bewildr 0.1.4 → 0.1.6
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/README.rdoc +1 -1
- data/Rakefile +2 -2
- data/lib/bewildr.rb +2 -0
- data/lib/bewildr/control_patterns/scroll_pattern.rb +38 -0
- data/lib/bewildr/control_type_additions/list_additions.rb +1 -0
- data/lib/bewildr/control_type_additions/scroll_additions.rb +34 -0
- data/lib/bewildr/control_type_additions/tree_additions.rb +1 -0
- data/lib/bewildr/element.rb +17 -1
- metadata +8 -6
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -10,10 +10,10 @@ require 'cucumber/rake/task'
|
|
10
10
|
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
12
|
s.name = 'bewildr'
|
13
|
-
s.version = '0.1.
|
13
|
+
s.version = '0.1.6'
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
|
16
|
-
s.summary = 'Test WPF UI apps with
|
16
|
+
s.summary = 'Test WPF UI apps with IronRuby'
|
17
17
|
s.description = s.summary
|
18
18
|
s.author = 'Nat Ritmeyer'
|
19
19
|
s.email = 'nat@natontesting.com'
|
data/lib/bewildr.rb
CHANGED
@@ -40,6 +40,7 @@ require 'bewildr/control_patterns/grid_pattern'
|
|
40
40
|
require 'bewildr/control_patterns/table_pattern'
|
41
41
|
require 'bewildr/control_patterns/text_pattern'
|
42
42
|
require 'bewildr/control_patterns/table_item_pattern'
|
43
|
+
require 'bewildr/control_patterns/scroll_pattern'
|
43
44
|
|
44
45
|
require 'bewildr/control_type_additions/text_additions'
|
45
46
|
require 'bewildr/control_type_additions/combo_box_additions'
|
@@ -52,3 +53,4 @@ require 'bewildr/control_type_additions/tree_additions'
|
|
52
53
|
require 'bewildr/control_type_additions/tree_item_additions'
|
53
54
|
require 'bewildr/control_type_additions/data_grid_additions'
|
54
55
|
require 'bewildr/control_type_additions/document_additions'
|
56
|
+
require 'bewildr/control_type_additions/scroll_additions'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlPatterns
|
5
|
+
module ScrollPattern
|
6
|
+
def self.extended(base)
|
7
|
+
|
8
|
+
base.instance_eval do
|
9
|
+
def vertically_scrollable
|
10
|
+
@automation_element.get_current_pattern(System::Windows::Automation::ScrollPattern.pattern).current.vertically_scrollable
|
11
|
+
end
|
12
|
+
|
13
|
+
def vertical_scroll_percent
|
14
|
+
@automation_element.get_current_pattern(System::Windows::Automation::ScrollPattern.pattern).current.vertical_scroll_percent.to_f
|
15
|
+
end
|
16
|
+
alias :scroll_percent :vertical_scroll_percent
|
17
|
+
|
18
|
+
def set_scroll_percent(percent_horizontal, percent_vertical)
|
19
|
+
@automation_element.get_current_pattern(System::Windows::Automation::ScrollPattern.pattern).set_scroll_percent(percent_horizontal, percent_vertical)
|
20
|
+
end
|
21
|
+
|
22
|
+
def scroll_vertically_to(target_percentage)
|
23
|
+
set_scroll_percent(System::Windows::Automation::ScrollPattern.NoScroll, target_percentage)
|
24
|
+
end
|
25
|
+
alias :scroll_to :scroll_vertically_to
|
26
|
+
|
27
|
+
def scroll_horizontally_to(target_percentage)
|
28
|
+
set_scroll_percent(target_percentage, System::Windows::Automation::ScrollPattern.NoScroll)
|
29
|
+
end
|
30
|
+
|
31
|
+
def scroll_down_one_page
|
32
|
+
@automation_element.get_current_pattern(System::Windows::Automation::ScrollPattern.pattern).scroll_vertical(System::Windows::Automation::ScrollAmount.LargeIncrement)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlTypeAdditions
|
5
|
+
module ScrollAdditions
|
6
|
+
def self.extended(base)
|
7
|
+
base.extend Bewildr::ControlPatterns::ScrollPattern
|
8
|
+
|
9
|
+
base.instance_eval do
|
10
|
+
|
11
|
+
#required because when a list is displayed, UI Automation only knows
|
12
|
+
#about the visible items. This method stores where the scroll value is,
|
13
|
+
#then moves the scroller to the top of the scroll bar and proceeds to
|
14
|
+
#page-down until the bottom of the scroll bar is reached. At this point,
|
15
|
+
#UI Automation knows about all the items in the list and we can put
|
16
|
+
#the scroll back where it was before we started this nonsense.
|
17
|
+
def load_all_items_hack
|
18
|
+
return unless scrollable?
|
19
|
+
|
20
|
+
initial_scroll_value = vertical_scroll_percent
|
21
|
+
|
22
|
+
scroll_to 0.0
|
23
|
+
page_down_to_bottom_of_scroll_bar
|
24
|
+
scroll_to initial_scroll_value
|
25
|
+
end
|
26
|
+
|
27
|
+
def page_down_to_bottom_of_scroll_bar
|
28
|
+
scroll_down_one_page while vertical_scroll_percent < 100.0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/bewildr/element.rb
CHANGED
@@ -69,6 +69,15 @@ module Bewildr
|
|
69
69
|
@automation_element.set_focus
|
70
70
|
end
|
71
71
|
|
72
|
+
def scrollable?
|
73
|
+
return false unless @automation_element.get_supported_patterns.collect {|pattern| pattern.programmatic_name.to_s }.include?("ScrollPatternIdentifiers.Pattern")
|
74
|
+
vertically_scrollable
|
75
|
+
end
|
76
|
+
|
77
|
+
def prepare_element
|
78
|
+
load_all_items_hack if scrollable?
|
79
|
+
end
|
80
|
+
|
72
81
|
#:id => "id"
|
73
82
|
#:name => "bob"
|
74
83
|
#:type => :button
|
@@ -194,9 +203,16 @@ module Bewildr
|
|
194
203
|
when :window
|
195
204
|
extend Bewildr::ControlTypeAdditions::WindowAdditions
|
196
205
|
end
|
206
|
+
|
207
|
+
#add scrolling capability if relevant - TODO: this ugliness will be fixed later
|
208
|
+
if @automation_element.get_supported_patterns.collect {|pattern| pattern.programmatic_name.to_s }.include?("ScrollPatternIdentifiers.Pattern")
|
209
|
+
extend Bewildr::ControlTypeAdditions::ScrollAdditions
|
210
|
+
end
|
197
211
|
end
|
198
212
|
|
199
|
-
#TODO:
|
213
|
+
#TODO: replace build_element to use something similar to what's below, but
|
214
|
+
#make it smarter
|
215
|
+
|
200
216
|
def build_custom_control_type
|
201
217
|
@automation_element.get_supported_patterns.each do |supported_pattern|
|
202
218
|
case supported_pattern.programmatic_name.to_s
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bewildr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nat Ritmeyer
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-20 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: Test WPF UI apps with
|
22
|
+
description: Test WPF UI apps with IronRuby
|
23
23
|
email: nat@natontesting.com
|
24
24
|
executables: []
|
25
25
|
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/bewildr/control_patterns/grid_pattern.rb
|
39
39
|
- lib/bewildr/control_patterns/invoke_pattern.rb
|
40
40
|
- lib/bewildr/control_patterns/range_value_pattern.rb
|
41
|
+
- lib/bewildr/control_patterns/scroll_pattern.rb
|
41
42
|
- lib/bewildr/control_patterns/selection_item_pattern.rb
|
42
43
|
- lib/bewildr/control_patterns/selection_pattern.rb
|
43
44
|
- lib/bewildr/control_patterns/table_item_pattern.rb
|
@@ -53,6 +54,7 @@ files:
|
|
53
54
|
- lib/bewildr/control_type_additions/list_additions.rb
|
54
55
|
- lib/bewildr/control_type_additions/menu_additions.rb
|
55
56
|
- lib/bewildr/control_type_additions/menu_item_additions.rb
|
57
|
+
- lib/bewildr/control_type_additions/scroll_additions.rb
|
56
58
|
- lib/bewildr/control_type_additions/tab_additions.rb
|
57
59
|
- lib/bewildr/control_type_additions/text_additions.rb
|
58
60
|
- lib/bewildr/control_type_additions/tree_additions.rb
|
@@ -97,6 +99,6 @@ rubyforge_project:
|
|
97
99
|
rubygems_version: 1.3.7
|
98
100
|
signing_key:
|
99
101
|
specification_version: 3
|
100
|
-
summary: Test WPF UI apps with
|
102
|
+
summary: Test WPF UI apps with IronRuby
|
101
103
|
test_files: []
|
102
104
|
|