uia 0.3.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -7
- data/ext/UiaDll/UiaDll/MenuItemMethods.cpp +11 -11
- data/lib/uia/control_types/menu_item.rb +3 -4
- data/lib/uia/library.rb +4 -3
- data/lib/uia/version.rb +1 -1
- data/spec/uia/control_types/menu_item_spec.rb +8 -13
- metadata +3 -3
data/ChangeLog
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
=== Version 0.
|
1
|
+
=== Version 0.4 / 2014-05-13
|
2
2
|
* Enhancements
|
3
|
-
* MenuItems#
|
4
|
-
|
5
|
-
=== Version 0.3.2 / 2014-05-13
|
6
|
-
* Enhancements
|
7
|
-
* added #with method to extend an Element based on ControlPatterns
|
8
|
-
* Uia::ControlPatterns::MenuItems can select a menu item by name or path
|
3
|
+
* MenuItems#menu_item - find by path
|
4
|
+
* MenuItems#select_menu_item
|
9
5
|
|
10
6
|
=== Version 0.3.1 / 2014-05-07
|
11
7
|
* Enhancements
|
@@ -7,12 +7,12 @@ extern "C" {
|
|
7
7
|
};
|
8
8
|
|
9
9
|
void SelectMenuItemPath(ElementInformationPtr, char*, const int, list<const char*>&);
|
10
|
-
|
11
|
-
|
10
|
+
ElementInformationPtr MenuItemByPath(ElementInformationPtr element, char*, const int, list<const char*>& items);
|
11
|
+
Element^ MenuItemPath(ElementInformationPtr, list<const char*>&);
|
12
12
|
|
13
|
-
__declspec(dllexport)
|
13
|
+
__declspec(dllexport) ElementInformationPtr MenuItem_ByPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, const int n, const char* arg0, ...) {
|
14
14
|
GRAB_VARARGS(menuItems, const char*, n);
|
15
|
-
return
|
15
|
+
return MenuItemByPath(element, errorInfo, errorInfoLength, menuItems);
|
16
16
|
}
|
17
17
|
|
18
18
|
__declspec(dllexport) void MenuItem_SelectPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, const int n, const char* arg0, ...) {
|
@@ -22,24 +22,24 @@ extern "C" {
|
|
22
22
|
|
23
23
|
void SelectMenuItemPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, list<const char*>& items) {
|
24
24
|
try {
|
25
|
-
MenuItemPath(element, items)->Invoke();
|
25
|
+
MenuItemPath(element, items)->As<InvokePattern^>(InvokePattern::Pattern)->Invoke();
|
26
26
|
} catch(Exception^ e) {
|
27
27
|
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
28
28
|
}
|
29
29
|
}
|
30
30
|
|
31
|
-
|
31
|
+
ElementInformationPtr MenuItemByPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, list<const char*>& items) {
|
32
32
|
try {
|
33
|
-
return
|
33
|
+
return ElementInformation::From(MenuItemPath(element, items));
|
34
34
|
} catch(MenuItemNotFound^) {
|
35
|
-
return
|
35
|
+
return NULL;
|
36
36
|
} catch(Exception^ e) {
|
37
37
|
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
38
|
-
return
|
38
|
+
return NULL;
|
39
39
|
}
|
40
40
|
}
|
41
41
|
|
42
|
-
|
42
|
+
Element^ MenuItemPath(ElementInformationPtr element, list<const char*>& items) {
|
43
43
|
auto current = ElementFrom(element);
|
44
44
|
|
45
45
|
for(auto item = items.begin(); item != items.end(); ++item) {
|
@@ -55,6 +55,6 @@ extern "C" {
|
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
58
|
-
return current
|
58
|
+
return current;
|
59
59
|
}
|
60
60
|
}
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Uia
|
2
2
|
module ControlTypes
|
3
3
|
module MenuItems
|
4
|
-
def
|
4
|
+
def select_menu_item(*path)
|
5
5
|
Library.select_menu_path @element, *path
|
6
6
|
end
|
7
|
-
alias_method :select_menu_item, :select_menu_path
|
8
7
|
|
9
|
-
def
|
10
|
-
Library.
|
8
|
+
def menu_item(*path)
|
9
|
+
Library.menu_item @element, *path
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
data/lib/uia/library.rb
CHANGED
@@ -153,14 +153,15 @@ module Uia
|
|
153
153
|
|
154
154
|
# MenuItem methods
|
155
155
|
attach_function :MenuItem_SelectPath, [:pointer, :pointer, :int, :int, :varargs], :void
|
156
|
-
attach_function :
|
156
|
+
attach_function :MenuItem_ByPath, [:pointer, :pointer, :int, :int, :varargs], ManagedElementStruct.by_ref
|
157
157
|
|
158
158
|
def self.select_menu_path(element, *path)
|
159
159
|
try_catch {|s, n| MenuItem_SelectPath element, s, n, path.count, *path.to_var_args(:string) }
|
160
160
|
end
|
161
161
|
|
162
|
-
def self.
|
163
|
-
try_catch {|s, n|
|
162
|
+
def self.menu_item(element, *path)
|
163
|
+
e = try_catch {|s, n| MenuItem_ByPath element, s, n, path.count, *path.to_var_args(:string) }
|
164
|
+
Uia::Element.new(e) unless e.empty?
|
164
165
|
end
|
165
166
|
|
166
167
|
def self.find_by_runtime_id(id)
|
data/lib/uia/version.rb
CHANGED
@@ -8,27 +8,22 @@ describe Uia::ControlTypes::MenuItems do
|
|
8
8
|
about.send_keys [:alt, :f4] if about
|
9
9
|
end
|
10
10
|
|
11
|
-
context '
|
12
|
-
Then {
|
13
|
-
Then {
|
11
|
+
context '#menu_item' do
|
12
|
+
Then { main.menu_item('non-existent') == nil }
|
13
|
+
Then { main.menu_item('File', 'Roundabout Way', 'To', 'Not There') == nil }
|
14
14
|
|
15
|
-
Then {
|
16
|
-
Then {
|
15
|
+
Then { main.menu_item('File').name == 'File' }
|
16
|
+
Then { main.menu_item('File', 'Roundabout Way', 'To').name == 'To' }
|
17
17
|
end
|
18
18
|
|
19
|
-
context '
|
20
|
-
When { main.select_menu_item 'About' }
|
21
|
-
Then { Uia.find_element(title: 'About') != nil }
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'selecting a path' do
|
19
|
+
context '#select_menu_item' do
|
25
20
|
context 'valid' do
|
26
|
-
When { main.
|
21
|
+
When { main.select_menu_item 'File', 'Roundabout Way', 'To', 'About' }
|
27
22
|
Then { Uia.find_element(title: 'About') != nil }
|
28
23
|
end
|
29
24
|
|
30
25
|
context 'invalid' do
|
31
|
-
Given(:bad_path) { main.
|
26
|
+
Given(:bad_path) { main.select_menu_item 'File', 'Roundabout Way', 'To', 'Something Not There' }
|
32
27
|
Then { expect { bad_path }.to raise_error(RuntimeError, /Something Not There/) }
|
33
28
|
end
|
34
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -261,7 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
261
261
|
version: '0'
|
262
262
|
segments:
|
263
263
|
- 0
|
264
|
-
hash: -
|
264
|
+
hash: -662745805
|
265
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
266
|
none: false
|
267
267
|
requirements:
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
version: '0'
|
271
271
|
segments:
|
272
272
|
- 0
|
273
|
-
hash: -
|
273
|
+
hash: -662745805
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
276
|
rubygems_version: 1.8.28
|