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 CHANGED
@@ -1,11 +1,7 @@
1
- === Version 0.3.3 / 2014-05-13
1
+ === Version 0.4 / 2014-05-13
2
2
  * Enhancements
3
- * MenuItems#has_menu_item?
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
- bool HasMenuItemPath(ElementInformationPtr, char*, const int, list<const char*>&);
11
- InvokePattern^ MenuItemPath(ElementInformationPtr, list<const char*>&);
10
+ ElementInformationPtr MenuItemByPath(ElementInformationPtr element, char*, const int, list<const char*>& items);
11
+ Element^ MenuItemPath(ElementInformationPtr, list<const char*>&);
12
12
 
13
- __declspec(dllexport) bool MenuItem_HasPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, const int n, const char* arg0, ...) {
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 HasMenuItemPath(element, errorInfo, errorInfoLength, menuItems);
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
- bool HasMenuItemPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, list<const char*>& items) {
31
+ ElementInformationPtr MenuItemByPath(ElementInformationPtr element, char* errorInfo, const int errorInfoLength, list<const char*>& items) {
32
32
  try {
33
- return nullptr != MenuItemPath(element, items);
33
+ return ElementInformation::From(MenuItemPath(element, items));
34
34
  } catch(MenuItemNotFound^) {
35
- return false;
35
+ return NULL;
36
36
  } catch(Exception^ e) {
37
37
  StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
38
- return false;
38
+ return NULL;
39
39
  }
40
40
  }
41
41
 
42
- InvokePattern^ MenuItemPath(ElementInformationPtr element, list<const char*>& items) {
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->As<InvokePattern^>(InvokePattern::Pattern);
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 select_menu_path(*path)
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 has_menu_item?(*path)
10
- Library.has_menu_item @element, *path
8
+ def menu_item(*path)
9
+ Library.menu_item @element, *path
11
10
  end
12
11
  end
13
12
  end
@@ -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 :MenuItem_HasPath, [:pointer, :pointer, :int, :int, :varargs], :bool
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.has_menu_item(element, *path)
163
- try_catch {|s, n| MenuItem_HasPath element, s, n, path.count, *path.to_var_args(:string) }
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)
@@ -1,3 +1,3 @@
1
1
  module Uia
2
- VERSION = '0.3.3'
2
+ VERSION = '0.4'
3
3
  end
@@ -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 'existence' do
12
- Then { expect(main).not_to have_menu_item 'non-existent' }
13
- Then { expect(main).not_to have_menu_item 'File', 'Roundabout Way', 'To', 'Not There' }
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 { expect(main).to have_menu_item 'File' }
16
- Then { expect(main).to have_menu_item 'File', 'Roundabout Way', 'To' }
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 'selecting individually' do
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.select_menu_path 'File', 'Roundabout Way', 'To', 'About' }
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.select_menu_path 'File', 'Roundabout Way', 'To', 'Something Not There' }
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.3.3
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: -227578093
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: -227578093
273
+ hash: -662745805
274
274
  requirements: []
275
275
  rubyforge_project:
276
276
  rubygems_version: 1.8.28