win_gui 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/.gitignore +21 -21
  2. data/HISTORY +7 -0
  3. data/LICENSE +20 -20
  4. data/README.rdoc +77 -114
  5. data/Rakefile +24 -58
  6. data/VERSION +1 -1
  7. data/features/support/env.rb +7 -4
  8. data/features/win_gui.feature +9 -9
  9. data/lib/version.rb +8 -0
  10. data/lib/win_gui/window.rb +78 -69
  11. data/lib/win_gui.rb +25 -3
  12. data/spec/spec.opts +1 -1
  13. data/spec/spec_helper.rb +90 -118
  14. data/spec/win_gui/window_spec.rb +120 -123
  15. data/tasks/common.rake +14 -0
  16. data/tasks/doc.rake +14 -0
  17. data/tasks/gem.rake +39 -0
  18. data/tasks/git.rake +34 -0
  19. data/tasks/spec.rake +19 -0
  20. data/tasks/version.rake +71 -0
  21. metadata +68 -188
  22. data/.document +0 -5
  23. data/book_code/early_success/bundle.rb +0 -34
  24. data/book_code/early_success/english.txt +0 -1
  25. data/book_code/early_success/jruby_basics.rb +0 -47
  26. data/book_code/early_success/windows_basics.rb +0 -97
  27. data/book_code/guessing/locknote.rb +0 -379
  28. data/book_code/guessing/monkeyshines.rb +0 -14
  29. data/book_code/guessing/note.rb +0 -120
  30. data/book_code/guessing/note_spec.rb +0 -175
  31. data/book_code/guessing/replay.rb +0 -21
  32. data/book_code/guessing/seed.rb +0 -9
  33. data/book_code/guessing/spec_helper.rb +0 -69
  34. data/book_code/guessing/windows_gui.rb +0 -247
  35. data/book_code/home_stretch/junquenote.rb +0 -151
  36. data/book_code/home_stretch/locknote.rb +0 -180
  37. data/book_code/home_stretch/note.rb +0 -144
  38. data/book_code/home_stretch/note_spec.rb +0 -191
  39. data/book_code/home_stretch/spec_helper.rb +0 -55
  40. data/book_code/home_stretch/swing_gui.rb +0 -50
  41. data/book_code/home_stretch/windows_gui.rb +0 -232
  42. data/book_code/junquenote/exports.sh +0 -10
  43. data/book_code/junquenote/jruby_mac.sh +0 -10
  44. data/book_code/junquenote/junquenote_app.rb +0 -262
  45. data/book_code/novite/Rakefile +0 -10
  46. data/book_code/novite/app/controllers/application.rb +0 -18
  47. data/book_code/novite/app/controllers/guests_controller.rb +0 -28
  48. data/book_code/novite/app/controllers/parties_controller.rb +0 -77
  49. data/book_code/novite/app/helpers/application_helper.rb +0 -11
  50. data/book_code/novite/app/helpers/guests_helper.rb +0 -10
  51. data/book_code/novite/app/helpers/parties_helper.rb +0 -10
  52. data/book_code/novite/app/models/guest.rb +0 -11
  53. data/book_code/novite/app/models/party.rb +0 -32
  54. data/book_code/novite/app/models/party_mailer.rb +0 -19
  55. data/book_code/novite/app/views/layouts/application.rhtml +0 -44
  56. data/book_code/novite/app/views/parties/new.html.erb +0 -42
  57. data/book_code/novite/app/views/parties/show.html.erb +0 -43
  58. data/book_code/novite/app/views/party_mailer/invite.erb +0 -17
  59. data/book_code/novite/config/boot.rb +0 -117
  60. data/book_code/novite/config/database.yml +0 -19
  61. data/book_code/novite/config/environment.rb +0 -67
  62. data/book_code/novite/config/environments/development.rb +0 -29
  63. data/book_code/novite/config/environments/production.rb +0 -27
  64. data/book_code/novite/config/environments/test.rb +0 -30
  65. data/book_code/novite/config/initializers/inflections.rb +0 -18
  66. data/book_code/novite/config/initializers/mime_types.rb +0 -13
  67. data/book_code/novite/config/routes.rb +0 -47
  68. data/book_code/novite/db/migrate/001_create_parties.rb +0 -26
  69. data/book_code/novite/db/migrate/002_create_guests.rb +0 -23
  70. data/book_code/novite/db/schema.rb +0 -41
  71. data/book_code/novite/log/empty.txt +0 -0
  72. data/book_code/novite/public/.htaccess +0 -40
  73. data/book_code/novite/public/404.html +0 -38
  74. data/book_code/novite/public/422.html +0 -38
  75. data/book_code/novite/public/500.html +0 -38
  76. data/book_code/novite/public/dispatch.cgi +0 -10
  77. data/book_code/novite/public/dispatch.fcgi +0 -24
  78. data/book_code/novite/public/dispatch.rb +0 -18
  79. data/book_code/novite/public/favicon.ico +0 -0
  80. data/book_code/novite/public/images/rails.png +0 -0
  81. data/book_code/novite/public/index.html +0 -285
  82. data/book_code/novite/public/javascripts/application.js +0 -10
  83. data/book_code/novite/public/javascripts/controls.js +0 -971
  84. data/book_code/novite/public/javascripts/dragdrop.js +0 -980
  85. data/book_code/novite/public/javascripts/effects.js +0 -1128
  86. data/book_code/novite/public/javascripts/prototype.js +0 -4233
  87. data/book_code/novite/public/robots.txt +0 -5
  88. data/book_code/novite/script/about +0 -3
  89. data/book_code/novite/script/console +0 -3
  90. data/book_code/novite/script/destroy +0 -3
  91. data/book_code/novite/script/generate +0 -3
  92. data/book_code/novite/script/performance/benchmarker +0 -3
  93. data/book_code/novite/script/performance/profiler +0 -3
  94. data/book_code/novite/script/performance/request +0 -3
  95. data/book_code/novite/script/plugin +0 -3
  96. data/book_code/novite/script/process/inspector +0 -3
  97. data/book_code/novite/script/process/reaper +0 -3
  98. data/book_code/novite/script/process/spawner +0 -3
  99. data/book_code/novite/script/runner +0 -3
  100. data/book_code/novite/script/server +0 -3
  101. data/book_code/novite/test/test_helper.rb +0 -46
  102. data/book_code/one_more_thing/applescript.rb +0 -68
  103. data/book_code/one_more_thing/note_spec.rb +0 -50
  104. data/book_code/one_more_thing/spec_helper.rb +0 -17
  105. data/book_code/one_more_thing/textedit-pure.rb +0 -28
  106. data/book_code/one_more_thing/textedit.applescript +0 -26
  107. data/book_code/one_more_thing/textedit.rb +0 -32
  108. data/book_code/one_more_thing/textnote.rb +0 -87
  109. data/book_code/simplify/junquenote.rb +0 -48
  110. data/book_code/simplify/locknote.rb +0 -46
  111. data/book_code/simplify/note.rb +0 -35
  112. data/book_code/simplify/note_spec.rb +0 -28
  113. data/book_code/simplify/swing_gui.rb +0 -45
  114. data/book_code/simplify/windows_gui.rb +0 -232
  115. data/book_code/simplify/windows_gui_spec.rb +0 -35
  116. data/book_code/story/invite.story +0 -19
  117. data/book_code/story/journal.txt +0 -29
  118. data/book_code/story/novite_stories.rb +0 -156
  119. data/book_code/story/party.rb +0 -149
  120. data/book_code/story/password.rb +0 -61
  121. data/book_code/story/password.story +0 -26
  122. data/book_code/story/rsvp.story +0 -29
  123. data/book_code/tables/TestTime.html +0 -93
  124. data/book_code/tables/TestTimeSample.html +0 -63
  125. data/book_code/tables/calculate_time.rb +0 -39
  126. data/book_code/tables/calculator.rb +0 -108
  127. data/book_code/tables/calculator_actions.rb +0 -27
  128. data/book_code/tables/calculator_spec.rb +0 -47
  129. data/book_code/tables/fit.rb +0 -32
  130. data/book_code/tables/matrix.rb +0 -109
  131. data/book_code/tables/pseudocode.rb +0 -17
  132. data/book_code/tubes/book_selenium.rb +0 -67
  133. data/book_code/tubes/book_watir.rb +0 -60
  134. data/book_code/tubes/dragdrop.html +0 -81
  135. data/book_code/tubes/html_capture.rb +0 -33
  136. data/book_code/tubes/joke_list.rb +0 -67
  137. data/book_code/tubes/list_spec.rb +0 -41
  138. data/book_code/tubes/search_spec.rb +0 -32
  139. data/book_code/tubes/selenium_example.rb +0 -66
  140. data/book_code/tubes/selenium_link.rb +0 -23
  141. data/book_code/tubes/web_server.rb +0 -14
  142. data/book_code/windows/wgui.rb +0 -29
  143. data/book_code/windows/wobj.rb +0 -25
  144. data/book_code/windows/wsh.rb +0 -25
  145. data/book_code/with_rspec/empty_spec.rb +0 -13
  146. data/book_code/with_rspec/junquenote.rb +0 -60
  147. data/book_code/with_rspec/locknote.rb +0 -129
  148. data/book_code/with_rspec/note_spec.rb +0 -32
  149. data/book_code/with_rspec/should_examples.rb +0 -18
  150. data/lib/note/java/jemmy.jar +0 -0
  151. data/lib/note/java/jnote.rb +0 -48
  152. data/lib/note/java/jruby_basics.rb +0 -37
  153. data/lib/note/java/junquenote_app.rb +0 -262
  154. data/lib/note/java/note_spec.rb +0 -20
  155. data/lib/note/win/locknote.rb +0 -19
  156. data/lib/note.rb +0 -15
  157. data/lib/win_gui/constants.rb +0 -82
  158. data/lib/win_gui/def_api.rb +0 -160
  159. data/lib/win_gui/string_extensions.rb +0 -36
  160. data/lib/win_gui/win_gui.rb +0 -437
  161. data/old/windows_basics.rb +0 -80
  162. data/old/wnote.rb +0 -80
  163. data/old/wnote_spec.rb +0 -20
  164. data/spec/note/win/locknote_spec.rb +0 -7
  165. data/spec/test_apps/locknote/LockNote.exe +0 -0
  166. data/spec/win_gui/def_api_spec.rb +0 -339
  167. data/spec/win_gui/string_extensions_spec.rb +0 -61
  168. data/spec/win_gui/win_gui_spec.rb +0 -537
  169. data/win_gui.gemspec +0 -215
data/spec/spec_helper.rb CHANGED
@@ -1,118 +1,90 @@
1
- lib_dir = File.join(File.dirname(__FILE__), "..", "lib" )
2
- $LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
3
- require 'spec'
4
- require 'win_gui'
5
- require 'note'
6
-
7
- # Customize RSpec with my own extensions
8
- module SpecMacros
9
-
10
- # wrapper for it method that extracts description from example source code, such as:
11
- # spec { use{ function(arg1 = 4, arg2 = 'string') }}
12
- def spec &block
13
- it description_from(*block.source_location), &block
14
- end
15
-
16
- # reads description line from source file and drops external brackets (like its{}, use{}
17
- def description_from(file, line)
18
- File.open(file) do |f|
19
- f.lines.to_a[line-1].gsub( /(spec.*?{)|(use.*?{)|}/, '' ).strip
20
- end
21
- end
22
- end
23
-
24
- Spec::Runner.configure { |config| config.extend(SpecMacros) }
25
-
26
- module GuiTest
27
- include WinGui
28
-
29
- # Test related Constants:
30
- TEST_TIMEOUT = 0.001
31
- TEST_KEY_DELAY = 0.001
32
- TEST_SLEEP_DELAY = 0.01
33
- TEST_APP_PATH = File.join(File.dirname(__FILE__), "test_apps/locknote/LockNote.exe" )
34
- TEST_APP_START = 'start "" "' + TEST_APP_PATH + '"'
35
- TEST_WIN_TITLE = 'LockNote - Steganos LockNote'
36
- TEST_WIN_CLASS = 'ATL:00434098'
37
- TEST_WIN_RECT = [710, 400, 1210, 800]
38
- TEST_MAX_RECT = [-4, -4, 1924, 1204] # on my 1920x1200 display
39
- TEST_MIN_RECT = [-32000, -32000, -31840, -31976]
40
- TEST_TEXTAREA_CLASS = 'ATL:00434310'
41
- TEST_STATUSBAR_CLASS = 'msctls_statusbar32'
42
- TEST_IMPOSSIBLE = 'Impossible'
43
- TEST_ERROR_CONVERSION = /Can.t convert/
44
-
45
- # Helper methods:
46
- def use
47
- lambda {yield}.should_not raise_error
48
- end
49
-
50
- def any_handle
51
- WinGui.def_api 'FindWindow', 'PP', 'L' unless respond_to? :find_window
52
- find_window(nil, nil)
53
- end
54
-
55
- def not_a_handle
56
- 123
57
- end
58
-
59
- def any_block
60
- lambda {|*args| args}
61
- end
62
-
63
- def hide_method(*names) # hide original method(s) if it is defined
64
- names.map(&:to_s).each do |name|
65
- WinGui.module_eval do
66
- aliases = generate_names(name, {}).flatten + [name]
67
- aliases.map(&:to_s).each do |ali|
68
- if method_defined? ali
69
- alias_method "orig_#{ali}".to_sym, ali
70
- remove_method ali
71
- end
72
- end
73
- end
74
- end
75
- end
76
-
77
- def restore_method(*names) # restore original method if it was hidden
78
- names.map(&:to_s).each do |name|
79
- WinGui.module_eval do
80
- aliases = generate_names(name, {}).flatten + [name]
81
- aliases.map(&:to_s).each do |ali|
82
- temp = "orig_#{ali}".to_sym
83
- if method_defined? temp
84
- alias_method ali, temp
85
- remove_method temp
86
- end
87
- end
88
- end
89
- end
90
- end
91
-
92
- def launch_test_app
93
- system TEST_APP_START
94
- sleep TEST_SLEEP_DELAY until (handle = find_window(nil, TEST_WIN_TITLE))
95
- @launched_test_app = Window.new handle
96
- end
97
-
98
- def close_test_app(app = @launched_test_app)
99
- while app and app.respond_to? :handle and find_window(nil, TEST_WIN_TITLE)
100
- post_message(app.handle, WM_SYSCOMMAND, SC_CLOSE, 0)
101
- sleep TEST_SLEEP_DELAY
102
- end
103
- @launched_test_app = nil
104
- end
105
-
106
- # Creates test app object and yields it back to the block
107
- def test_app
108
- app = launch_test_app
109
-
110
- def app.textarea #define singleton method retrieving app's text area
111
- Window.new find_window_ex(self.handle, 0, TEST_TEXTAREA_CLASS, nil)
112
- end
113
-
114
- yield app
115
- close_test_app
116
- end
117
-
118
- end
1
+ require 'spec'
2
+ require 'spec/autorun'
3
+ require 'win_gui'
4
+
5
+ # Customize RSpec with my own extensions
6
+ module SpecMacros
7
+
8
+ # wrapper for it method that extracts description from example source code, such as:
9
+ # spec { use{ function(arg1 = 4, arg2 = 'string') }}
10
+ def spec &block
11
+ it description_from(*block.source_location), &block
12
+ end
13
+
14
+ # reads description line from source file and drops external brackets (like its{}, use{}
15
+ def description_from(file, line)
16
+ File.open(file) do |f|
17
+ f.lines.to_a[line-1].gsub( /(spec.*?{)|(use.*?{)|}/, '' ).strip
18
+ end
19
+ end
20
+ end
21
+
22
+ Spec::Runner.configure { |config| config.extend(SpecMacros) }
23
+
24
+ module WinGuiTest
25
+ include Win::Gui
26
+
27
+ # Test related Constants:
28
+ TIMEOUT = 0.001
29
+ KEY_DELAY = 0.001
30
+ SLEEP_DELAY = 0.01
31
+ APP_PATH = File.join(File.dirname(__FILE__), "../misc/locknote/LockNote.exe" )
32
+ APP_START = RUBY_PLATFORM =~ /cygwin/ ? "cmd /c start `cygpath -w #{APP_PATH}`" : "start #{APP_PATH}"
33
+ # end
34
+ #
35
+ # 'start "" "' + APP_PATH + '"'
36
+ WIN_TITLE = 'LockNote - Steganos LockNote'
37
+ WIN_CLASS = 'ATL:00434098'
38
+ WIN_RECT = [710, 400, 1210, 800]
39
+ MAX_RECT = [-4, -4, 1924, 1204] # on my 1920x1200 display
40
+ MIN_RECT = [-32000, -32000, -31840, -31976]
41
+ TEXTAREA_CLASS = 'ATL:00434310'
42
+ STATUSBAR_CLASS = 'msctls_statusbar32'
43
+ IMPOSSIBLE = 'Impossible'
44
+ ERROR_CONVERSION = /Can.t convert/
45
+
46
+ # Helper methods:
47
+ def use
48
+ lambda {yield}.should_not raise_error
49
+ end
50
+
51
+ def any_handle
52
+ WinGui.def_api 'FindWindow', 'PP', 'L' unless respond_to? :find_window
53
+ find_window(nil, nil)
54
+ end
55
+
56
+ def not_a_handle
57
+ 123
58
+ end
59
+
60
+ def any_block
61
+ lambda {|*args| args}
62
+ end
63
+
64
+ def launch_test_app
65
+ system APP_START
66
+ sleep SLEEP_DELAY until (handle = find_window(nil, WIN_TITLE))
67
+ @launched_test_app = Window.new handle
68
+ end
69
+
70
+ def close_test_app(app = @launched_test_app)
71
+ while app && app.respond_to?(:handle) && find_window(nil, WIN_TITLE)
72
+ post_message(app.handle, WM_SYSCOMMAND, SC_CLOSE, nil)
73
+ sleep SLEEP_DELAY
74
+ end
75
+ @launched_test_app = nil
76
+ end
77
+
78
+ # Creates test app object and yields it back to the block
79
+ def test_app
80
+ app = launch_test_app
81
+
82
+ def app.textarea #define singleton method retrieving app's text area
83
+ Window.new find_window_ex(self.handle, 0, TEXTAREA_CLASS, nil)
84
+ end
85
+
86
+ yield app
87
+ close_test_app
88
+ end
89
+
90
+ end
@@ -1,124 +1,121 @@
1
- require File.join(File.dirname(__FILE__), ".." , "spec_helper" )
2
-
3
- module GuiTest
4
-
5
- describe Window do
6
- before(:each) { @app = launch_test_app }
7
- after(:each){ close_test_app }
8
-
9
- context 'creating' do
10
- it 'can be wrapped around any existing window' do
11
- any_handle = find_window(nil, nil)
12
- use{ Window.new any_handle }
13
- end
14
-
15
- it 'can be wrapped around specific window' do
16
- use{ Window.new @app.handle }
17
- end
18
- end
19
-
20
- context 'manipulating' do
21
-
22
- it 'has handle property equal to underlying window handle' do
23
- any_handle = find_window(nil, nil)
24
- any = Window.new any_handle
25
- any.handle.should == any_handle
26
- end
27
-
28
- it 'has text property equal to underlying window text(title)' do
29
- @app.text.should == TEST_WIN_TITLE
30
- end
31
-
32
- it 'closes when asked nicely' do
33
- @app.close
34
- sleep TEST_SLEEP_DELAY # needed to ensure window had enough time to close down
35
- find_window(nil, TEST_WIN_TITLE).should == nil
36
- end
37
-
38
- it 'waits f0r window to disappear (NB: this happens before handle is released!)' do
39
- start = Time.now
40
- @app.close
41
- @app.wait_for_close
42
- (Time.now - start).should be <= WG_CLOSE_TIMEOUT
43
- window_visible?(@app.handle).should be false
44
- end
45
- end
46
-
47
- context '.top_level class method' do
48
- it 'finds any top-level window (title = nil) and wraps it in a Window object' do
49
- use { @win = Window.top_level(title = nil, timeout_sec = 3) }
50
- Window.should === @win
51
- end
52
-
53
- it 'finds top-level window by title and wraps it in a Window object' do
54
- win = Window.top_level( TEST_WIN_TITLE, 1)
55
- win.handle.should == @app.handle
56
- end
57
- end
58
-
59
- context '#child' do
60
- spec { use { @control = @app.child(title_class_id = nil) }}
61
-
62
- it 'finds any child window(control) if given nil' do
63
- @app.child(nil).should_not == nil
64
- end
65
-
66
- it 'finds child window(control) by class' do
67
- @app.child(TEST_TEXTAREA_CLASS).should_not == nil
68
- end
69
-
70
- it 'finds child window(control) by name' do
71
- pending 'Need to find control with short name'
72
- @app.child(TEST_TEXTAREA_TEXT).should_not == nil
73
- end
74
-
75
- it 'finds child window(control) by control ID' do
76
- pending 'Need to find some control ID'
77
- @app.child(TEST_TEXTAREA_ID).should_not == nil
78
- end
79
-
80
- it 'raises error if wrong control is given' do
81
- expect { @app.child('Impossible Control')}.to raise_error "Control 'Impossible Control' not found"
82
- end
83
- it 'substitutes & for _ when searching by title ("&Yes" type controls)'
84
-
85
- end
86
-
87
- context '#children' do
88
- spec { use { children = @app.children }}
89
-
90
- it 'returns an array' do
91
- @app.children.should be_a_kind_of(Array)
92
- end
93
-
94
- it 'returns an array of all child windows to the given window ' do
95
- children = @app.children
96
- children.should be_a_kind_of Array
97
- children.should_not be_empty
98
- children.should have(2).elements
99
- children.each{|child| child?(@app.handle, child.handle).should == true }
100
- get_class_name(children.last.handle).should == TEST_TEXTAREA_CLASS
101
- end
102
-
103
- # it 'finds child window(control) by name' do
104
- # pending 'Need to find control with short name'
105
- # @app.child(TEST_TEXTAREA_TEXT).should_not == nil
106
- # end
107
- #
108
- # it 'finds child window(control) by control ID' do
109
- # pending 'Need to find some control ID'
110
- # @app.child(TEST_TEXTAREA_ID).should_not == nil
111
- # end
112
- #
113
- # it 'raises error if wrong control is given' do
114
- # expect { @app.child('Impossible Control')}.to raise_error "Control 'Impossible Control' not found"
115
- # end
116
- # it 'substitutes & for _ when searching by title ("&Yes" type controls)'
117
-
118
- end
119
-
120
- context '#click' do
121
- it 'emulates clicking of the control identified by id'
122
- end
123
- end
1
+ require File.join(File.dirname(__FILE__), ".." , "spec_helper" )
2
+
3
+ module WinGuiTest
4
+ include WinGui
5
+
6
+ describe Window do
7
+ before(:each) { @app = launch_test_app }
8
+ after(:each){ close_test_app }
9
+
10
+ context 'initializing' do
11
+ it 'can be wrapped around any existing window' do
12
+ any_handle = find_window(nil, nil)
13
+ use{ Window.new any_handle }
14
+ end
15
+ end
16
+
17
+ context 'manipulating' do
18
+
19
+ it 'has handle property equal to underlying window handle' do
20
+ any_handle = find_window(nil, nil)
21
+ any = Window.new any_handle
22
+ any.handle.should == any_handle
23
+ end
24
+
25
+ it 'has text property equal to underlying window text(title)' do
26
+ @app.text.should == WIN_TITLE
27
+ end
28
+
29
+ it 'closes when asked nicely' do
30
+ @app.close
31
+ sleep SLEEP_DELAY # needed to ensure window had enough time to close down
32
+ find_window(nil, WIN_TITLE).should == nil
33
+ end
34
+
35
+ it 'waits f0r window to disappear (NB: this happens before handle is released!)' do
36
+ start = Time.now
37
+ @app.close
38
+ @app.wait_for_close
39
+ (Time.now - start).should be <= WG_CLOSE_TIMEOUT
40
+ window_visible?(@app.handle).should be false
41
+ end
42
+ end
43
+
44
+ context '.top_level class method' do
45
+ it 'finds any top-level window (title = nil) and wraps it in a Window object' do
46
+ use { @win = Window.top_level(title = nil, timeout_sec = 3) }
47
+ Window.should === @win
48
+ end
49
+
50
+ it 'finds top-level window by title and wraps it in a Window object' do
51
+ win = Window.top_level( WIN_TITLE, 1)
52
+ win.handle.should == @app.handle
53
+ end
54
+ end
55
+
56
+ context '#child' do
57
+ spec { use { @control = @app.child(title_class_id = nil) }}
58
+
59
+ it 'finds any child window(control) if given nil' do
60
+ @app.child(nil).should_not == nil
61
+ end
62
+
63
+ it 'finds child window(control) by class' do
64
+ @app.child(TEXTAREA_CLASS).should_not == nil
65
+ end
66
+
67
+ it 'finds child window(control) by name' do
68
+ pending 'Need to find control with short name'
69
+ @app.child(TEXTAREA_TEXT).should_not == nil
70
+ end
71
+
72
+ it 'finds child window(control) by control ID' do
73
+ pending 'Need to find some control ID'
74
+ @app.child(TEXTAREA_ID).should_not == nil
75
+ end
76
+
77
+ it 'raises error if wrong control is given' do
78
+ expect { @app.child('Impossible Control')}.to raise_error "Control 'Impossible Control' not found"
79
+ end
80
+ it 'substitutes & for _ when searching by title ("&Yes" type controls)'
81
+
82
+ end
83
+
84
+ context '#children' do
85
+ spec { use { children = @app.children }}
86
+
87
+ it 'returns an array' do
88
+ @app.children.should be_a_kind_of(Array)
89
+ end
90
+
91
+ it 'returns an array of all child windows to the given window ' do
92
+ children = @app.children
93
+ children.should be_a_kind_of Array
94
+ children.should_not be_empty
95
+ children.should have(2).elements
96
+ children.each{|child| child?(@app.handle, child.handle).should == true }
97
+ get_class_name(children.last.handle).should == TEXTAREA_CLASS
98
+ end
99
+
100
+ # it 'finds child window(control) by name' do
101
+ # pending 'Need to find control with short name'
102
+ # @app.child(TEXTAREA_TEXT).should_not == nil
103
+ # end
104
+ #
105
+ # it 'finds child window(control) by control ID' do
106
+ # pending 'Need to find some control ID'
107
+ # @app.child(TEXTAREA_ID).should_not == nil
108
+ # end
109
+ #
110
+ # it 'raises error if wrong control is given' do
111
+ # expect { @app.child('Impossible Control')}.to raise_error "Control 'Impossible Control' not found"
112
+ # end
113
+ # it 'substitutes & for _ when searching by title ("&Yes" type controls)'
114
+
115
+ end
116
+
117
+ context '#click' do
118
+ it 'emulates clicking of the control identified by id'
119
+ end
120
+ end
124
121
  end
data/tasks/common.rake ADDED
@@ -0,0 +1,14 @@
1
+ #task :default => 'test:run'
2
+ #task 'gem:release' => 'test:run'
3
+
4
+ #Bundler not ready for prime time just yet
5
+ #desc 'Bundle dependencies'
6
+ #task :bundle do
7
+ # output = `bundle check 2>&1`
8
+ #
9
+ # unless $?.to_i == 0
10
+ # puts output
11
+ # system "bundle install"
12
+ # puts
13
+ # end
14
+ #end
data/tasks/doc.rake ADDED
@@ -0,0 +1,14 @@
1
+ desc 'Alias to doc:rdoc'
2
+ task :doc => 'doc:rdoc'
3
+
4
+ namespace :doc do
5
+ require 'rake/rdoctask'
6
+ Rake::RDocTask.new do |rdoc|
7
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "clobber", :rerdoc => "rerdoc") do |rdoc|
8
+ rdoc.rdoc_dir = DOC_PATH.basename.to_s
9
+ rdoc.title = "#{NAME} #{VERSION} Documentation"
10
+ rdoc.main = "README.doc"
11
+ rdoc.rdoc_files.include('README*')
12
+ rdoc.rdoc_files.include('lib/**/*.rb')
13
+ end
14
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,39 @@
1
+ desc "Alias to gem:release"
2
+ task :release => 'gem:release'
3
+
4
+ desc "Alias to gem:install"
5
+ task :install => 'gem:install'
6
+
7
+ desc "Alias to gem:build"
8
+ task :gem => 'gem:build'
9
+
10
+ namespace :gem do
11
+ gem_file = "#{NAME}-#{VERSION}.gem"
12
+
13
+ desc "(Re-)Build gem"
14
+ task :build do
15
+ puts "Remove existing gem package"
16
+ rm_rf PKG_PATH
17
+ puts "Build new gem package"
18
+ system "gem build #{NAME}.gemspec"
19
+ puts "Move built gem to package dir"
20
+ mkdir_p PKG_PATH
21
+ mv gem_file, PKG_PATH
22
+ end
23
+
24
+ desc "Cleanup already installed gem(s)"
25
+ task :cleanup do
26
+ puts "Cleaning up installed gem(s)"
27
+ system "gem cleanup #{NAME}"
28
+ end
29
+
30
+ desc "Build and install gem"
31
+ task :install => :build do
32
+ system "gem install #{PKG_PATH}/#{gem_file}"
33
+ end
34
+
35
+ desc "Build and push gem to Gemcutter"
36
+ task :release => [:build, 'git:tag'] do
37
+ system "gem push #{PKG_PATH}/#{gem_file}"
38
+ end
39
+ end
data/tasks/git.rake ADDED
@@ -0,0 +1,34 @@
1
+ desc "Alias to git:commit"
2
+ task :git => 'git:commit'
3
+
4
+ namespace :git do
5
+
6
+ desc "Stage and commit your work [with message]"
7
+ task :commit, [:message] do |t, args|
8
+ puts "Staging new (unversioned) files"
9
+ system "git add --all"
10
+ if args.message
11
+ puts "Committing with message: #{args.message}"
12
+ system %Q[git commit -a -m "#{args.message}" --author arvicco]
13
+ else
14
+ puts "Committing"
15
+ system %Q[git commit -a -m "No message" --author arvicco]
16
+ end
17
+ end
18
+
19
+ desc "Push local changes to Github"
20
+ task :push => :commit do
21
+ puts "Pushing local changes to remote"
22
+ system "git push"
23
+ end
24
+
25
+ desc "Create (release) tag on Github"
26
+ task :tag => :push do
27
+ tag = VERSION
28
+ puts "Creating git tag: #{tag}"
29
+ system %Q{git tag -a -m "Release tag #{tag}" #{tag}}
30
+ puts "Pushing #{tag} to remote"
31
+ system "git push origin #{tag}"
32
+ end
33
+
34
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,19 @@
1
+ desc 'Alias to spec:spec'
2
+ task :spec => 'spec:spec'
3
+
4
+ namespace :spec do
5
+ require 'spec/rake/spectask'
6
+
7
+ desc "Run all specs"
8
+ Spec::Rake::SpecTask.new(:spec) do |t|
9
+ t.spec_opts = ['--options', %Q{"#{BASE_PATH}/spec/spec.opts"}]
10
+ t.spec_files = FileList['spec/**/*_spec.rb']
11
+ end
12
+
13
+ desc "Run specs with RCov"
14
+ Spec::Rake::SpecTask.new(:rcov) do |t|
15
+ t.spec_files = FileList['spec/**/*_spec.rb']
16
+ t.rcov = true
17
+ t.rcov_opts = ['--exclude', 'spec']
18
+ end
19
+ end
@@ -0,0 +1,71 @@
1
+ class Version
2
+ attr_accessor :major, :minor, :patch, :build
3
+
4
+ def initialize(version_string)
5
+ raise "Invalid version #{version_string}" unless version_string =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
6
+ @major = $1.to_i
7
+ @minor = $2.to_i
8
+ @patch = $3.to_i
9
+ @build = $4
10
+ end
11
+
12
+ def bump_major(x)
13
+ @major += x.to_i
14
+ @minor = 0
15
+ @patch = 0
16
+ @build = nil
17
+ end
18
+
19
+ def bump_minor(x)
20
+ @minor += x.to_i
21
+ @patch = 0
22
+ @build = nil
23
+ end
24
+
25
+ def bump_patch(x)
26
+ @patch += x.to_i
27
+ @build = nil
28
+ end
29
+
30
+ def update(major, minor, patch, build=nil)
31
+ @major = major
32
+ @minor = minor
33
+ @patch = patch
34
+ @build = build
35
+ end
36
+
37
+ def write(desc = nil)
38
+ CLASS_NAME::VERSION_FILE.open('w') {|file| file.puts to_s }
39
+ (BASE_PATH + 'HISTORY').open('a') do |file|
40
+ file.puts "\n== #{to_s} / #{Time.now.strftime '%Y-%m-%d'}\n"
41
+ file.puts "\n* #{desc}\n" if desc
42
+ end
43
+ end
44
+
45
+ def to_s
46
+ [major, minor, patch, build].compact.join('.')
47
+ end
48
+ end
49
+
50
+ desc 'Set version: [x.y.z] - explicitly, [1/10/100] - bump major/minor/patch, [.build] - build'
51
+ task :version, [:command, :desc] do |t, args|
52
+ version = Version.new(VERSION)
53
+ case args.command
54
+ when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
55
+ version.update($1, $2, $3, $4)
56
+ when /^\.(.*?)$/ # Set build
57
+ version.build = $1
58
+ when /^(\d{1})$/ # Bump patch
59
+ version.bump_patch $1
60
+ when /^(\d{1})0$/ # Bump minor
61
+ version.bump_minor $1
62
+ when /^(\d{1})00$/ # Bump major
63
+ version.bump_major $1
64
+ else # Unknown command, just display VERSION
65
+ puts "#{NAME} #{version}"
66
+ next
67
+ end
68
+
69
+ puts "Writing version #{version} to VERSION file"
70
+ version.write args.desc
71
+ end