win32-autogui 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gemfiles CHANGED
@@ -68,8 +68,10 @@ lib/win32/autogui/logging.rb
68
68
  lib/win32/autogui/window.rb
69
69
  lib/win32/autogui/windows/window.rb
70
70
  spec/applications/calculator.rb
71
+ spec/applications/notepad.rb
71
72
  spec/aruba_helper.rb
72
73
  spec/auto_gui/application_spec.rb
74
+ spec/auto_gui/input_spec.rb
73
75
  spec/auto_gui/logging_spec.rb
74
76
  spec/auto_gui/window_spec.rb
75
77
  spec/basic_gem/aruba_helper_spec.rb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- win32-autogui (0.4.2)
4
+ win32-autogui (0.4.3)
5
5
  log4r (>= 1.1.9)
6
6
  win32-clipboard (= 0.5.2)
7
7
  win32-process (= 0.6.4)
@@ -6,6 +6,11 @@ Most recent changes are at the top
6
6
  Changes
7
7
  -------
8
8
 
9
+ ### 0.4.3 - 03/17/2011 ###
10
+
11
+ * Add test coverage for Autogui::Input using Notepad.exe
12
+ * Fix Autogui::Input broken quote handling (jondot)
13
+
9
14
  ### 0.4.2 - 02/07/2011 ###
10
15
 
11
16
  * Add logger.trunc attribute to control log truncation, defaults to true
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -242,11 +242,10 @@ def char_to_virtual_keycode(char)
242
242
  [VK_OEM_6]
243
243
  when '}'
244
244
  [VK_SHIFT, VK_OEM_6]
245
- when '\''
245
+ when "'"
246
246
  [VK_OEM_7]
247
- when '\"'
247
+ when '"'
248
248
  [VK_SHIFT, VK_OEM_7]
249
-
250
249
  when '!'
251
250
  [VK_SHIFT, VK_1]
252
251
  when '@'
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ class Notepad < Autogui::Application
4
+
5
+ # initialize with the binary name 'notepad' and the window title
6
+ # '<filename> - Notepad' used along with the application pid to find the
7
+ # main application window
8
+ def initialize(options = {})
9
+ defaults = {
10
+ :name => "notepad",
11
+ :title => " - Notepad",
12
+ :logger_level => Autogui::Logging::DEBUG
13
+ }
14
+ super defaults.merge(options)
15
+ end
16
+
17
+ # the notepad's results window
18
+ def edit_window
19
+ main_window.children.find {|w| w.window_class == 'Edit'}
20
+ end
21
+
22
+ # About dialog, hotkey (VK_MENU, VK_H, VK_A)
23
+ def dialog_about(options = {})
24
+ Autogui::EnumerateDesktopWindows.new(options).find do |w|
25
+ w.title.match(/About Notepad/) && (w.pid == pid)
26
+ end
27
+ end
28
+
29
+ def message_dialog_confirm(options={})
30
+ Autogui::EnumerateDesktopWindows.new(options).find do |w|
31
+ w.title.match(/Notepad/) && (w.pid == pid) && (w.window_class == "#32770")
32
+ end
33
+ end
34
+
35
+ # menu action File, Exit
36
+ def file_exit
37
+ set_focus
38
+ keystroke(VK_MENU, VK_F, VK_X)
39
+ if message_dialog_confirm
40
+ keystroke(VK_N) if message_dialog_confirm
41
+ end
42
+ end
43
+
44
+ # menu action File, Save
45
+ def file_save
46
+ set_focus
47
+ keystroke(VK_MENU, VK_F, VK_S)
48
+ end
49
+
50
+
51
+ end
@@ -0,0 +1,68 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ include Autogui::Input
4
+
5
+ describe Autogui::Input do
6
+ before(:each) do
7
+ @application = Notepad.new
8
+ @application.main_window.title.should == "Untitled - Notepad"
9
+ end
10
+ after(:each) do
11
+ if @application.running?
12
+ @application.file_exit
13
+ # still running? force it to close
14
+ @application.close(:wait_for_close => true)
15
+ @application.should_not be_running
16
+ end
17
+ end
18
+
19
+ describe "keystroke" do
20
+
21
+ it "should input virtual keycodes" do
22
+ @application.edit_window.text.should == ""
23
+ keystroke(VK_A)
24
+ @application.edit_window.text.should == 'a'
25
+ keystroke(VK_SHIFT, VK_A)
26
+ @application.edit_window.text.should == 'aA'
27
+ keystroke(VK_BACK)
28
+ keystroke(VK_BACK)
29
+ @application.edit_window.text.should == ''
30
+ end
31
+ end
32
+
33
+ describe "type_in" do
34
+
35
+ it "should input a string one character at a time" do
36
+ @application.edit_window.text.should == ""
37
+ input_string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
38
+ type_in(input_string)
39
+ @application.edit_window.text.should == input_string
40
+ input_string.should_not be_nil
41
+ input_string.should_not == ""
42
+ end
43
+
44
+ it "should handle non-alphanumerics" do
45
+ @application.edit_window.text.should == ""
46
+ input_string = %( +=,.-_;:/?~[]{}$%^&*`)
47
+ type_in(input_string)
48
+ @application.edit_window.text.should == input_string
49
+ input_string.should_not be_nil
50
+ input_string.should_not == ""
51
+ end
52
+
53
+ it "should handle special charaters" do
54
+ @application.edit_window.text.should == ""
55
+ type_in("#\\")
56
+ @application.edit_window.text.should == "#\\"
57
+ type_in("\n()")
58
+ @application.edit_window.text.should == "#\\\r\n()"
59
+ end
60
+
61
+ it "should handle quotes" do
62
+ @application.edit_window.text.should == ""
63
+ type_in(%('"))
64
+ @application.edit_window.text.should == %('")
65
+ end
66
+ end
67
+
68
+ end
@@ -12,6 +12,7 @@
12
12
 
13
13
  # applications
14
14
  require File.expand_path(File.dirname(__FILE__) + '/applications/calculator')
15
+ require File.expand_path(File.dirname(__FILE__) + '/applications/notepad')
15
16
 
16
17
  Spec::Runner.configure do |config|
17
18
  config.include Aruba::Api
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-autogui
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robert Wahler
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-07 00:00:00 -05:00
18
+ date: 2011-03-17 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -290,8 +290,10 @@ files:
290
290
  - lib/win32/autogui/window.rb
291
291
  - lib/win32/autogui/windows/window.rb
292
292
  - spec/applications/calculator.rb
293
+ - spec/applications/notepad.rb
293
294
  - spec/aruba_helper.rb
294
295
  - spec/auto_gui/application_spec.rb
296
+ - spec/auto_gui/input_spec.rb
295
297
  - spec/auto_gui/logging_spec.rb
296
298
  - spec/auto_gui/window_spec.rb
297
299
  - spec/basic_gem/aruba_helper_spec.rb