win32-autogui 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.gemfiles +3 -3
  2. data/.gitignore +5 -8
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +54 -34
  5. data/HISTORY.markdown +4 -1
  6. data/README.markdown +20 -17
  7. data/Rakefile +43 -32
  8. data/TODO.markdown +10 -4
  9. data/VERSION +1 -1
  10. data/config/cucumber.yml +4 -3
  11. data/examples/quicknote/FormAboutU.dfm +0 -0
  12. data/examples/quicknote/FormAboutU.pas +0 -0
  13. data/examples/quicknote/FormMainU.dfm +0 -0
  14. data/examples/quicknote/FormMainU.pas +0 -0
  15. data/examples/quicknote/FormSplashU.dfm +0 -0
  16. data/examples/quicknote/FormSplashU.pas +0 -0
  17. data/examples/quicknote/Gemfile +18 -0
  18. data/examples/quicknote/Gemfile.lock +69 -0
  19. data/examples/quicknote/LICENSE +0 -0
  20. data/examples/quicknote/README.markdown +11 -1
  21. data/examples/quicknote/Rakefile +5 -5
  22. data/examples/quicknote/TODO.markdown +0 -0
  23. data/examples/quicknote/exe/.gitignore +0 -0
  24. data/examples/quicknote/lib/quicknote.rb +0 -0
  25. data/examples/quicknote/quicknote.cfg +0 -0
  26. data/examples/quicknote/quicknote.dof +0 -0
  27. data/examples/quicknote/quicknote.dpr +0 -0
  28. data/examples/quicknote/quicknote.res +0 -0
  29. data/examples/quicknote/spec/quicknote/form_about_spec.rb +0 -0
  30. data/examples/quicknote/spec/quicknote/form_main_spec.rb +5 -5
  31. data/examples/quicknote/spec/quicknote/form_splash_spec.rb +3 -3
  32. data/examples/quicknote/spec/spec_helper.rb +6 -4
  33. data/examples/quicknote/spec/watchr.rb +0 -0
  34. data/examples/skeleton/Gemfile +18 -0
  35. data/examples/skeleton/HISTORY.markdown +0 -0
  36. data/examples/skeleton/LICENSE +0 -0
  37. data/examples/skeleton/README.markdown +2 -2
  38. data/examples/skeleton/Rakefile +5 -5
  39. data/examples/skeleton/TODO.markdown +0 -0
  40. data/examples/skeleton/config/cucumber.yml +0 -0
  41. data/examples/skeleton/exe/.gitignore +0 -0
  42. data/examples/skeleton/features/basic.feature +0 -0
  43. data/examples/skeleton/features/step_definitions/.gitignore +0 -0
  44. data/examples/skeleton/features/step_definitions/application_steps.rb +0 -0
  45. data/examples/skeleton/features/support/env.rb +6 -2
  46. data/examples/skeleton/lib/myapp.rb +0 -0
  47. data/examples/skeleton/spec/myapp/form_about_spec.rb +0 -0
  48. data/examples/skeleton/spec/myapp/form_main_spec.rb +0 -0
  49. data/examples/skeleton/spec/spec_helper.rb +6 -4
  50. data/examples/skeleton/spec/watchr.rb +0 -0
  51. data/features/support/env.rb +6 -2
  52. data/lib/win32/autogui/application.rb +3 -2
  53. data/lib/win32/autogui/input.rb +2 -2
  54. data/lib/win32/autogui/window.rb +8 -0
  55. data/lib/win32/autogui/windows/window.rb +1 -0
  56. data/spec/applications/notepad.rb +0 -0
  57. data/spec/auto_gui/application_spec.rb +15 -1
  58. data/spec/auto_gui/input_spec.rb +0 -0
  59. data/spec/auto_gui/logging_spec.rb +1 -1
  60. data/spec/auto_gui/window_spec.rb +2 -2
  61. data/spec/basic_gem/aruba_helper_spec.rb +2 -2
  62. data/spec/basic_gem/basic_gem_spec.rb +5 -1
  63. data/spec/basic_gem/gemspec_spec.rb +6 -6
  64. data/spec/spec_helper.rb +6 -4
  65. data/spec/watchr.rb +2 -0
  66. data/win32-autogui.gemspec +25 -35
  67. metadata +131 -198
  68. data/examples/quicknote/spec/spec.opts +0 -2
  69. data/examples/skeleton/spec/spec.opts +0 -2
  70. data/spec/spec.opts +0 -2
@@ -0,0 +1,69 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ aruba (0.4.6)
5
+ bcat (>= 0.6.1)
6
+ childprocess (>= 0.2.0)
7
+ cucumber (>= 1.0.2)
8
+ rdiscount (>= 1.6.8)
9
+ rspec (>= 2.6.0)
10
+ bcat (0.6.1)
11
+ rack (~> 1.0)
12
+ builder (3.0.0)
13
+ childprocess (0.2.1)
14
+ ffi (~> 1.0.6)
15
+ cucumber (1.0.2)
16
+ builder (>= 2.1.2)
17
+ diff-lcs (>= 1.1.2)
18
+ gherkin (~> 2.4.5)
19
+ json (>= 1.4.6)
20
+ term-ansicolor (>= 1.0.5)
21
+ diff-lcs (1.1.2)
22
+ ffi (1.0.9-x86-mingw32)
23
+ gherkin (2.4.6-x86-mingw32)
24
+ json (>= 1.4.6)
25
+ json (1.5.3)
26
+ log4r (1.1.9)
27
+ mutagem (0.2.0)
28
+ rack (1.3.2)
29
+ rake (0.9.2)
30
+ rdiscount (1.6.8)
31
+ rspec (2.6.0)
32
+ rspec-core (~> 2.6.0)
33
+ rspec-expectations (~> 2.6.0)
34
+ rspec-mocks (~> 2.6.0)
35
+ rspec-core (2.6.4)
36
+ rspec-expectations (2.6.0)
37
+ diff-lcs (~> 1.1.2)
38
+ rspec-mocks (2.6.0)
39
+ term-ansicolor (1.0.6)
40
+ win32-api (1.4.8-x86-mingw32)
41
+ win32-autogui (0.5.0)
42
+ log4r (>= 1.1.9)
43
+ win32-clipboard (~> 0.5.2)
44
+ win32-process (~> 0.6.5)
45
+ windows-api (~> 0.4.0)
46
+ windows-pr (~> 1.2.0)
47
+ win32-clipboard (0.5.2)
48
+ windows-pr (>= 1.0.3)
49
+ win32-process (0.6.5)
50
+ windows-pr (>= 1.1.2)
51
+ win32console (1.3.0-x86-mingw32)
52
+ windows-api (0.4.0)
53
+ win32-api (>= 1.4.5)
54
+ windows-pr (1.2.0)
55
+ win32-api (>= 1.4.5)
56
+ windows-api (>= 0.3.0)
57
+
58
+ PLATFORMS
59
+ x86-mingw32
60
+
61
+ DEPENDENCIES
62
+ aruba (~> 0.4.2)
63
+ bundler (>= 1.0.14)
64
+ cucumber (~> 1.0)
65
+ mutagem (>= 0.2.0)
66
+ rake (>= 0.9.2)
67
+ rspec (>= 2.6.0)
68
+ win32-autogui (>= 0.5.0)
69
+ win32console (>= 1.2.0)
File without changes
@@ -4,6 +4,16 @@ QuickNote README
4
4
  QuickNote is a stripped down Notepad clone written in Delphi. It is an example GUI executable with
5
5
  source code for the Win32-autogui gem. It is not fit for any other purpose.
6
6
 
7
+ QuickNote specs
8
+ ---------------
9
+ install development dependencies
10
+
11
+ gem install bundler
12
+ bundle install
13
+
14
+ run specs
15
+
16
+ bundle exec rake
7
17
 
8
18
  Modifications to the load paths for use in a real world project
9
19
  ----------------------------------------------------------------
@@ -26,4 +36,4 @@ lib/quicknote.rb
26
36
  Copyright
27
37
  ---------
28
38
 
29
- Copyright (c) 2010 GearheadForHire, LLC. See [LICENSE](LICENSE) for details.
39
+ Copyright (c) 2010-2011 GearheadForHire, LLC. See [LICENSE](LICENSE) for details.
@@ -2,11 +2,11 @@
2
2
 
3
3
  require 'rubygems'
4
4
 
5
- require 'spec'
6
- require 'spec/rake/spectask'
7
- Spec::Rake::SpecTask.new(:spec) do |spec|
8
- spec.libs << 'lib' << 'spec'
9
- spec.spec_files = FileList['spec/**/*_spec.rb']
5
+ require 'rspec/core/rake_task'
6
+ desc "Run RSpec"
7
+ RSpec::Core::RakeTask.new do |spec|
8
+ spec.pattern = 'spec/**/*_spec.rb'
9
+ spec.rspec_opts = ['--color', '--format nested']
10
10
  end
11
11
 
12
12
  task :default => :spec
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -63,7 +63,7 @@
63
63
  describe "file open (VK_MENU, VK_F, VK_O)" do
64
64
  before(:each) do
65
65
  @filename = "input_file.txt"
66
- @file_contents = create_file(@filename, "the quick brown fox")
66
+ @file_contents = write_file(@filename, "the quick brown fox")
67
67
  @application.file_new(:save => false)
68
68
  end
69
69
  after(:each) do
@@ -126,7 +126,7 @@
126
126
  end
127
127
  it "should add the filename 'untitled.txt' to the title" do
128
128
  filename = "input_file.txt"
129
- file_contents = create_file(filename, "the quick brown fox")
129
+ file_contents = write_file(filename, "the quick brown fox")
130
130
  @application.file_open(filename, :save => false)
131
131
  @application.main_window.title.downcase.should == "QuickNote - #{fullpath(filename)}".downcase
132
132
  @application.file_new(:save => false)
@@ -149,7 +149,7 @@
149
149
  describe "file save (VK_MENU, VK_F, VK_S)" do
150
150
  before(:each) do
151
151
  @filename = "input_file.txt"
152
- @file_contents = create_file(@filename, "original content")
152
+ @file_contents = write_file(@filename, "original content")
153
153
  @application.file_open(fullpath(@filename), :save => false)
154
154
  @application.main_window.title.downcase.should == "QuickNote - #{fullpath(@filename)}".downcase
155
155
  @application.edit_window.text.should == "original content"
@@ -216,9 +216,9 @@
216
216
  describe "file save as (VK_MENU, VK_F, VK_A)" do
217
217
  before(:each) do
218
218
  @filename = "original.txt"
219
- @file_contents = create_file(@filename, "original content")
219
+ @file_contents = write_file(@filename, "original content")
220
220
  @saveas_filename = "newfile.txt"
221
- create_file(@saveas_filename, "")
221
+ write_file(@saveas_filename, "")
222
222
  @application.file_open(fullpath(@filename), :save => false)
223
223
  end
224
224
  after(:each) do
@@ -4,8 +4,8 @@
4
4
  include Autogui::Input
5
5
 
6
6
  describe "FormSplash" do
7
- after(:all) do
8
- if @application.running?
7
+ after(:each) do
8
+ if @application && @application.running?
9
9
  @application.splash.wait_for_close if @application.splash
10
10
  @application.file_exit
11
11
  # still running? force it to close
@@ -15,7 +15,7 @@
15
15
  end
16
16
 
17
17
  describe "startup with no command line parameters" do
18
- before(:all) do
18
+ before(:each) do
19
19
  # --nosplash is the default, turn it back on
20
20
  @application = Quicknote.new :parameters => ''
21
21
  @application.should be_running
@@ -11,11 +11,13 @@
11
11
  require 'rubygems'
12
12
  require 'win32/autogui'
13
13
  require 'quicknote'
14
- require 'spec'
15
- require 'spec/autorun'
14
+ require 'rspec/core'
16
15
  require 'aruba/api'
17
16
  require 'aruba_helper'
18
17
 
19
- Spec::Runner.configure do |config|
20
- config.include Aruba::Api
18
+ RSpec.configure do |config|
19
+ config.include Aruba::Api
20
+ config.filter_run :focus => true
21
+ config.run_all_when_everything_filtered = true
22
+ config.treat_symbols_as_metadata_keys_with_true_values = true
21
23
  end
File without changes
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "bundler", ">= 1.0.14"
4
+ gem "rake", ">= 0.9.2"
5
+
6
+ # development path manually added, this is here just for dependencies
7
+ gem "win32-autogui", ">= 0.5.0"
8
+
9
+ # scripting
10
+ gem "mutagem", ">= 0.2.0"
11
+
12
+ # this gem is only used if ANSICON support is not detected
13
+ gem "win32console", ">= 1.2.0"
14
+
15
+ # Specs and Features
16
+ gem "rspec", ">= 2.6.0"
17
+ gem "cucumber", "~> 1.0"
18
+ gem "aruba", "~> 0.4.2"
File without changes
File without changes
@@ -47,8 +47,8 @@ customize docs
47
47
 
48
48
  test it
49
49
 
50
- rake spec
51
- rake features
50
+ bundle exec rake spec
51
+ bundle exec rake features
52
52
 
53
53
  commit it
54
54
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  require 'rubygems'
4
4
 
5
- require 'spec'
6
- require 'spec/rake/spectask'
7
- Spec::Rake::SpecTask.new(:spec) do |spec|
8
- spec.libs << 'lib' << 'spec'
9
- spec.spec_files = FileList['spec/**/*_spec.rb']
5
+ require 'rspec/core/rake_task'
6
+ desc "Run RSpec"
7
+ RSpec::Core::RakeTask.new do |spec|
8
+ spec.pattern = 'spec/**/*_spec.rb'
9
+ spec.rspec_opts = ['--color', '--format nested']
10
10
  end
11
11
 
12
12
  require 'cucumber'
File without changes
File without changes
File without changes
File without changes
@@ -1,8 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
 
3
3
  require 'win32/autogui'
4
- require 'spec/expectations'
5
- require 'aruba'
4
+ require 'aruba/cucumber'
5
+ require 'rspec/expectations'
6
6
  require File.expand_path(File.dirname(__FILE__) + '/../../spec/aruba_helper')
7
7
 
8
8
  puts "Cucumber starting"
@@ -13,3 +13,7 @@
13
13
  at_exit do
14
14
  puts "Cucumber exiting"
15
15
  end
16
+
17
+ Before do
18
+ @aruba_timeout_seconds = 10
19
+ end
File without changes
@@ -6,11 +6,13 @@
6
6
  require 'rubygems'
7
7
  require 'win32/autogui'
8
8
  require 'myapp'
9
- require 'spec'
10
- require 'spec/autorun'
9
+ require 'rspec/core'
11
10
  require 'aruba/api'
12
11
  require 'aruba_helper'
13
12
 
14
- Spec::Runner.configure do |config|
15
- config.include Aruba::Api
13
+ RSpec.configure do |config|
14
+ config.include Aruba::Api
15
+ config.filter_run :focus => true
16
+ config.run_all_when_everything_filtered = true
17
+ config.treat_symbols_as_metadata_keys_with_true_values = true
16
18
  end
File without changes
@@ -1,6 +1,10 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'rubygems'
3
3
  require 'win32/autogui'
4
- require 'spec/expectations'
5
- require 'aruba'
4
+ require 'aruba/cucumber'
5
+ require 'rspec/expectations'
6
6
  require File.expand_path(File.dirname(__FILE__) + '/../../spec/aruba_helper')
7
+
8
+ Before do
9
+ @aruba_timeout_seconds = 10
10
+ end
@@ -24,7 +24,8 @@ def text
24
24
  # @param [String] str text to load onto the clipboard
25
25
  #
26
26
  def text=(str)
27
- Win32::Clipboard.set_data(str)
27
+ data = str.nil? ? "" : str.dup
28
+ Win32::Clipboard.set_data(data)
28
29
  end
29
30
 
30
31
  end
@@ -275,7 +276,7 @@ def combined_text
275
276
  # @return [Clipboard]
276
277
  #
277
278
  def clipboard
278
- @clipboard || Autogui::Clipboard.new
279
+ @clipboard ||= Autogui::Clipboard.new
279
280
  end
280
281
 
281
282
  private
@@ -198,11 +198,11 @@ def char_to_virtual_keycode(char)
198
198
 
199
199
  case char
200
200
  when '0'..'9'
201
- [code - ?0 + 0x30]
201
+ [code - ?0.ord + 0x30]
202
202
  when 'A'..'Z'
203
203
  [VK_SHIFT, code]
204
204
  when 'a'..'z'
205
- [code - ?a + ?A]
205
+ [code - ?a.ord + ?A.ord]
206
206
  when ' '
207
207
  [code]
208
208
  when '+'
@@ -162,6 +162,14 @@ def is_window?
162
162
  (handle != 0) && (IsWindow(handle) != 0)
163
163
  end
164
164
 
165
+ # Determines the visibility state of the window
166
+ #
167
+ # @return [Boolean]
168
+ #
169
+ def visible?
170
+ is_window? && (IsWindowVisible(handle) != 0)
171
+ end
172
+
165
173
  # Brings the window into the foreground and activates it.
166
174
  # Keyboard input is directed to the window, and various visual cues
167
175
  # are changed for the user.
@@ -16,6 +16,7 @@ module Window
16
16
  API.new('IsWindow', 'L', 'I', 'user32')
17
17
  API.new('SetForegroundWindow', 'L', 'I', 'user32')
18
18
  API.new('SendMessageA', 'LIIP', 'I', 'user32')
19
+ API.new('IsWindowVisible', 'L', 'I', 'user32')
19
20
 
20
21
  end
21
22
  end
File without changes
@@ -76,7 +76,6 @@
76
76
  keystroke(VK_MENU, VK_H, VK_A)
77
77
  dialog_about = @calculator.dialog_about
78
78
  dialog_about.title.should == "About Calculator"
79
- dialog_about.combined_text.should match(/Microsoft . Calculator/)
80
79
  dialog_about.close
81
80
  @calculator.dialog_about.should be_nil
82
81
  end
@@ -106,6 +105,21 @@
106
105
  @calculator.clipboard.text.should == ""
107
106
  end
108
107
 
108
+ it "should not change the original text data" do
109
+ original_text = "the cow jumped over the moon"
110
+ copy_of_text = original_text.dup
111
+ copy_of_text.should == original_text
112
+ @calculator.clipboard.text = original_text
113
+ copy_of_text.should == original_text
114
+ @calculator.clipboard.text.should == original_text
115
+ original_text.should == "the cow jumped over the moon"
116
+ end
117
+
118
+ it "should memoize the clipboard object" do
119
+ clipboard = @calculator.clipboard
120
+ clipboard.should == @calculator.clipboard
121
+ end
122
+
109
123
  describe "copy (VK_CONTROL, VK_C)" do
110
124
  it "should copy the edit window" do
111
125
  @calculator.set_focus
File without changes
@@ -9,7 +9,7 @@
9
9
  end
10
10
  before(:each) do
11
11
  @logfile = "autogui.log"
12
- create_file(@logfile, "the quick brown fox")
12
+ write_file(@logfile, "the quick brown fox")
13
13
  end
14
14
  after(:each) do
15
15
  if @application
@@ -73,7 +73,7 @@ def close_calculator
73
73
  dialog_about = Autogui::EnumerateDesktopWindows.new(:timeout => seconds).find do |w|
74
74
  w.title.match(/About Calculator/) && (w.pid == @calculator.pid)
75
75
  end
76
- end}.should_not raise_error
76
+ end}.should_not raise_exception
77
77
  dialog_about.should_not be_nil
78
78
  dialog_about.close
79
79
  end
@@ -84,7 +84,7 @@ def close_calculator
84
84
  dialog_bogus = Autogui::EnumerateDesktopWindows.new(:timeout => seconds).find do |w|
85
85
  w.title.match(/Bogus Window that does not exist/) && (w.pid == @calculator.pid)
86
86
  end
87
- end}.should raise_error
87
+ end}.should raise_exception(Timeout::Error)
88
88
  dialog_bogus.should be_nil
89
89
  end
90
90
  end