rautomation 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.gitignore +9 -8
  2. data/Gemfile.lock +2 -2
  3. data/History.rdoc +13 -0
  4. data/README.rdoc +3 -2
  5. data/Rakefile +30 -10
  6. data/VERSION +1 -1
  7. data/ext/UiaDll/Release/UiaDll.dll +0 -0
  8. data/ext/UiaDll/UiaDll/AssemblyInfo.cpp +40 -0
  9. data/ext/UiaDll/UiaDll/AutomatedComboBox.cpp +66 -0
  10. data/ext/UiaDll/UiaDll/AutomatedComboBox.h +32 -0
  11. data/ext/UiaDll/UiaDll/AutomatedTable.cpp +50 -0
  12. data/ext/UiaDll/UiaDll/AutomatedTable.h +22 -0
  13. data/ext/UiaDll/UiaDll/AutomationClicker.cpp +50 -0
  14. data/ext/UiaDll/UiaDll/AutomationClicker.h +24 -0
  15. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.cpp +53 -0
  16. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.h +22 -0
  17. data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +75 -0
  18. data/ext/UiaDll/UiaDll/MenuItemSelector.h +22 -0
  19. data/ext/UiaDll/UiaDll/ReadMe.txt +8 -18
  20. data/ext/UiaDll/UiaDll/StringHelper.cpp +9 -0
  21. data/ext/UiaDll/UiaDll/StringHelper.h +7 -0
  22. data/ext/UiaDll/UiaDll/ToggleStateHelper.cpp +33 -0
  23. data/ext/UiaDll/UiaDll/ToggleStateHelper.h +10 -0
  24. data/ext/UiaDll/UiaDll/UiaDll.cpp +458 -325
  25. data/ext/UiaDll/UiaDll/UiaDll.h +13 -0
  26. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +45 -28
  27. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +66 -7
  28. data/ext/UiaDll/UiaDll/app.ico +0 -0
  29. data/ext/UiaDll/UiaDll/app.rc +0 -0
  30. data/ext/UiaDll/UiaDll/dllmain.cpp +5 -23
  31. data/ext/UiaDll/UiaDll/resource.h +3 -0
  32. data/ext/UiaDll/UiaDll/stdafx.cpp +0 -3
  33. data/ext/UiaDll/UiaDll/stdafx.h +23 -18
  34. data/ext/UiaDll/UiaDll.sln +6 -6
  35. data/ext/WindowsForms/Release/WindowsForms.exe +0 -0
  36. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.Designer.cs +0 -0
  37. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.cs +0 -0
  38. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.resx +0 -0
  39. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.Designer.cs +0 -0
  40. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.cs +0 -0
  41. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.resx +0 -0
  42. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.Designer.cs +173 -76
  43. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.cs +76 -77
  44. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.resx +3 -0
  45. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.Designer.cs +0 -0
  46. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.cs +0 -0
  47. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.resx +0 -0
  48. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Program.cs +0 -0
  49. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/AssemblyInfo.cs +0 -0
  50. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Resources.Designer.cs +0 -0
  51. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Resources.resx +0 -0
  52. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Settings.Designer.cs +0 -0
  53. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Settings.settings +0 -0
  54. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.Designer.cs +0 -0
  55. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.cs +0 -0
  56. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.resx +0 -0
  57. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/WindowsForms.csproj +2 -2
  58. data/ext/WindowsForms/{src/WindowsForms/WindowsForms.sln → WindowsForms.sln} +0 -0
  59. data/lib/rautomation/adapter/ms_uia/constants.rb +1 -0
  60. data/lib/rautomation/adapter/ms_uia/control.rb +11 -0
  61. data/lib/rautomation/adapter/ms_uia/functions.rb +8 -5
  62. data/lib/rautomation/adapter/ms_uia/menu.rb +36 -0
  63. data/lib/rautomation/adapter/ms_uia/select_list.rb +4 -12
  64. data/lib/rautomation/adapter/ms_uia/table.rb +90 -11
  65. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +48 -2
  66. data/lib/rautomation/adapter/ms_uia/window.rb +6 -1
  67. data/lib/rautomation/adapter/ms_uia.rb +1 -0
  68. data/spec/adapter/autoit/mouse_spec.rb +2 -2
  69. data/spec/adapter/ms_uia/functions_spec.rb +39 -0
  70. data/spec/adapter/ms_uia/select_list_spec.rb +26 -13
  71. data/spec/adapter/ms_uia/table_spec.rb +96 -2
  72. data/spec/adapter/ms_uia/window_spec.rb +37 -11
  73. data/spec/adapter/win_32/mouse_spec.rb +2 -2
  74. data/spec/adapter/win_32/window_spec.rb +0 -9
  75. data/spec/spec_helper.rb +3 -3
  76. data/spec/window_spec.rb +17 -6
  77. metadata +48 -40
  78. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.cpp +0 -174
  79. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj +0 -95
  80. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.filters +0 -42
  81. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.user +0 -3
  82. data/ext/ListViewExplorer/ListViewExplorer/ReadMe.txt +0 -40
  83. data/ext/ListViewExplorer/ListViewExplorer/stdafx.cpp +0 -8
  84. data/ext/ListViewExplorer/ListViewExplorer/stdafx.h +0 -17
  85. data/ext/ListViewExplorer/ListViewExplorer/table_support.cpp +0 -250
  86. data/ext/ListViewExplorer/ListViewExplorer/table_support.h +0 -2
  87. data/ext/ListViewExplorer/ListViewExplorer/targetver.h +0 -8
  88. data/ext/ListViewExplorer/ListViewExplorer.sln +0 -20
  89. data/ext/ListViewExplorer/ListViewExplorer.suo +0 -0
  90. data/ext/UiaDll/UiaDll.suo +0 -0
  91. data/ext/WindowsForms/bin/WindowsForms.exe +0 -0
  92. data/ext/WindowsForms/src/WindowsForms/WindowsForms.suo +0 -0
@@ -0,0 +1,36 @@
1
+ module RAutomation
2
+ module Adapter
3
+ module MsUia
4
+ class Menu
5
+ attr_reader :menu_items
6
+ attr_reader :window
7
+
8
+ def initialize(window, locator)
9
+ @menu_items = [] << locator[:text]
10
+ @window = window
11
+ end
12
+
13
+ def menu(locator)
14
+ @menu_items << locator[:text]
15
+ self
16
+ end
17
+
18
+ def exists?
19
+ UiaDll::menu_item_exists window.hwnd, *menu_items_arg
20
+ end
21
+
22
+ def open
23
+ error_info = FFI::MemoryPointer.new :char, 1024
24
+ UiaDll::select_menu_item window.hwnd, error_info, 1024, *menu_items_arg
25
+ error = error_info.get_string 0
26
+ raise error unless error.empty?
27
+ end
28
+
29
+ private
30
+ def menu_items_arg
31
+ menu_items.map {|s| [:string, s]}.flatten << :pointer << nil
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -15,23 +15,18 @@ module RAutomation
15
15
  @index = index
16
16
  end
17
17
 
18
- #todo - replace with UIA version
19
18
  def selected?
20
- selected_idx = Functions.send_message(@select_list.control_hwnd, Constants::CB_GETCURSEL, 0, nil)
21
- return false if selected_idx == Constants::CB_ERR
22
- @text == Functions.retrieve_combobox_item_text(@select_list.control_hwnd, selected_idx)
19
+ @index == UiaDll::get_combobox_selected_index(@select_list.control_hwnd)
23
20
  end
24
21
 
25
- #todo - replace with UIA version
26
22
  def select
27
23
  @select_list.assert_enabled
28
- Functions.send_message(@select_list.control_hwnd, Constants::CB_SETCURSEL, @index, nil) != Constants::CB_ERR
24
+ UiaDll::select_combo_by_index @select_list.control_hwnd, @index
29
25
  end
30
26
 
31
27
  alias_method :set, :select
32
28
  end
33
29
 
34
- #todo - replace with UIA version
35
30
  def initialize(window, locators)
36
31
  super
37
32
  @hwnd = Functions.control_hwnd(@window.hwnd, @locators)
@@ -42,7 +37,6 @@ module RAutomation
42
37
  UiaDll::set_value(list, value)
43
38
  end
44
39
 
45
- #todo - replace with UIA version
46
40
  def options(options = {})
47
41
  items = []
48
42
 
@@ -64,7 +58,6 @@ module RAutomation
64
58
  selected_option ? selected_option.text : ""
65
59
  end
66
60
 
67
- #todo - replace with UIA version
68
61
  def option(options)
69
62
  item_count.times do |item_no|
70
63
  item = Functions.retrieve_combobox_item_text(@hwnd, item_no)
@@ -79,7 +72,7 @@ module RAutomation
79
72
  end
80
73
 
81
74
  def select(index)
82
- Functions.send_message(@hwnd, Constants::CB_SETCURSEL, index, nil) != Constants::CB_ERR
75
+ UiaDll::select_combo_by_index @hwnd, index
83
76
  end
84
77
 
85
78
  def list_item_height
@@ -110,9 +103,8 @@ module RAutomation
110
103
 
111
104
  private
112
105
 
113
- #todo - replace with UIA version
114
106
  def item_count
115
- Functions.send_message(@hwnd, Constants::CB_GETCOUNT, 0, nil)
107
+ UiaDll::get_combobox_count(@hwnd)
116
108
  end
117
109
 
118
110
  end
@@ -1,15 +1,96 @@
1
1
  module RAutomation
2
2
  module Adapter
3
3
  module MsUia
4
+ class Cell
5
+ include Locators
6
+ attr_reader :row, :column, :hwnd
7
+
8
+ def initialize(window, locators)
9
+ @hwnd = window.hwnd
10
+ @locators = extract(locators)
11
+ @row = window.row
12
+ @column = @locators[:index] || 0
13
+ end
14
+
15
+ def exists?
16
+ UiaDll::data_item_exists hwnd, row, column
17
+ end
18
+
19
+ def value
20
+ UiaDll::cell_value_at hwnd, row, column
21
+ end
22
+
23
+ alias_method :text, :value
24
+ alias_method :index, :column
25
+ end
26
+
27
+ class Row
28
+ include Locators
29
+ extend ElementCollections
30
+ attr_reader :hwnd
31
+
32
+ has_many :cells
33
+
34
+ def cells(locators={})
35
+ Cells.new(self, locators).select do |cell|
36
+ Row.locators_match? locators, cell
37
+ end
38
+ end
39
+
40
+ def cell(locators={})
41
+ cells(locators).first
42
+ end
43
+
44
+ def initialize(window, locators)
45
+ @hwnd = window.hwnd
46
+ @locators = extract(locators)
47
+ end
48
+
49
+ def index
50
+ @locators[:index] || 0
51
+ end
52
+
53
+ def value
54
+ UiaDll::cell_value_at @hwnd, @locators[:index]
55
+ end
56
+
57
+ def exists?
58
+ UiaDll::data_item_exists(@hwnd, @locators[:index])
59
+ end
60
+
61
+ def self.locators_match?(locators, item)
62
+ locators.all? do |locator, value|
63
+ return item.value =~ value if value.is_a? Regexp
64
+ return item.send(locator) == value
65
+ end
66
+ end
67
+
68
+ alias_method :text, :value
69
+ alias_method :row, :index
70
+ end
71
+
4
72
  class Table < Control
5
73
  include WaitHelper
6
74
  include Locators
75
+ extend ElementCollections
76
+
77
+ has_many :rows
78
+
79
+ def row(locators={})
80
+ rows(locators).first
81
+ end
82
+
83
+ def rows(locators={})
84
+ Rows.new(self, locators).select do |row|
85
+ Row.locators_match? locators, row
86
+ end
87
+ end
7
88
 
8
89
  def strings
9
90
  rows = []
10
91
  header_columns = []
11
92
 
12
- raise "Not a list control" unless UiaDll::current_control_type(uia_element) == Constants::UIA_LIST_CONTROL_TYPE
93
+ raise "Not a list control" unless of_type_table?
13
94
 
14
95
 
15
96
  children_count = count_children(uia_element)
@@ -49,27 +130,25 @@ module RAutomation
49
130
  # end
50
131
 
51
132
  def select(index)
52
- children = FFI::MemoryPointer.new :pointer, row_count
53
-
54
- length = UiaDll::find_children(uia_element, children)
55
-
56
- target_element = children.read_array_of_pointer(length)[index]
57
-
58
- UiaDll::select(target_element)
133
+ UiaDll::select_data_item hwnd, index - 1
59
134
  end
60
135
 
61
136
  #todo - replace with UIA version
62
137
  def selected?(row)
63
- state = Functions.get_table_row_state(Window.oleacc_module_handle, Functions.control_hwnd(@window.hwnd, @locators), row)
138
+ state = Functions.get_table_row_state(Window.oleacc_module_handle, hwnd, row)
64
139
  state & Constants::STATE_SYSTEM_SELECTED != 0
65
140
  end
66
141
 
67
142
  def row_count
68
- UiaDll::find_children(uia_element, nil)
143
+ UiaDll::get_data_item_count hwnd
69
144
  end
70
145
 
71
146
  def exist?
72
- super && matches_type?(Constants::UIA_LIST_CONTROL_TYPE)
147
+ super && of_type_table?
148
+ end
149
+
150
+ def of_type_table?
151
+ matches_type?(Constants::UIA_LIST_CONTROL_TYPE) || matches_type?(Constants::UIA_DATA_GRID_CONTROL_TYPE)
73
152
  end
74
153
 
75
154
  alias_method :exists?, :exist?
@@ -52,12 +52,58 @@ module RAutomation
52
52
  [:pointer], :bool
53
53
  attach_function :select, :RA_Select,
54
54
  [:pointer], :int
55
- attach_function :set_value, :RA_Set_Value,
56
- [:pointer, :pointer], :int
57
55
  attach_function :find_window_by_pid, :RA_FindWindowByPID,
58
56
  [:int], :pointer
59
57
  attach_function :current_process_id, :RA_GetCurrentProcessId,
60
58
  [:pointer], :int
59
+ attach_function :select_combo_by_index, :RA_SelectComboByIndex,
60
+ [:long, :int], :bool
61
+ attach_function :set_value, :RA_SelectComboByValue,
62
+ [:pointer, :pointer], :int
63
+ attach_function :select_menu_item, :RA_SelectMenuItem,
64
+ [:long, :pointer, :int, :varargs], :void
65
+ attach_function :menu_item_exists, :RA_MenuItemExists,
66
+ [:long, :varargs], :bool
67
+ attach_function :get_combobox_count, :RA_GetComboOptionsCount,
68
+ [:long], :int
69
+ attach_function :get_combobox_value, :RA_GetComboValueByIndex,
70
+ [:long, :int, :pointer, :int], :bool
71
+ attach_function :get_combobox_selected_index, :RA_GetSelectedComboIndex,
72
+ [:long], :int
73
+ attach_function :get_data_item_count, :RA_GetDataItemCount,
74
+ [:long], :int
75
+ attach_function :select_data_item, :RA_SelectDataItem,
76
+ [:long, :int], :void
77
+ attach_function :expand_by_value, :RA_ExpandItemByValue,
78
+ [:long, :string], :void
79
+ attach_function :expand_by_index, :RA_ExpandItemByIndex,
80
+ [:long, :int], :void
81
+ attach_function :collapse_by_value, :RA_CollapseItemByValue,
82
+ [:long, :string], :void
83
+ attach_function :collapse_by_index, :RA_CollapseItemByIndex,
84
+ [:long, :int], :void
85
+ attach_function :data_item_exists_by_value, :RA_DataItemExistsByValue,
86
+ [:long, :string], :bool
87
+ attach_function :RA_DataItemExists,
88
+ [:long, :int, :int], :bool
89
+
90
+ attach_function :RA_CellValueAt,
91
+ [:long, :int, :int, :pointer, :int], :void
92
+
93
+ attach_function :control_click, :RA_Click,
94
+ [:long, :pointer, :int], :void
95
+ attach_function :control_mouse_click, :RA_PointAndClick,
96
+ [:long, :pointer, :int], :void
97
+
98
+ def self.cell_value_at(hwnd, row, column=0)
99
+ string = FFI::MemoryPointer.new :char, 1024
100
+ RA_CellValueAt hwnd, row, column, string, 1024
101
+ string.read_string
102
+ end
103
+
104
+ def self.data_item_exists(hwnd, row, column=0)
105
+ RA_DataItemExists hwnd, row, column
106
+ end
61
107
  end
62
108
  end
63
109
  end
@@ -184,6 +184,12 @@ module RAutomation
184
184
  TextField.new(self, locator)
185
185
  end
186
186
 
187
+ # Returns a {Menu} object use to build a path to a menu item to open.
188
+ # @param [Hash] locator for the {Menu}. Only :text is allowed.
189
+ def menu(locator)
190
+ Menu.new(self, locator)
191
+ end
192
+
187
193
  # Redirects all method calls not part of the public API to the {Functions} directly.
188
194
  # @see RAutomation::Window#method_missing
189
195
  def method_missing(name, *args)
@@ -369,7 +375,6 @@ module RAutomation
369
375
  release_key key
370
376
  key
371
377
  end
372
-
373
378
  end
374
379
  end
375
380
  end
@@ -14,6 +14,7 @@ require File.dirname(__FILE__) + "/ms_uia/button_helper"
14
14
  require File.dirname(__FILE__) + "/ms_uia/control"
15
15
  require File.dirname(__FILE__) + "/ms_uia/button"
16
16
  require File.dirname(__FILE__) + "/ms_uia/checkbox"
17
+ require File.dirname(__FILE__) + "/ms_uia/menu"
17
18
  require File.dirname(__FILE__) + "/ms_uia/radio"
18
19
  require File.dirname(__FILE__) + "/ms_uia/text_field"
19
20
  require File.dirname(__FILE__) + "/ms_uia/select_list"
@@ -10,7 +10,7 @@ describe "AutoIt::Mouse", :if => SpecHelper.adapter == :autoit do
10
10
 
11
11
  window.maximize
12
12
  mouse = window.mouse
13
- mouse.move :x => 60, :y => 45
13
+ mouse.move :x => 60, :y => 65
14
14
  mouse.click
15
15
 
16
16
  RAutomation::WaitHelper.wait_until {popup.present?}
@@ -33,7 +33,7 @@ describe "AutoIt::Mouse", :if => SpecHelper.adapter == :autoit do
33
33
  text_field.value.should == "start string"
34
34
 
35
35
  mouse = window.mouse
36
- mouse.move :x => 146, :y => 103
36
+ mouse.move :x => 146, :y => 125
37
37
  mouse.press
38
38
  mouse.move :x => 194
39
39
  mouse.release
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "MsUia::Functions", :if => SpecHelper.adapter == :ms_uia do
4
+ context "working with expandable / collapsable items" do
5
+ let(:tree_view) { RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "treeView") }
6
+
7
+ def options
8
+ tree_view.options.map &:text
9
+ end
10
+
11
+ it "can be expanded by value" do
12
+ options.should eq ["Parent One", "Parent Two"]
13
+ tree_view.expand "Parent One"
14
+ options.should eq ["Parent One", "Child 1", "Child 2", "Parent Two"]
15
+ end
16
+
17
+ it "can be expanded by index" do
18
+ options.should eq ["Parent One", "Parent Two"]
19
+ tree_view.expand 0
20
+ tree_view.expand 2
21
+ options.should eq ["Parent One", "Child 1", "Child 2", "Grandchild 1", "Parent Two"]
22
+ end
23
+
24
+ it "can be collapsed by value" do
25
+ tree_view.expand "Parent One"
26
+ options.should eq ["Parent One", "Child 1", "Child 2", "Parent Two"]
27
+ tree_view.collapse "Parent One"
28
+ options.should eq ["Parent One", "Parent Two"]
29
+ end
30
+
31
+ it "can be collapsed by index" do
32
+ tree_view.expand 0
33
+ options.should eq ["Parent One", "Child 1", "Child 2", "Parent Two"]
34
+ tree_view.collapse 0
35
+ options.should eq ["Parent One", "Parent Two"]
36
+ end
37
+ end
38
+
39
+ end
@@ -72,6 +72,32 @@ describe "MsUia::SelectList", :if => SpecHelper.adapter == :ms_uia do
72
72
  lambda { select_list.option(:text => "Apple").set }.should raise_error
73
73
  end
74
74
 
75
+ it "fires change event when the value is set" do
76
+
77
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
78
+
79
+ select_list.option(:text => "Apple").should_not be_selected
80
+ select_list.set("Apple")
81
+ select_list.option(:text => "Apple").should be_selected
82
+
83
+ label = RAutomation::Window.new(:title => "MainFormWindow").label(:id => "fruitsLabel")
84
+ RAutomation::WaitHelper.wait_until { label.exist? }
85
+ label.value.should == "Apple"
86
+ end
87
+
88
+ it "fires change event when the index changes" do
89
+
90
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
91
+ label = RAutomation::Window.new(:title => "MainFormWindow").label(:id => "fruitsLabel")
92
+
93
+ select_list.options[4].select
94
+ select_list.option(:text => "Passion Fruit").should be_selected
95
+ label.value.should == "Passion Fruit"
96
+
97
+ select_list.select 3
98
+ select_list.option(:text => "Orange").should be_selected
99
+ label.value.should == "Orange"
100
+ end
75
101
 
76
102
  # it "control by focus" do
77
103
  # window = RAutomation::Window.new(:title => /MainFormWindow/i)
@@ -93,17 +119,4 @@ describe "MsUia::SelectList", :if => SpecHelper.adapter == :ms_uia do
93
119
  # sleep 10
94
120
  # box1.should == box2
95
121
  # end
96
-
97
- # it "fires change event when selected" do
98
- #
99
- # select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
100
- #
101
- # select_list.option(:text => "Apple").should_not be_selected
102
- # select_list.set("Apple")
103
- # select_list.option(:text => "Apple").should be_selected
104
- #
105
- # label = RAutomation::Window.new(:title => "MainFormWindow").label(:id => "fruitsLabel")
106
- # sleep 1
107
- # label.value.should == "Apple"
108
- # end
109
122
  end
@@ -40,10 +40,104 @@ describe "MsUia::Table", :if => SpecHelper.adapter == :ms_uia do
40
40
  it "#select" do
41
41
  table = RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView")
42
42
 
43
- table.selected?(2).should == false
43
+ table.select(1)
44
+ table.should_not be_selected(2)
44
45
 
45
46
  table.select(2)
46
- table.selected?(2).should == true
47
+ table.should be_selected(2)
48
+ end
49
+
50
+ it "#row_count" do
51
+ table = RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView")
52
+ table.row_count.should eq(2)
53
+ end
54
+
55
+ context "#rows" do
56
+ let(:table) { RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView") }
57
+
58
+ it "has rows" do
59
+ table.rows.size.should eq 2
60
+ end
61
+
62
+ it "have values" do
63
+ table.rows.map(&:value).should eq ["John Doe", "Anna Doe"]
64
+ end
65
+
66
+ it "values are also text" do
67
+ table.rows.map(&:text).should eq ["John Doe", "Anna Doe"]
68
+ end
69
+
70
+ context "locators" do
71
+ it "can locate by text" do
72
+ table.rows(:text => "Anna Doe").size.should eq 1
73
+ end
74
+
75
+ it "can locate by regex" do
76
+ table.rows(:text => /Doe/).size.should eq 2
77
+ end
78
+
79
+ it "can locate by index" do
80
+ table.rows(:index => 1).first.text.should eq "Anna Doe"
81
+ end
82
+
83
+ it "an index is also a row" do
84
+ table.rows(:row => 1).first.text.should eq "Anna Doe"
85
+ end
86
+ end
87
+
88
+ context "singular row" do
89
+ it "grabs the first by default" do
90
+ table.row.text.should eq "John Doe"
91
+ end
92
+
93
+ it "can haz locators too" do
94
+ table.row(:text => "Anna Doe").text.should eq "Anna Doe"
95
+ end
96
+ end
97
+
98
+ context "Row#cells" do
99
+ let(:row) { table.row }
100
+
101
+ it "has cells" do
102
+ row.cells.size.should eq 3
103
+ end
104
+
105
+ it "cells have values" do
106
+ row.cells.map(&:value).should eq ["John Doe", "12/15/1967", "FL"]
107
+ end
108
+
109
+ it "values are also text" do
110
+ row.cells.map(&:text).should eq ["John Doe", "12/15/1967", "FL"]
111
+ end
112
+
113
+ context "locators" do
114
+ it "can locate by text" do
115
+ row.cells(:text => "FL").size.should eq 1
116
+ end
117
+
118
+ it "can locate by regex" do
119
+ row.cells(:text => /[JF]/).size.should eq 2
120
+ end
121
+
122
+ it "can locate by index" do
123
+ row.cells(:index => 1).first.text.should eq "12/15/1967"
124
+ end
125
+
126
+ it "an index is also a column" do
127
+ row.cells(:column => 1).first.text.should eq "12/15/1967"
128
+ end
129
+ end
130
+
131
+ context "singular cell" do
132
+ it "grabs the first by default" do
133
+ row.cell.text.should eq "John Doe"
134
+ end
135
+
136
+ it "can haz locators too" do
137
+ row.cell(:text => "FL").text.should eq "FL"
138
+ end
139
+ end
140
+ end
47
141
  end
48
142
 
49
143
  end
@@ -40,6 +40,43 @@ describe "MsUia::Window", :if => SpecHelper.adapter == :ms_uia do
40
40
  end
41
41
  end
42
42
 
43
+ context "menu items" do
44
+ let(:about_box) { RAutomation::Window.new :title => "About" }
45
+
46
+ it "can select menu items" do
47
+ window.menu(:text => "File").menu(:text => "About").open
48
+ RAutomation::WaitHelper.wait_until { about_box.present? }
49
+ end
50
+
51
+ it "can select deep menu items" do
52
+ window.menu(:text => "File")
53
+ .menu(:text => "Roundabout Way")
54
+ .menu(:text => "About").open
55
+ RAutomation::WaitHelper.wait_until { about_box.present? }
56
+ end
57
+
58
+ it "raises when errors occur" do
59
+ lambda { window.menu(:text => "File").menu(:text => "Does Not Exist").open}.should raise_error
60
+ end
61
+
62
+ it "indicates if the menu item does not exist" do
63
+ begin
64
+ window.menu(:text => "File").menu(:text => "Should Not Exist").open
65
+ fail "Should have failed to find the menu item"
66
+ rescue Exception => e
67
+ e.message.should match /MenuItem with the text "Should Not Exist" does not exist/
68
+ end
69
+ end
70
+
71
+ it "knows when menu items exist" do
72
+ window.menu(:text => "File").menu(:text => "About").should exist
73
+ end
74
+
75
+ it "knows when menu items do not exist" do
76
+ window.menu(:text => "File").menu(:text => "Missing").should_not exist
77
+ end
78
+ end
79
+
43
80
  =begin
44
81
  it "control by focus" do
45
82
  window = RAutomation::Window.new(:title => /MainFormWindow/i)
@@ -54,17 +91,6 @@ describe "MsUia::Window", :if => SpecHelper.adapter == :ms_uia do
54
91
  box1.should == box2
55
92
  end
56
93
 
57
- it "#child" do
58
- window = RAutomation::Window.new(:title => /MainFormWindow/i)
59
- window.should exist
60
-
61
- # buttons are windows too. so let's find the button for now
62
- child = window.child(:title => /About/i)
63
- child.should exist
64
- child.title.should == "&About"
65
- # child.text.should include "About"
66
- end
67
-
68
94
  it "send tab keystrokes to move focus between elements" do
69
95
  window = RAutomation::Window.new(:title => /MainFormWindow/i)
70
96
  window.button(:value => "&About").set_focus
@@ -10,7 +10,7 @@ describe "Win32::Mouse", :if => SpecHelper.adapter == :win_32 do
10
10
 
11
11
  window.maximize
12
12
  mouse = window.mouse
13
- mouse.move :x => 60, :y => 45
13
+ mouse.move :x => 60, :y => 65
14
14
  mouse.click
15
15
 
16
16
  RAutomation::WaitHelper.wait_until {popup.present?}
@@ -33,7 +33,7 @@ describe "Win32::Mouse", :if => SpecHelper.adapter == :win_32 do
33
33
  text_field.value.should == "start string"
34
34
 
35
35
  mouse = window.mouse
36
- mouse.move :x => 146, :y => 103
36
+ mouse.move :x => 146, :y => 125
37
37
  mouse.press
38
38
  mouse.move :x => 194
39
39
  mouse.release
@@ -3,15 +3,6 @@ require "spec_helper"
3
3
  describe "Win32::Window", :if => SpecHelper.adapter == :win_32 do
4
4
  let(:window) {RAutomation::Window.new(:title => /MainFormWindow/i)}
5
5
 
6
- it "#child" do
7
- window.should exist
8
-
9
- # buttons are windows too. so let's find the button for now
10
- child = window.child(:title => /About/i)
11
- child.should exist
12
- child.title.should == "&About"
13
- end
14
-
15
6
  context "#send_keys" do
16
7
  it "send tab keystrokes to move focus between elements" do
17
8
  window.button(:value => "&About").focus
data/spec/spec_helper.rb CHANGED
@@ -28,7 +28,7 @@ module SpecHelper
28
28
  :autoit => {
29
29
  # Path to some binary, which opens up a window, what can be
30
30
  # minimized, maximized, activated, closed and etc.
31
- :window1 => "ext\\WindowsForms\\bin\\WindowsForms.exe",
31
+ :window1 => "ext\\WindowsForms\\Release\\WindowsForms.exe",
32
32
  :window2 => "calc",
33
33
  :window2_title => /calc/i,
34
34
  # Window 1 title, has to be a Regexp.
@@ -53,7 +53,7 @@ module SpecHelper
53
53
  :win_32 => {
54
54
  # Path to some binary, which opens up a window, what can be
55
55
  # minimized, maximized, activated, closed and etc.
56
- :window1 => "ext\\WindowsForms\\bin\\WindowsForms.exe",
56
+ :window1 => "ext\\WindowsForms\\Release\\WindowsForms.exe",
57
57
  :window2 => "calc",
58
58
  :window2_title => /calc/i,
59
59
  # Window 1 title, has to be a Regexp.
@@ -79,7 +79,7 @@ module SpecHelper
79
79
  :ms_uia => {
80
80
  # Path to some binary, which opens up a window, what can be
81
81
  # minimized, maximized, activated, closed and etc.
82
- :window1 => "ext\\WindowsForms\\bin\\WindowsForms.exe",
82
+ :window1 => "ext\\WindowsForms\\Release\\WindowsForms.exe",
83
83
  :window2 => "calc",
84
84
  :window2_title => /calc/i,
85
85
  # Window 1 title, has to be a Regexp.