lebowski 0.1.1 → 0.2.0
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/History.md +17 -1
- data/Manifest.txt +8 -0
- data/README.md +6 -0
- data/lib/lebowski/foundation/application.rb +340 -74
- data/lib/lebowski/foundation/core.rb +23 -0
- data/lib/lebowski/foundation/dom_element.rb +15 -0
- data/lib/lebowski/foundation/errors/timeout.rb +5 -0
- data/lib/lebowski/foundation/mixins/collection_item_view_support.rb +5 -0
- data/lib/lebowski/foundation/mixins/define_paths_support.rb +318 -0
- data/lib/lebowski/foundation/mixins/delegate_support.rb +5 -0
- data/lib/lebowski/foundation/mixins/frame_application_context_support.rb +37 -0
- data/lib/lebowski/foundation/mixins/inline_text_field_support.rb +5 -0
- data/lib/lebowski/foundation/mixins/key_check.rb +5 -0
- data/lib/lebowski/foundation/mixins/list_item_view_support.rb +5 -0
- data/lib/lebowski/foundation/mixins/positioned_element.rb +24 -0
- data/lib/lebowski/foundation/mixins/stall_support.rb +5 -0
- data/lib/lebowski/foundation/mixins/user_actions.rb +37 -8
- data/lib/lebowski/foundation/mixins/wait_actions.rb +5 -0
- data/lib/lebowski/foundation/object_array.rb +96 -1
- data/lib/lebowski/foundation/proxy_factory.rb +2 -0
- data/lib/lebowski/foundation/proxy_object.rb +128 -130
- data/lib/lebowski/foundation/views/select_button.rb +69 -0
- data/lib/lebowski/foundation/views/view.rb +10 -0
- data/lib/lebowski/foundation/views/web.rb +26 -0
- data/lib/lebowski/foundation.rb +10 -0
- data/lib/lebowski/runtime/errors/remote_control_command_execution_error.rb +5 -0
- data/lib/lebowski/runtime/errors/remote_control_command_timeout_error.rb +5 -0
- data/lib/lebowski/runtime/errors/remote_control_error.rb +5 -0
- data/lib/lebowski/runtime/errors/selenium_server_error.rb +5 -0
- data/lib/lebowski/runtime/object_encoder.rb +5 -0
- data/lib/lebowski/runtime/sprout_core_driver.rb +5 -0
- data/lib/lebowski/runtime/sprout_core_extensions.rb +114 -0
- data/lib/lebowski/runtime.rb +5 -0
- data/lib/lebowski/scui/mixins/link_support.rb +32 -0
- data/lib/lebowski/scui/mixins/node_item_view_support.rb +50 -13
- data/lib/lebowski/scui/mixins/terminal_view_support.rb +30 -0
- data/lib/lebowski/scui/views/color_well.rb +48 -0
- data/lib/lebowski/scui/views/combo_box.rb +90 -87
- data/lib/lebowski/scui/views/content_editable.rb +422 -0
- data/lib/lebowski/scui/views/date_picker.rb +70 -58
- data/lib/lebowski/scui/views/linkit.rb +8 -0
- data/lib/lebowski/scui/views/select_field_tab.rb +30 -0
- data/lib/lebowski/scui.rb +18 -0
- data/lib/lebowski/version.rb +2 -2
- data/resources/user-extensions.js +293 -11
- metadata +69 -25
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
class SproutCoreDriver
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module Runtime
|
3
8
|
|
@@ -21,6 +26,10 @@ module Lebowski
|
|
21
26
|
def open_sc_application(app_root_path, timeout=nil)
|
22
27
|
__remote_control_command("openScApplication", [app_root_path, timeout])
|
23
28
|
end
|
29
|
+
|
30
|
+
def update_sc_application_context(app_name, timeout=nil)
|
31
|
+
__remote_control_command("updateScApplicationContext", [app_name, timeout])
|
32
|
+
end
|
24
33
|
|
25
34
|
# SC Object Foundation Selenium Calls
|
26
35
|
|
@@ -132,6 +141,14 @@ module Lebowski
|
|
132
141
|
return Coords.new(value[0], value[1])
|
133
142
|
end
|
134
143
|
|
144
|
+
def get_sc_element_width(type, *params)
|
145
|
+
return get_element_width(__locator(type, *params))
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_sc_element_height(type, *params)
|
149
|
+
return get_element_height(__locator(type, *params))
|
150
|
+
end
|
151
|
+
|
135
152
|
def get_sc_view_child_view_count(scpath)
|
136
153
|
full_path = "#{scpath}.childViews.length"
|
137
154
|
return __number_command("getScPropertyValue", [full_path, ])
|
@@ -383,6 +400,103 @@ module Lebowski
|
|
383
400
|
__remote_control_command("scWindowMaximize")
|
384
401
|
end
|
385
402
|
|
403
|
+
def sc_select_main_window()
|
404
|
+
sc_select_window('top', '')
|
405
|
+
end
|
406
|
+
|
407
|
+
def sc_select_window(locator_type, locator_value)
|
408
|
+
hash = {
|
409
|
+
:locatorType => locator_type,
|
410
|
+
:locatorValue => locator_value
|
411
|
+
}
|
412
|
+
|
413
|
+
encoded_hash = ObjectEncoder.encode_hash(hash)
|
414
|
+
|
415
|
+
__remote_control_command("scSelectWindow", [encoded_hash])
|
416
|
+
end
|
417
|
+
|
418
|
+
def is_sc_opened_window?(locator_type, locator_value)
|
419
|
+
hash = {
|
420
|
+
:locatorType => locator_type,
|
421
|
+
:locatorValue => locator_value
|
422
|
+
}
|
423
|
+
|
424
|
+
encoded_hash = ObjectEncoder.encode_hash(hash)
|
425
|
+
|
426
|
+
return __boolean_command("isScOpenedWindow", [encoded_hash])
|
427
|
+
end
|
428
|
+
|
429
|
+
def sc_close_opened_window(locator_type, locator_value)
|
430
|
+
hash = {
|
431
|
+
:locatorType => locator_type,
|
432
|
+
:locatorValue => locator_value
|
433
|
+
}
|
434
|
+
|
435
|
+
encoded_hash = ObjectEncoder.encode_hash(hash)
|
436
|
+
|
437
|
+
return __boolean_command("scCloseOpenedWindow", [encoded_hash])
|
438
|
+
end
|
439
|
+
|
440
|
+
def get_css_selector_count(selector)
|
441
|
+
return __number_command("getCssSelectorCount", [selector, ])
|
442
|
+
end
|
443
|
+
|
444
|
+
def select_range(*params)
|
445
|
+
hash = nil
|
446
|
+
|
447
|
+
if params.length == 0
|
448
|
+
raise ArgumentError.new "no parameters were supplied"
|
449
|
+
end
|
450
|
+
|
451
|
+
if params[0].kind_of? Hash
|
452
|
+
hash = params[0]
|
453
|
+
end
|
454
|
+
|
455
|
+
encoded_hash = ObjectEncoder.encode_hash(hash)
|
456
|
+
|
457
|
+
__remote_control_command("selectRange", [encoded_hash])
|
458
|
+
end
|
459
|
+
|
460
|
+
def range_delete_content(*params)
|
461
|
+
hash = nil
|
462
|
+
|
463
|
+
if params.length == 0
|
464
|
+
raise ArgumentError.new "no parameters were supplied"
|
465
|
+
end
|
466
|
+
|
467
|
+
if params[0].kind_of? Hash
|
468
|
+
hash = params[0]
|
469
|
+
end
|
470
|
+
|
471
|
+
encoded_hash = ObjectEncoder.encode_hash(hash)
|
472
|
+
|
473
|
+
__remote_control_command("rangeDeleteContent", [encoded_hash])
|
474
|
+
end
|
475
|
+
|
476
|
+
def range_insert_content(*params)
|
477
|
+
hash = nil
|
478
|
+
|
479
|
+
if params.length == 0
|
480
|
+
raise ArgumentError.new "no parameters were supplied"
|
481
|
+
end
|
482
|
+
|
483
|
+
if params[0].kind_of? Hash
|
484
|
+
hash = params[0]
|
485
|
+
end
|
486
|
+
|
487
|
+
encoded_hash = ObjectEncoder.encode_hash(hash)
|
488
|
+
|
489
|
+
__remote_control_command("rangeInsertContent", [encoded_hash])
|
490
|
+
end
|
491
|
+
|
492
|
+
def get_element_tag_name(selector, index)
|
493
|
+
return __string_command("getElementTagName", [selector, index,])
|
494
|
+
end
|
495
|
+
|
496
|
+
def get_element_child_nodes_count(selector, index)
|
497
|
+
return __number_command("getElementChildNodesCount", [selector, index])
|
498
|
+
end
|
499
|
+
|
386
500
|
# Selenium User Extensions Testing/Debugging Calls
|
387
501
|
|
388
502
|
def __sc_test_computing_property_path(key, path)
|
data/lib/lebowski/runtime.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
require File.expand_path(File.dirname(__FILE__) + '/runtime/errors/remote_control_error')
|
2
7
|
require File.expand_path(File.dirname(__FILE__) + '/runtime/errors/remote_control_command_execution_error')
|
3
8
|
require File.expand_path(File.dirname(__FILE__) + '/runtime/errors/remote_control_command_timeout_error')
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
6
|
+
module Lebowski
|
7
|
+
module SCUI
|
8
|
+
module Mixins
|
9
|
+
|
10
|
+
module LinkSupport
|
11
|
+
|
12
|
+
def start_node
|
13
|
+
return self['startNode']
|
14
|
+
end
|
15
|
+
|
16
|
+
def end_node
|
17
|
+
return self['endNode']
|
18
|
+
end
|
19
|
+
|
20
|
+
def start_terminal
|
21
|
+
return self['startTerminal']
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_terminal
|
25
|
+
return self['endTerminal']
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module SCUI
|
3
8
|
module Mixins
|
@@ -20,36 +25,59 @@ module Lebowski
|
|
20
25
|
return @terminals
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
28
|
+
def links
|
29
|
+
return Support::LinksArray.new self
|
30
|
+
end
|
31
|
+
|
32
|
+
def linked_to?(item)
|
33
|
+
node_item_view = get_node_item_view(item)
|
34
|
+
comparison_node = node_item_view['content']
|
35
|
+
my_node = self['content']
|
26
36
|
|
27
|
-
|
37
|
+
links.each { |link| return true if (link.start_node == comparison_node) || (link.end_node == comparison_node) }
|
38
|
+
node_item_view.links.each { |link| return true if (link.start_node == my_node) || (link.end_node == my_node) }
|
39
|
+
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
|
43
|
+
def positioned_left_of?(item)
|
44
|
+
verify_positioning(item, true, -1)
|
45
|
+
end
|
46
|
+
|
47
|
+
def positioned_right_of?(item)
|
48
|
+
verify_positioning(item, true)
|
28
49
|
end
|
29
50
|
|
30
|
-
def
|
31
|
-
|
32
|
-
self.drag_on_to(fixed_node)
|
51
|
+
def positioned_above?(item)
|
52
|
+
verify_positioning(item, false, -1)
|
33
53
|
end
|
34
54
|
|
35
|
-
def
|
55
|
+
def positioned_below?(item)
|
56
|
+
verify_positioning(item, false)
|
57
|
+
end
|
58
|
+
|
59
|
+
def drag_in_canvas(x, y)
|
60
|
+
self.drag_to(@parent, x, y)
|
61
|
+
end
|
62
|
+
|
63
|
+
def drag_left_of(item)
|
36
64
|
drag_relative_to_node(item, true, -1)
|
37
65
|
end
|
38
66
|
|
39
|
-
def
|
67
|
+
def drag_right_of(item)
|
40
68
|
drag_relative_to_node(item, true)
|
41
69
|
end
|
42
70
|
|
43
|
-
def
|
71
|
+
def drag_above(item)
|
44
72
|
drag_relative_to_node(item, false, -1)
|
45
73
|
end
|
46
74
|
|
47
|
-
def
|
75
|
+
def drag_below(item)
|
48
76
|
drag_relative_to_node(item, false)
|
49
77
|
end
|
50
78
|
|
51
79
|
private
|
52
|
-
def
|
80
|
+
def get_node_item_view(item)
|
53
81
|
if item.kind_of? Integer
|
54
82
|
fixed_node = @parent.item_views[item]
|
55
83
|
raise ArgumentError.new "There is no node at index #{item}" if fixed_node.nil?
|
@@ -61,7 +89,7 @@ module Lebowski
|
|
61
89
|
end
|
62
90
|
|
63
91
|
def drag_relative_to_node(item, horizontal_drag, multiplier = 1)
|
64
|
-
fixed_node =
|
92
|
+
fixed_node = get_node_item_view(item)
|
65
93
|
|
66
94
|
x = horizontal_drag ? (fixed_node.frame.width + 50) * multiplier : 0
|
67
95
|
y = horizontal_drag ? 0 : (fixed_node.frame.height + 50) * multiplier
|
@@ -69,6 +97,15 @@ module Lebowski
|
|
69
97
|
self.drag_to(fixed_node, x, y)
|
70
98
|
end
|
71
99
|
|
100
|
+
def verify_positioning(item, horizontal_drag, multiplier = 1)
|
101
|
+
fixed_node = get_node_item_view(item)
|
102
|
+
x = horizontal_drag ? (fixed_node.position.x + (50 + fixed_node.frame.width) * multiplier) : fixed_node.position.x
|
103
|
+
y = horizontal_drag ? fixed_node.position.y : (fixed_node.position.y + (50 + fixed_node.frame.height) * multiplier)
|
104
|
+
|
105
|
+
return true if (self.position.x == x) && (self.position.y == y)
|
106
|
+
return false
|
107
|
+
end
|
108
|
+
|
72
109
|
def assert_item_has_node_item_view_support(item)
|
73
110
|
if not item.respond_to? :has_node_item_view_support
|
74
111
|
raise ArgumentError.new "The item passed in must have node item view support (#{NodeItemViewSupport})"
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module SCUI
|
3
8
|
module Mixins
|
@@ -7,11 +12,36 @@ module Lebowski
|
|
7
12
|
return true
|
8
13
|
end
|
9
14
|
|
15
|
+
def terminal_name
|
16
|
+
@terminal_name = self['terminal'] if @terminal_name.nil?
|
17
|
+
return @terminal_name
|
18
|
+
end
|
19
|
+
|
10
20
|
def link_to(end_term, x = 0, y = 0)
|
11
21
|
assert_item_has_terminal_view_support(end_term)
|
12
22
|
self.drag_to(end_term, x, y)
|
13
23
|
end
|
14
24
|
|
25
|
+
def linked_to?(terminal)
|
26
|
+
assert_item_has_terminal_view_support(terminal)
|
27
|
+
|
28
|
+
terminal_parent_node = terminal.parent['content']
|
29
|
+
my_parent_node = self.parent['content']
|
30
|
+
|
31
|
+
self.parent.links.each do |link|
|
32
|
+
return true if (link.start_node == terminal_parent_node) && (link.start_terminal == terminal.terminal_name) && (link.end_terminal == self.terminal_name)
|
33
|
+
return true if (link.end_node == terminal_parent_node) && (link.end_terminal == terminal.terminal_name) && (link.start_terminal == self.terminal_name)
|
34
|
+
end
|
35
|
+
|
36
|
+
terminal.parent.links.each do |link|
|
37
|
+
return true if (link.start_node == my_parent_node) && (link.start_terminal == self.terminal_name) && (link.end_terminal == terminal.terminal_name)
|
38
|
+
return true if (link.end_node == my_parent_node) && (link.end_terminal == self.terminal_name) && (link.start_terminal == terminal.terminal_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
|
44
|
+
|
15
45
|
private
|
16
46
|
def assert_item_has_terminal_view_support(item)
|
17
47
|
if not item.respond_to? :has_terminal_view_support
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
6
|
+
module Lebowski
|
7
|
+
module SCUI
|
8
|
+
module Views
|
9
|
+
|
10
|
+
#
|
11
|
+
# Represents a proxy to a SCUI color well view (SCUI.ColorWell)
|
12
|
+
#
|
13
|
+
class ColorWellView < Lebowski::Foundation::Views::View
|
14
|
+
representing_sc_class 'SCUI.ColorWell'
|
15
|
+
|
16
|
+
COLORS = { :red => '#ff0000', :green => '#00ff00', :blue => '#0000ff', :orange => '#ff6600',
|
17
|
+
:yellow => '#ffff00', :violet => '#8f00ff', :gray => '#999999', :black => '#000000', :white => '#ffffff' }
|
18
|
+
|
19
|
+
def color_selected?
|
20
|
+
return (not (text_box.value.nil? || text_box.value =='#eee'))
|
21
|
+
end
|
22
|
+
|
23
|
+
def color?(value)
|
24
|
+
value = COLORS[value] if value.kind_of? Symbol
|
25
|
+
return (text_box.value == value)
|
26
|
+
end
|
27
|
+
|
28
|
+
def select_color(value)
|
29
|
+
value = COLORS[value] if value.kind_of? Symbol
|
30
|
+
raise ArgumentError.new "The color value must be either a symbol or a string." if not value.kind_of? String
|
31
|
+
text_box.type value
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def text_box
|
36
|
+
@text_box = picker_pane['contentView.textBox'] if @text_box.nil?
|
37
|
+
return @text_box
|
38
|
+
end
|
39
|
+
|
40
|
+
def picker_pane
|
41
|
+
@picker_pane = self['_pickerPane'] if @picker_pane.nil?
|
42
|
+
return @picker_pane
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,86 +1,17 @@
|
|
1
|
+
# ==========================================================================
|
2
|
+
# Project: Lebowski Framework - The SproutCore Test Automation Framework
|
3
|
+
# License: Licensed under MIT license (see License.txt)
|
4
|
+
# ==========================================================================
|
5
|
+
|
1
6
|
module Lebowski
|
2
7
|
module SCUI
|
3
8
|
module Views
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(parent)
|
9
|
-
@parent = parent
|
10
|
-
@list_pane = parent['_listPane']
|
11
|
-
|
12
|
-
list_view_path = 'contentView.listView.contentView'
|
13
|
-
if not @list_pane.sc_path_defined?(list_view_path)
|
14
|
-
# revert to the old path to access the list view
|
15
|
-
list_view_path = 'contentView.contentView'
|
16
|
-
end
|
17
|
-
|
18
|
-
@value_key = @list_pane["#{list_view_path}.contentValueKey"]
|
19
|
-
@item_views = @list_pane[list_view_path].item_views
|
20
|
-
end
|
21
|
-
|
22
|
-
def count?(expected_count, item)
|
23
|
-
type(item)
|
24
|
-
return (@item_views.count == expected_count)
|
25
|
-
end
|
26
|
-
|
27
|
-
def any?(item)
|
28
|
-
type(item)
|
29
|
-
return @item_views.any?({@value_key => item})
|
30
|
-
end
|
31
|
-
|
32
|
-
alias_method :some?, :any?
|
33
|
-
|
34
|
-
def one?(item)
|
35
|
-
type(item)
|
36
|
-
return @item_views.one?({@value_key => item})
|
37
|
-
end
|
38
|
-
|
39
|
-
def none?(item)
|
40
|
-
type(item)
|
41
|
-
@item_views.none?({@value_key => item})
|
42
|
-
end
|
43
|
-
|
44
|
-
def list_displayed?
|
45
|
-
return @list_pane.isPaneAttached
|
46
|
-
end
|
47
|
-
|
48
|
-
def select_item(item)
|
49
|
-
@parent.display_list
|
50
|
-
if item.kind_of? Integer
|
51
|
-
select_item_by_index(item)
|
52
|
-
elsif item.kind_of? String
|
53
|
-
select_item_by_name(/^#{item}/i)
|
54
|
-
elsif item.kind_of? Regexp
|
55
|
-
select_item_by_name(item)
|
56
|
-
end
|
57
|
-
@parent.hide_list
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
def select_item_by_index(index)
|
62
|
-
raise ArgumentError.new "Index out of range. The item number must be greater than or equal to zero." if (index < 0)
|
63
|
-
raise ArgumentError.new "Index out of range. There are fewer than #{index.to_s} items in the list." if (index >= @item_views.count)
|
64
|
-
@item_views[index].select
|
65
|
-
end
|
66
|
-
|
67
|
-
def select_item_by_name(name)
|
68
|
-
if one?(name)
|
69
|
-
@item_views.find_first({@value_key => name}).select
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def type(text)
|
74
|
-
field = @parent.child_views[0]
|
75
|
-
if text.kind_of? Regexp
|
76
|
-
field.type_keys(text.inspect.tr('/^', '').tr('/i', ''))
|
77
|
-
else
|
78
|
-
field.type_keys(text)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
10
|
+
#
|
11
|
+
# Represents a proxy to a SCUI combo box view (SCUI.ComboBoxView)
|
12
|
+
#
|
83
13
|
class ComboBoxView < Lebowski::Foundation::Views::View
|
14
|
+
|
84
15
|
representing_sc_class 'SCUI.ComboBoxView'
|
85
16
|
|
86
17
|
def empty?
|
@@ -89,15 +20,15 @@ module Lebowski
|
|
89
20
|
end
|
90
21
|
|
91
22
|
def display_list
|
92
|
-
click_button if !
|
23
|
+
click_button if !list_displayed?
|
93
24
|
end
|
94
25
|
|
95
26
|
def hide_list
|
96
|
-
click_button if
|
27
|
+
click_button if list_displayed?
|
97
28
|
end
|
98
|
-
|
29
|
+
|
99
30
|
def list_displayed?
|
100
|
-
return
|
31
|
+
return list_pane.isPaneAttached
|
101
32
|
end
|
102
33
|
|
103
34
|
def select_item(item)
|
@@ -105,15 +36,87 @@ module Lebowski
|
|
105
36
|
end
|
106
37
|
|
107
38
|
def list
|
108
|
-
|
39
|
+
if @list.nil?
|
40
|
+
if sc_path_defined?('_listPane.contentView.listView.contentView')
|
41
|
+
@list = ComboBoxList.new(self, '_listPane.contentView.listView.contentView', @driver)
|
42
|
+
else
|
43
|
+
@list = ComboBoxList.new(self, '_listPane.contentView.contentView', @driver)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return @list
|
109
47
|
end
|
110
48
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
49
|
+
private
|
50
|
+
def list_pane
|
51
|
+
@list_pane = self['_listPane'] if @list_pane.nil?
|
52
|
+
return @list_pane
|
53
|
+
end
|
54
|
+
|
55
|
+
def click_button
|
56
|
+
self['dropDownButtonView'].click
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
class ComboBoxList < Lebowski::Foundation::Views::ListView
|
63
|
+
|
64
|
+
def count?(expected_count, item)
|
65
|
+
type(item)
|
66
|
+
return (item_views.count == expected_count)
|
67
|
+
end
|
68
|
+
|
69
|
+
def any?(item)
|
70
|
+
type(item)
|
71
|
+
return item_views.any?({value_key => /#{item}/i})
|
72
|
+
end
|
73
|
+
|
74
|
+
alias_method :some?, :any?
|
75
|
+
|
76
|
+
def one?(item)
|
77
|
+
type(item)
|
78
|
+
return item_views.one?({value_key => /#{item}/i})
|
79
|
+
end
|
80
|
+
|
81
|
+
def none?(item)
|
82
|
+
type(item)
|
83
|
+
item_views.none?({value_key => /#{item}/i})
|
84
|
+
end
|
85
|
+
|
86
|
+
def select_item(item)
|
87
|
+
@parent.display_list
|
88
|
+
if item.kind_of? Integer
|
89
|
+
select_item_by_index(item)
|
90
|
+
elsif item.kind_of? String
|
91
|
+
select_item_by_name(item)
|
92
|
+
else
|
93
|
+
raise ArgumentError.new "The argument must be either an integer or a string."
|
94
|
+
end
|
95
|
+
@parent.hide_list
|
115
96
|
end
|
116
97
|
|
98
|
+
private
|
99
|
+
def value_key
|
100
|
+
@value_key = self['contentValueKey'] if @value_key.nil?
|
101
|
+
return @value_key
|
102
|
+
end
|
103
|
+
|
104
|
+
def select_item_by_index(index)
|
105
|
+
raise ArgumentError.new "Index out of range. The item number must be greater than or equal to zero." if (index < 0)
|
106
|
+
raise ArgumentError.new "Index out of range. There are fewer than #{index.to_s} items in the list." if (index >= item_views.count)
|
107
|
+
item_views[index].select
|
108
|
+
end
|
109
|
+
|
110
|
+
def select_item_by_name(name)
|
111
|
+
if any?(name)
|
112
|
+
item_views.find_first({value_key => /#{name}/i}).select
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def type(text)
|
117
|
+
@parent.child_views[0].type_keys(text)
|
118
|
+
end
|
117
119
|
end
|
120
|
+
|
118
121
|
end
|
119
122
|
end
|