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
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/about'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/console'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/destroy'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/generate'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/benchmarker'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/profiler'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/request'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/plugin'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/inspector'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/reaper'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/spawner'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/runner'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/server'
@@ -1,46 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- ENV["RAILS_ENV"] = "test"
10
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
11
- require 'test_help'
12
-
13
- class Test::Unit::TestCase
14
- # Transactional fixtures accelerate your tests by wrapping each test method
15
- # in a transaction that's rolled back on completion. This ensures that the
16
- # test database remains unchanged so your fixtures don't have to be reloaded
17
- # between every test method. Fewer database queries means faster tests.
18
- #
19
- # Read Mike Clark's excellent walkthrough at
20
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
21
- #
22
- # Every Active Record database supports transactions except MyISAM tables
23
- # in MySQL. Turn off transactional fixtures in this case; however, if you
24
- # don't care one way or the other, switching from MyISAM to InnoDB tables
25
- # is recommended.
26
- #
27
- # The only drawback to using transactional fixtures is when you actually
28
- # need to test transactions. Since your test is bracketed by a transaction,
29
- # any transactions started in your code will be automatically rolled back.
30
- self.use_transactional_fixtures = true
31
-
32
- # Instantiated fixtures are slow, but give you @david where otherwise you
33
- # would need people(:david). If you don't want to migrate your existing
34
- # test cases which use the @david style and don't mind the speed hit (each
35
- # instantiated fixtures translates to a database query per test method),
36
- # then set this back to true.
37
- self.use_instantiated_fixtures = false
38
-
39
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
40
- #
41
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
42
- # -- they do not yet inherit this setting
43
- fixtures :all
44
-
45
- # Add more helper methods to be used by all tests here...
46
- end
@@ -1,68 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- module AppleScript
11
- class Command
12
- def initialize #(1)
13
- @lines = []
14
- @tells = 0
15
- end
16
-
17
- def method_missing(name, *args, &block)
18
- immediate = name.to_s.include? '!' #(2)
19
- param = args.shift
20
- script = name.to_s.chomp('!').gsub('_', ' ')
21
- script += %Q( #{param.inspect}) if param
22
-
23
- unless immediate #(3)
24
- script = 'tell ' + script
25
- @tells += 1
26
- end
27
-
28
- @lines << script
29
-
30
- if block_given? #(4)
31
- @has_block = true
32
- instance_eval &block
33
- go!
34
- elsif immediate && !@has_block
35
- go!
36
- else
37
- self
38
- end
39
- end
40
- end
41
- end
42
-
43
-
44
-
45
-
46
- module AppleScript
47
- class Command
48
- def go!
49
- clauses = @lines.map do |line|
50
- '-e "' + line.gsub('"', '\"') + '"'
51
- end.join(' ') + ' '
52
-
53
- clauses += '-e "end tell" ' * @tells
54
-
55
- `osascript #{clauses}`.chomp("\n")
56
- end
57
- end
58
- end
59
-
60
-
61
-
62
-
63
- module AppleScript
64
- def tell
65
- Command.new
66
- end
67
- end
68
-
@@ -1,50 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'spec_helper'
10
-
11
- describe 'The editor' do
12
- it_should_behave_like 'a new document'
13
-
14
- it 'supports multiple levels of undo' do
15
-
16
- @note.text = 'abc'
17
- @note.text = 'def'
18
-
19
- @note.undo
20
- @note.text.should == 'abc'
21
-
22
- @note.undo
23
- @note.text.should be_empty
24
-
25
- end
26
-
27
- it 'supports copying and pasting text' do
28
- @note.text = 'itchy'
29
- @note.select_all
30
- @note.copy
31
- @note.text.should == 'itchy'
32
-
33
- @note.text = 'scratchy'
34
- @note.select_all
35
- @note.paste
36
- @note.text.should == 'itchy'
37
- end
38
-
39
- it 'supports cutting and pasting text' do
40
- @note.text = 'pineapple'
41
- @note.select_all
42
- @note.cut
43
- @note.text.should be_empty
44
-
45
- @note.text = 'mango'
46
- @note.select_all
47
- @note.paste
48
- @note.text.should == 'pineapple'
49
- end
50
- end
@@ -1,17 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- describe 'a new document', :shared => true do
10
- before do
11
- @note = Note.open
12
- end
13
-
14
- after do
15
- @note.exit! if @note.running?
16
- end
17
- end
@@ -1,28 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'applescript'
10
-
11
- include AppleScript
12
-
13
- RightArrow = 124
14
-
15
- tell.application("TextEdit").activate! #(1)
16
-
17
- tell.application("System Events").
18
- process("TextEdit").
19
- menu_bar(1).
20
- menu_bar_item("Edit"). #(2)
21
- menu("Edit") do #(3)
22
- keystroke! "H"
23
- keystroke! "i"
24
- click_menu_item! "Select All"
25
- click_menu_item! "Copy"
26
- key_code! RightArrow
27
- click_menu_item! "Paste"
28
- end
@@ -1,26 +0,0 @@
1
- tell application "TextEdit"
2
- activate
3
- end tell
4
-
5
- tell application "System Events"
6
- tell process "TextEdit"
7
- keystroke "H"
8
- keystroke "i"
9
- end tell
10
- end tell
11
-
12
- tell application "System Events"
13
- tell process "TextEdit"
14
- tell menu bar 1
15
- tell menu bar item "Edit"
16
- tell menu "Edit"
17
- click menu item "Select All"
18
- click menu item "Copy"
19
- set rightArrow to 124
20
- key code rightArrow
21
- click menu item "Paste"
22
- end tell
23
- end tell
24
- end tell
25
- end tell
26
- end tell
@@ -1,32 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'rubygems'
10
- require 'appscript'
11
-
12
- include Appscript
13
-
14
- app("TextEdit").activate
15
-
16
- events = app("System Events")
17
- events.keystroke "H"
18
- events.keystroke "i"
19
-
20
- edit = app('System Events').
21
- processes['TextEdit'].
22
- menu_bars[1].
23
- menu_bar_items['Edit'].
24
- menus['Edit']
25
-
26
- edit.menu_items['Select All'].click
27
- edit.menu_items['Copy'].click
28
-
29
- RightArrow = 124
30
- events.key_code RightArrow
31
-
32
- edit.menu_items['Paste'].click
@@ -1,87 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- require 'applescript'
11
- require 'note'
12
-
13
- class TextNote < Note
14
- include AppleScript
15
-
16
- @@app = TextNote
17
-
18
- def initialize(name = 'Untitled', with_options = {})
19
- tell.application('TextEdit').activate!
20
- end
21
-
22
- DontSave = 2
23
-
24
- def exit!
25
- menu 'TextEdit', 'Quit TextEdit'
26
-
27
- tell.
28
- application('System Events').
29
- process('TextEdit').
30
- window('Untitled').
31
- sheet(1).
32
- click_button!(DontSave) #(1)
33
- end
34
-
35
- def running?
36
- tell.
37
- application('System Events').
38
- process!('TextEdit') == 'TextEdit' #(2)
39
- end
40
- end
41
-
42
-
43
-
44
-
45
- class TextNote
46
- def text
47
- tell.
48
- application('System Events').
49
- process('TextEdit').
50
- window('Untitled').
51
- scroll_area(1).
52
- text_area(1).
53
- get_value!
54
- end
55
-
56
- def text=(new_text)
57
- select_all
58
-
59
- tell.application('System Events').
60
- process('TextEdit').
61
- window('Untitled') do
62
- new_text.split(//).each {|k| keystroke! k}
63
- end
64
- end
65
- end
66
-
67
-
68
-
69
-
70
- class TextNote
71
- def menu(name, item, wait = false)
72
- tell.application('System Events').
73
- process('TextEdit').
74
- menu_bar(1).
75
- menu_bar_item(name).
76
- menu(name).
77
- click_menu_item! item
78
- end
79
-
80
- def undo; menu('Edit', 1) end #(3)
81
-
82
- def select_all; menu('Edit', 'Select All') end
83
- def cut; menu('Edit', 'Cut') end
84
- def copy; menu('Edit', 'Copy') end
85
- def paste; menu('Edit', 'Paste') end
86
- end
87
-
@@ -1,48 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- require 'swing_gui' #(1)
11
- require 'junquenote_app'
12
- require 'note'
13
-
14
- class JunqueNote < Note
15
- include SwingGui
16
-
17
-
18
- @@app = JunqueNote
19
- @@titles[:save] = "Quittin' time"
20
-
21
-
22
- def initialize
23
- JunqueNoteApp.new
24
-
25
- @main_window = JFrameOperator.new 'JunqueNote'
26
- @edit_window = JTextAreaOperator.new @main_window #(2)
27
- end
28
- end
29
-
30
-
31
-
32
-
33
- class JunqueNote
34
- def text
35
- @edit_window.text
36
- end
37
-
38
- def text=(message)
39
- @edit_window.clear_text
40
- @edit_window.type_text message
41
- end
42
-
43
- def close
44
- menu_bar = JMenuBarOperator.new @main_window
45
- menu_bar.push_menu_no_block 'File|Exit', '|'
46
- end
47
- end
48
-
@@ -1,46 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- require 'windows_gui'
11
- require 'note'
12
-
13
- class LockNote < Note
14
- include WindowsGui
15
-
16
-
17
- @@app = LockNote
18
- @@titles[:save] = 'Steganos LockNote'
19
-
20
-
21
- def initialize
22
- system 'start "" "C:/LockNote/LockNote.exe"'
23
-
24
- @main_window = Window.top_level 'LockNote - Steganos LockNote'
25
- @edit_window = @main_window.child 'ATL:00434310'
26
- end
27
- end
28
-
29
-
30
-
31
- class LockNote
32
- def text
33
- @edit_window.text
34
- end
35
-
36
- def text=(message)
37
- keystroke VK_CONTROL, ?A
38
- keystroke VK_BACK
39
- type_in(message)
40
- end
41
-
42
- def close
43
- @main_window.close
44
- end
45
- end
46
-
@@ -1,35 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- class Note
11
- @@app = nil #(1)
12
- @@titles = {} #(2)
13
-
14
- def self.open
15
- @@app.new
16
- end
17
- end
18
-
19
-
20
-
21
-
22
- class Note
23
- def exit!
24
- close
25
-
26
- @prompted = dialog(@@titles[:save]) do |d| #(3)
27
- d.click '_No'
28
- end
29
- end
30
-
31
- def has_prompted?
32
- @prompted
33
- end
34
- end
35
-
@@ -1,28 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- describe 'The main window' do
10
- it 'launches with a welcome message' do
11
- note = Note.open
12
- note.text.should include('Welcome')
13
- note.exit!
14
- end
15
-
16
- it 'exits without a prompt if nothing has changed' do
17
- note = Note.open
18
- note.exit!
19
- note.should_not have_prompted
20
- end
21
-
22
- it 'prompts before exiting if the document has changed' do
23
- note = Note.open
24
- note.text = 'changed'
25
- note.exit!
26
- note.should have_prompted
27
- end
28
- end
@@ -1,45 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'java'
10
- require 'jemmy.jar'
11
-
12
- include_class 'org.netbeans.jemmy.JemmyProperties'
13
- include_class 'org.netbeans.jemmy.TestOut'
14
-
15
- JemmyProperties.set_current_output TestOut.get_null_output
16
-
17
- %w(Frame TextArea MenuBar Dialog Button).each do |o|
18
- include_class "org.netbeans.jemmy.operators.J#{o}Operator"
19
- end
20
-
21
-
22
- class JDialogOperator
23
- def click(title)
24
- b = JButtonOperator.new self, title.gsub('_', '') #(1)
25
- b.push
26
- end
27
- end
28
-
29
-
30
-
31
- module SwingGui
32
- def dialog(title, seconds=3)
33
- JemmyProperties.set_current_timeout \
34
- 'DialogWaiter.WaitDialogTimeout', seconds * 1000
35
-
36
- begin
37
- d = JDialogOperator.new title
38
- yield d #(2)
39
- d.wait_closed
40
-
41
- true
42
- rescue NativeException
43
- end
44
- end
45
- end