simple_gui_creator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
1
+ =begin
2
+ Copyright 2010, Roger Pack
3
+ This file is part of Sensible Cinema.
4
+
5
+ Sensible Cinema is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ Sensible Cinema is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+ require File.expand_path(File.dirname(__FILE__) + '/common')
19
+
20
+ require 'socket' # gethostname
21
+
22
+ describe 'dvd_drive_info' do
23
+
24
+ it 'should be able to get an md5sum from a dvd' do
25
+ FileUtils.mkdir_p 'VIDEO_TS'
26
+ Dir.chdir 'VIDEO_TS' do
27
+ File.binwrite("VTS_01_0.IFO", "b")
28
+ File.binwrite("VIDEO_TS.IFO", "a")
29
+ end
30
+ # different because of different volume names I think
31
+ expected=
32
+ if Socket.gethostname == "PACKR-B1C04F564"
33
+ "212780b8|dbf8e73e"
34
+ elsif OS.mac?
35
+ "e293328f|519cd647"
36
+ else
37
+ p 'unknown drive label maybe expected?...' + DriveInfo.md5sum_disk("./") # unfortunately varies depending on drive label...
38
+ nil
39
+ end
40
+ p 'comparing', DriveInfo.md5sum_disk("./"), expected
41
+ DriveInfo.md5sum_disk("./").should == expected if expected
42
+ end
43
+
44
+ def assert_has_mounted_disk
45
+ raise "test requires locally mounted DVD!" if DriveInfo.get_dvd_drives_as_openstruct.length == 0
46
+ end
47
+
48
+ it "should be able to do it for real disc in the drive" do
49
+ assert_has_mounted_disk
50
+ found_one = false
51
+ DriveInfo.get_dvd_drives_as_openstruct.each{|d|
52
+ if d.VolumeName # mounted ...
53
+ DriveInfo.md5sum_disk(d.MountPoint).length.should be > 0
54
+ found_one = true
55
+ d.FreeSpace.should == 0
56
+ end
57
+ }
58
+ found_one.should be true
59
+ end
60
+
61
+ it "should return a drive with most space" do
62
+ space_drive = DriveInfo.get_drive_with_most_space_with_slash
63
+ space_drive[1..-1].should == ":/" if OS.windows? # hope forward slash is ok...
64
+ space_drive[0..0].should == "/" if !OS.windows?
65
+ require 'fileutils'
66
+ FileUtils.touch space_drive + 'touched_file'
67
+ FileUtils.rm space_drive + 'touched_file'
68
+ end
69
+
70
+ it "should be able to run it twice cached etc" do
71
+ assert_has_mounted_disk
72
+ assert system(OS.ruby_bin + " -rubygems -I.. run_drive_info.rb")
73
+ end
74
+
75
+ end
@@ -0,0 +1,67 @@
1
+ =begin
2
+ Copyright 2010, Roger Pack
3
+ This file is part of Sensible Cinema.
4
+
5
+ Sensible Cinema is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ Sensible Cinema is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+ require File.expand_path(File.dirname(__FILE__) + '/common')
19
+ require 'timeout'
20
+
21
+ p 'dont move the mouse!'
22
+
23
+ describe MouseControl do
24
+
25
+ it "should move it a couple times" do
26
+ old = MouseControl.total_movements
27
+ begin
28
+ Timeout::timeout(2) {
29
+ MouseControl.jitter_forever_in_own_thread.join
30
+ }
31
+ rescue Timeout::Error
32
+ end
33
+ MouseControl.total_movements.should be > old
34
+ end
35
+
36
+ it "should not move it if the user does" do
37
+ old = MouseControl.total_movements
38
+ begin
39
+ Timeout::timeout(2) {
40
+ MouseControl.jitter_forever_in_own_thread
41
+ x = 1
42
+ loop {
43
+ java.awt.Robot.new.mouse_move(500 + (x+=1),500); sleep 0.1;
44
+ }
45
+ }
46
+ rescue Timeout::Error
47
+ end
48
+ MouseControl.total_movements.should == old + 1
49
+ end
50
+
51
+ it "should be able to left mouse click" do
52
+ MouseControl.left_mouse_button_state.should be :up
53
+ MouseControl.left_mouse_down!
54
+ MouseControl.left_mouse_button_state.should be :down
55
+ MouseControl.left_mouse_up!
56
+ MouseControl.left_mouse_button_state.should be :up
57
+ end
58
+
59
+ it "should be able to click" do
60
+ MouseControl.left_mouse_button_state.should be :up
61
+ MouseControl.single_click_left_mouse_button
62
+ MouseControl.left_mouse_up!
63
+ MouseControl.left_mouse_up!
64
+ MouseControl.left_mouse_button_state.should be :up
65
+ end
66
+
67
+ end
@@ -0,0 +1,179 @@
1
+ require File.dirname(__FILE__)+ '/common'
2
+
3
+ describe ParseTemplate do
4
+
5
+ def parse_string string
6
+ @frame = ParseTemplate::JFramer.new
7
+ @frame.parse_setup_string(string)
8
+ @frame
9
+ end
10
+
11
+ after do
12
+ @frame.close if @frame
13
+ end
14
+
15
+ it "should parse titles" do
16
+ frame = parse_string " ------------A Title-------------------------------------------"
17
+ frame.title.should == "A Title"
18
+ frame.get_title.should == "A Title" # java method mapping :)
19
+ frame.original_title.should == "A Title"
20
+ frame.title= 'new title'
21
+ frame.get_title.should == "new title"
22
+ frame.original_title.should == "A Title"
23
+ end
24
+
25
+ it "should parse button only lines, with several buttons same line" do
26
+ frame = parse_string "| [Setup Preferences:preferences][Start:start] [Stop:stop] |"
27
+ get_dimentia(frame.elements[:stop]).should == [221, 10, 20, 60]
28
+ assert frame.elements.length == 3
29
+ prefs_button = frame.elements[:preferences]
30
+ start_button = frame.elements[:start]
31
+ prefs_button.text.should == "Setup Preferences"
32
+ get_dimentia(prefs_button).should == [10, 10, 20, 139]
33
+ assert start_button.text == "Start"
34
+ prefs_button.text = "new text"
35
+ assert prefs_button.text == "new text"
36
+ prefs_button.location.x.should_not == start_button.location.x
37
+ prefs_button.location.y.should == start_button.location.y
38
+ frame.get_size.height.should be > 0
39
+ frame.get_size.width.should be > 0
40
+ end
41
+
42
+ # it "should parse drop down lines"
43
+ # frame = parse_string "| [some dropdown lines:dropdowns \/] |"
44
+ # end
45
+
46
+ it "should parse text strings" do
47
+ frame = parse_string '| "Temp Dir location:temp_dir" |'
48
+ assert frame.elements.length == 1
49
+ frame.elements[:temp_dir].should_not be nil
50
+ end
51
+
52
+ it "should handle a string below buttons" do
53
+ frame = parse_string <<-EOL
54
+ ----------A title------------
55
+ | [a button:button] [a button2:button2] |
56
+ | "some text2:text1" |
57
+ ---------------------------------------
58
+ EOL
59
+ assert frame.elements.length == 3
60
+ end
61
+
62
+ it "should split escaped colons" do
63
+ frame = parse_string "| \"some stuff ::my_name\""
64
+ frame.elements[:my_name].text.should == 'some stuff :'
65
+ end
66
+
67
+ it "should not accept zero length strings without width spec" do
68
+ proc {frame = parse_string "| \":my_name\""}.should raise_exception
69
+ end
70
+
71
+ it "should accept zero length strings if they have a width spec" do
72
+ frame = parse_string "| \":my_name,width=250\""
73
+ frame.elements[:my_name].text.should == ''
74
+ end
75
+
76
+ it "should not add codeless items to elements" do
77
+ frame = parse_string " \"some stuff without a code name\" "
78
+ frame.elements.size.should == 0
79
+ end
80
+
81
+ it "should not allow unknown param settings" do
82
+ proc { parse_string " \" text:name,fake=fake \" "}.should raise_exception
83
+ end
84
+
85
+ # LODO allow internal sub-boxes LOL
86
+ # TODO mixeds on the same line
87
+ # LODO should pass the button through to on_clicked [?] or button with frame, too?
88
+ # LODO should be able to clear everything a button does or used to do...
89
+ # LODO a 'title managing' object LOL
90
+ # LODO rel_width=+100 or some odd
91
+ # buttons should require a code name :P
92
+ # allow prepropagation of textareas, for easier width detection...and/or separating out concerns...hmm...
93
+ # parse_setup_string string, :text_area_to_use_text => string
94
+ # parse_setup_string :default_font =>
95
+
96
+ it "should accept height, width, abs_x, abs_y" do
97
+ frame = parse_string ' [a:my_name,abs_x=1,abs_y=2,width=100,height=101] '
98
+ get_dimentia(frame.elements[:my_name]).should == [1,2,101,100]
99
+ end
100
+
101
+ it "should accept params, without a name" do
102
+ frame = parse_string ' "a:abs_x=1,abs_y=1,width=100,height=100" '
103
+ frame.elements.should be_empty
104
+ end
105
+
106
+ it "should allow for symbol access" do
107
+ frame = parse_string '| "a:my_name" |'
108
+ frame.elements[:my_name].text.should == 'a'
109
+ end
110
+
111
+ it "should do rstrip on symbol names" do
112
+ frame = parse_string '| "a:my_name " |'
113
+ frame.elements[:my_name].text.should == 'a'
114
+ end
115
+
116
+ it "should disallow double names...I think so anyway..." do
117
+ proc { frame = parse_string('| "a:my_name" |\n'*2) }.should raise_exception
118
+ end
119
+
120
+ def get_dimentia(element)
121
+ x = element.get_location.x
122
+ y = element.get_location.y
123
+ h = element.size.height
124
+ w = element.size.width
125
+ [x,y,h,w]
126
+ end
127
+
128
+ it "should line up elements right when given some abs" do
129
+ frame = parse_string <<-EOL
130
+ | [a button:button_name,width=100,height=100,abs_x=50,abs_y=50] [a third button:third]
131
+ | [another button:button_name2] [another button:button_name4]|
132
+ | [another button:button_name3] |
133
+ EOL
134
+ get_dimentia(frame.elements[:button_name]).should == [50,50,100,100]
135
+ #assert_matches_dimentia(frame.elements[:third],
136
+ # TODO
137
+
138
+ end
139
+
140
+ it "should parse blank buttons with the extra space counting for size" do
141
+ frame = parse_string " | [ :text_to_use] |"
142
+ button = frame.elements[:text_to_use]
143
+ button.text.should == "" # torn on this one...
144
+ button.size.width.should==129 # bigger than 35, basically
145
+ end
146
+
147
+ it "should parse text areas" do
148
+ string = <<-EOL
149
+ | [ :text_area] |
150
+ | [ ] |
151
+ EOL
152
+ frame = parse_string string
153
+ frame.elements[:text_area].class.should == Java::JavaxSwing::JTextArea
154
+ frame.elements.length.should == 1 # not create fake empty buttons underneath :)
155
+ get_dimentia(frame.elements[:text_area]).should == [0, 0, 32, 319]# it's "sub-contained" in a jscrollpane <sigh>
156
+ end
157
+
158
+ it "should let you use ending colons" do
159
+ frame = parse_string "\"Here's your template:\""
160
+ frame.elements.length.should == 0 # and hope it includes the colon in there :)
161
+ end
162
+
163
+
164
+ it "should allow for spaced out attributes" do
165
+ frame = parse_string "| [ :text, width = 200 ] "
166
+ get_dimentia(frame.elements[:text])[3].should == 200
167
+ end
168
+
169
+ it "should parse text areas that aren't first, also one right next to it both sides"
170
+
171
+ it "should allow for blank lines to mean spacing" do
172
+ frame = parse_string "| [ a button] |\n [ a button] \n[ a button]"
173
+ frame.size.height.should == 125
174
+ frame.close
175
+ frame = parse_string "| [ a button] |\n [ a button] \n[ a button]\n| |"
176
+ frame.size.height.should == 150
177
+ end
178
+
179
+ end
@@ -0,0 +1,31 @@
1
+ require 'common.rb'
2
+
3
+ # also test PlayAudio
4
+ describe PlayMp3Audio do
5
+
6
+ it "can play mp3 files" do
7
+ a = PlayMp3Audio.new 'diesel.mp3'
8
+ a.play_non_blocking
9
+ puts 'non silence'
10
+ sleep 1
11
+ a.stop
12
+ puts 'silence'
13
+ sleep 1
14
+ end
15
+
16
+ it "can join" do
17
+ a = PlayMp3Audio.new 'diesel.mp3'
18
+ a.play_till_end
19
+ end
20
+
21
+ it "can play wav" do
22
+ a = PlayAudio.new 'static.wav'
23
+ a.start
24
+ puts 'static'
25
+ sleep 1
26
+ puts 'silence'
27
+ a.stop
28
+ sleep 1
29
+ end
30
+
31
+ end
@@ -0,0 +1,11 @@
1
+ require 'common.rb'
2
+
3
+ describe RubyClip do
4
+
5
+ it "should be able to get and set clipboard" do
6
+ string = 'from' + rand(33).to_s
7
+ RubyClip.set_clipboard string
8
+ RubyClip.get_clipboard_contents.should == string
9
+ end
10
+
11
+ end
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__) + '/common'
2
+ DriveInfo.create_looping_drive_cacher
3
+ DriveInfo.create_looping_drive_cacher
4
+ raise unless DriveInfo.get_dvd_drives_as_openstruct.length > 0
data/spec/static.wav ADDED
Binary file
@@ -0,0 +1,140 @@
1
+ =begin
2
+ Copyright 2010, Roger Pack
3
+ This file is part of Sensible Cinema.
4
+
5
+ Sensible Cinema is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ Sensible Cinema is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+
19
+ require File.expand_path(File.dirname(__FILE__) + '/common')
20
+
21
+ module SwingHelpers
22
+ describe 'functionality' do
23
+ puts "most of these require user interaction, sadly"
24
+
25
+ it "should close its modeless dialog" do
26
+
27
+ dialog = NonBlockingDialog.new("Is this modeless?")
28
+ dialog = NonBlockingDialog.new("Is this modeless?\nSecond lineLL")
29
+ dialog = NonBlockingDialog.new("Is this modeless?\nSecond lineLL\nThird line too!")
30
+ dialog = NonBlockingDialog.new("Can this take very long lines of input, like super long?")
31
+ dialog.dispose # should get here :P
32
+ # comment out to let user see+close it :P
33
+ end
34
+
35
+ it "should be able to convert filenames well" do
36
+ if OS.windows?
37
+ "a/b/c".to_filename.should == File.expand_path("a\\b\\c").gsub('/', "\\")
38
+ else
39
+ "a/b/c".to_filename.should == File.expand_path("a/b/c")
40
+ end
41
+ end
42
+
43
+ it "should reveal a file" do
44
+ FileUtils.touch "a b"
45
+ SwingHelpers.show_in_explorer "a b"
46
+ Dir.mkdir "a dir" unless File.exist?('a dir')
47
+ SwingHelpers.show_in_explorer "a dir"
48
+ end
49
+
50
+ it "should reveal a url" do
51
+ SwingHelpers.open_url_to_view_it_non_blocking "http://www.google.com"
52
+ end
53
+
54
+ it "should select folders" do
55
+ raise unless File.directory?(c = SwingHelpers.new_existing_dir_chooser_and_go('hello', '.'))
56
+ p c
57
+ raise unless File.directory?(c = SwingHelpers.new_existing_dir_chooser_and_go)
58
+ p c
59
+ end
60
+
61
+ it "should select nonexisting" do
62
+ name = JFileChooser.new_nonexisting_filechooser_and_go 'should force you to select nonexisting..'
63
+ raise if File.exist? name
64
+ name = SwingHelpers.new_previously_existing_file_selector_and_go 'should forc select existing file, try to select nonexist'
65
+ raise unless File.exist? name # it forced them to retry
66
+ end
67
+
68
+ it "should show onminimize" do
69
+ a = JFrame.new 'minimize me'
70
+ a.set_size 200,200
71
+ minimized = false
72
+ count = 0
73
+ a.after_minimized {
74
+ count += 1
75
+ }
76
+ a.show
77
+ sleep 1
78
+ a.minimize
79
+ sleep 0.2
80
+ assert count == 1
81
+ a.show
82
+ sleep 0.2
83
+ a.minimize
84
+ sleep 0.2
85
+ assert count == 1
86
+ a.restore
87
+ sleep 0.2
88
+ a.minimize
89
+ sleep 0.2
90
+ assert count == 2
91
+ a.close
92
+ end
93
+
94
+ def loop_with_timeout(seconds)
95
+ start = Time.now
96
+ while(Time.now - start < seconds)
97
+ if !yield
98
+ sleep 0.5
99
+ else
100
+ return
101
+ end
102
+ end
103
+
104
+ end
105
+
106
+ it "should have an after_close method" do
107
+ a = JFrame.new 'close me!'
108
+ a.set_size 200,200
109
+ closed = 0
110
+ a.after_closed {
111
+ closed += 1
112
+ }
113
+ a.show
114
+ a.close
115
+ sleep 0.2
116
+ assert closed == 1
117
+ end
118
+
119
+ it "should have an after_restored method" do
120
+ a = JFrame.new ''
121
+ success = 0
122
+ a.after_restored_either_way {
123
+ success += 1
124
+ a.close
125
+ }
126
+ a.show
127
+ a.minimize
128
+ a.restore
129
+ sleep 0.2
130
+ assert success == 1
131
+ a.maximize
132
+ a.restore
133
+ sleep 0.2
134
+ assert success == 1
135
+ end
136
+
137
+ end
138
+ end
139
+
140
+ puts 'close the windows...'
data/vendor/dvdid.exe ADDED
Binary file
Binary file
@@ -0,0 +1,67 @@
1
+ /* $Id: dvdid.h 3209 2009-10-14 14:41:34Z chris $ */
2
+
3
+ #ifndef DVDID__DVDID_H
4
+ #define DVDID__DVDID_H
5
+
6
+
7
+ #include <stdint.h>
8
+
9
+
10
+ #include "export.h"
11
+
12
+
13
+ #ifdef __cplusplus
14
+ extern "C" {
15
+ #endif
16
+
17
+
18
+ enum dvdid_status_e {
19
+ DVDID_STATUS_OK = 0,
20
+ DVDID_STATUS_MALLOC_ERROR,
21
+
22
+ /* Error that should only be returned by dvdid_calculate (but not test of API) */
23
+ DVDID_STATUS_PLATFORM_UNSUPPORTED,
24
+ DVDID_STATUS_READ_VIDEO_TS_ERROR,
25
+ DVDID_STATUS_READ_VMGI_ERROR,
26
+ DVDID_STATUS_READ_VTS01I_ERROR,
27
+
28
+ DVDID_STATUS_DETECT_MEDIUM_ERROR,
29
+ DVDID_STATUS_MEDIUM_UNKNOWN,
30
+ DVDID_STATUS_FIXUP_SIZE_ERROR,
31
+
32
+ DVDID_STATUS_READ_VCD_ERROR,
33
+ DVDID_STATUS_READ_CDI_ERROR,
34
+ DVDID_STATUS_READ_EXT_ERROR,
35
+ DVDID_STATUS_READ_KARAOKE_ERROR,
36
+ DVDID_STATUS_READ_CDDA_ERROR,
37
+ DVDID_STATUS_READ_MPEGAV_ERROR,
38
+ DVDID_STATUS_READ_SEGMENT_ERROR,
39
+ DVDID_STATUS_READ_INFO_VCD_ERROR,
40
+ DVDID_STATUS_READ_ENTRIES_VCD_ERROR,
41
+
42
+ DVDID_STATUS_READ_SVCD_ERROR,
43
+ DVDID_STATUS_READ_MPEG2_ERROR,
44
+ DVDID_STATUS_READ_INFO_SVD_ERROR,
45
+ DVDID_STATUS_READ_ENTRIES_SVD_ERROR,
46
+ DVDID_STATUS_READ_TRACKS_SVD_ERROR,
47
+ };
48
+
49
+
50
+ typedef enum dvdid_status_e dvdid_status_t;
51
+
52
+ /*
53
+ If unsucessful, errn will be set to a platform specific error number, or zero if no
54
+ such information is available. If errn is NULL, the parameter will be ignored.
55
+ */
56
+ DVDID_API(dvdid_status_t) dvdid_calculate(uint64_t *discid, const char* path, int *errn);
57
+
58
+ /* Get a pointer to a string describing the contents of a dvdid_status_t */
59
+ DVDID_API(const char*) dvdid_error_string(dvdid_status_t status);
60
+
61
+
62
+ #ifdef __cplusplus
63
+ }
64
+ #endif
65
+
66
+
67
+ #endif