uia 0.0.6 → 0.0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ === Version 0.0.6.1 / 2013-10-30
2
+ * Bug Fixes
3
+ * Fixed issue when finding root children by RegEx initially
4
+ * all Find methods consistently return Element classes
5
+
1
6
  === Version 0.0.6 / 2013-10-22
2
7
  * Enhancements
3
8
  * Have implemented the following patterns:
Binary file
Binary file
@@ -62,6 +62,11 @@ namespace UIA.Helper
62
62
  get { return _element.GetSupportedPatterns().Select(x => x.Id).ToArray(); }
63
63
  }
64
64
 
65
+ public static Element[] Windows
66
+ {
67
+ get { return Find(AutomationElement.RootElement, TreeScope.Children, Condition.TrueCondition); }
68
+ }
69
+
65
70
  public Element[] Children
66
71
  {
67
72
  get { return Find(TreeScope.Children, Condition.TrueCondition); }
@@ -124,7 +129,12 @@ namespace UIA.Helper
124
129
 
125
130
  private Element[] Find(TreeScope scope, Condition condition)
126
131
  {
127
- return _element.FindAll(scope, condition).Cast<AutomationElement>()
132
+ return Find(_element, scope, condition);
133
+ }
134
+
135
+ private static Element[] Find(AutomationElement element, TreeScope scope, Condition condition)
136
+ {
137
+ return element.FindAll(scope, condition).Cast<AutomationElement>()
128
138
  .Select(x => new Element(x))
129
139
  .ToArray();
130
140
  }
@@ -99,7 +99,7 @@ extern "C" {
99
99
 
100
100
  __declspec(dllexport) ElementsPtr Root_Children(char* errorInfo, const int errorInfoLength) {
101
101
  try {
102
- return new Elements(Element::From(AutomationElement::RootElement)->Children);
102
+ return new Elements(Element::Windows);
103
103
  } catch(Exception^ e) {
104
104
  StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
105
105
  return NULL;
data/lib/uia/element.rb CHANGED
@@ -47,11 +47,11 @@ module Uia
47
47
  end
48
48
 
49
49
  def children
50
- @element.children.map { |c| Element.new c }
50
+ @element.children
51
51
  end
52
52
 
53
53
  def descendants
54
- @element.descendants.map { |c| Element.new c }
54
+ @element.descendants
55
55
  end
56
56
 
57
57
  def click
@@ -86,7 +86,8 @@ module Uia
86
86
 
87
87
  def children
88
88
  self[:length].times.collect do |i|
89
- ElementCast.new(self[:items] + i * ElementCast.size)
89
+ pointer = self[:items] + i * ElementCast.size
90
+ Uia::Element.new(ElementCast.new(pointer))
90
91
  end
91
92
  end
92
93
 
data/lib/uia/library.rb CHANGED
@@ -5,8 +5,6 @@ module Uia
5
5
  module Library
6
6
  extend FFI::Library
7
7
 
8
- PropertyId = enum(:is_selection_item, 0)
9
-
10
8
  def self.uia_directory
11
9
  File.dirname(__FILE__) + '/../../ext/UiaDll/Release'
12
10
  end
@@ -45,7 +43,7 @@ module Uia
45
43
  attach_throwable_function :find_by_id, :Element_FindById, [:string], ElementStruct.by_ref, &element_or_nil
46
44
  attach_throwable_function :find_by_name, :Element_FindByName, [:string], ElementStruct.by_ref, &element_or_nil
47
45
  attach_throwable_function :find_by_pid, :Element_FindByProcessId, [:int], ElementStruct.by_ref, &element_or_nil
48
- attach_throwable_function :find_by_handle, :Element_FindByHandle, [:int], ElementStruct.by_ref
46
+ attach_throwable_function :find_by_handle, :Element_FindByHandle, [:int], ElementStruct.by_ref, &element_or_nil
49
47
  attach_function :Element_FindByRuntimeId, [:pointer, :int, :pointer, :int], ElementStruct.by_ref
50
48
 
51
49
  # element methods
data/lib/uia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uia
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.6.1'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,8 @@ require 'childprocess'
7
7
  require 'ffi'
8
8
  require 'uia'
9
9
 
10
+ include Uia
11
+
10
12
  RSpec.configure do |config|
11
13
  config.before(:all) do
12
14
  @app = ChildProcess.build('spec/app/WindowsForms.exe').start
data/spec/uia_spec.rb CHANGED
@@ -9,24 +9,24 @@ describe Uia do
9
9
  Given(:main_window) { Uia.find_element id: 'MainFormWindow' }
10
10
 
11
11
  context 'by id' do
12
- Then { Uia.find_element(id: 'MainFormWindow') != nil }
13
- Then { Uia.find_element(id: /[Mm]ain/) != nil }
12
+ Then { expect(Uia.find_element(id: 'MainFormWindow')).to be_instance_of(Element) }
13
+ Then { expect(Uia.find_element(id: /[Mm]ain/)).to be_instance_of(Element) }
14
14
  Then { Uia.find_element(id: 'not there') == nil }
15
15
  end
16
16
 
17
17
  context 'by name' do
18
- Then { Uia.find_element(name: 'MainFormWindow') != nil }
19
- Then { Uia.find_element(name: /[Mm]ain.*Window/ ) != nil }
18
+ Then { expect(Uia.find_element(name: 'MainFormWindow')).to be_instance_of(Element) }
19
+ Then { expect(Uia.find_element(name: /[Mm]ain.*Window/ )).to be_instance_of(Element) }
20
20
  Then { Uia.find_element(name: 'not there') == nil }
21
21
  end
22
22
 
23
23
  context 'by process id' do
24
- Then { Uia.find_element(pid: @app.pid) != nil }
24
+ Then { expect(Uia.find_element(pid: @app.pid)).to be_instance_of(Element) }
25
25
  Then { Uia.find_element(pid: -1) == nil }
26
26
  end
27
27
 
28
28
  context 'by runtime id' do
29
- Then { Uia.find_element(runtime_id: main_window.runtime_id) != nil }
29
+ Then { expect(Uia.find_element(runtime_id: main_window.runtime_id)).to be_instance_of(Element) }
30
30
 
31
31
  context 'can search descendants' do
32
32
  Given(:element_with_no_handle) { Uia.find_element(id: 'MainFormWindow').find(name: 'Parent Two') }
@@ -35,7 +35,7 @@ describe Uia do
35
35
  end
36
36
 
37
37
  context 'by window handle' do
38
- Then { Uia.find_element(handle: main_window.handle) != nil }
38
+ Then { expect(Uia.find_element(handle: main_window.handle)).to be_instance_of(Element) }
39
39
  Then { expect { Uia.find_element(handle: 0x0) }.to raise_error }
40
40
  end
41
41
 
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.0.6
4
+ version: 0.0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-23 00:00:00.000000000 Z
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -211,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
211
  version: '0'
212
212
  segments:
213
213
  - 0
214
- hash: 149401647
214
+ hash: 849394065
215
215
  required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  none: false
217
217
  requirements:
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  version: '0'
221
221
  segments:
222
222
  - 0
223
- hash: 149401647
223
+ hash: 849394065
224
224
  requirements: []
225
225
  rubyforge_project:
226
226
  rubygems_version: 1.8.24