lebowski 0.1.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.
Files changed (85) hide show
  1. data/History.md +3 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +84 -0
  4. data/README.md +146 -0
  5. data/Rakefile +42 -0
  6. data/bin/lebowski +26 -0
  7. data/bin/lebowski-spec +29 -0
  8. data/bin/lebowski-start-server +24 -0
  9. data/lib/lebowski.rb +15 -0
  10. data/lib/lebowski/core.rb +35 -0
  11. data/lib/lebowski/foundation.rb +52 -0
  12. data/lib/lebowski/foundation/application.rb +315 -0
  13. data/lib/lebowski/foundation/core.rb +61 -0
  14. data/lib/lebowski/foundation/core_query.rb +231 -0
  15. data/lib/lebowski/foundation/dom_element.rb +114 -0
  16. data/lib/lebowski/foundation/errors/argument_invalid_type.rb +31 -0
  17. data/lib/lebowski/foundation/errors/unexpected_type.rb +30 -0
  18. data/lib/lebowski/foundation/mixins/collection_item_view_support.rb +87 -0
  19. data/lib/lebowski/foundation/mixins/delegate_support.rb +22 -0
  20. data/lib/lebowski/foundation/mixins/inline_text_field_support.rb +29 -0
  21. data/lib/lebowski/foundation/mixins/key_check.rb +35 -0
  22. data/lib/lebowski/foundation/mixins/list_item_view_support.rb +36 -0
  23. data/lib/lebowski/foundation/mixins/positioned_element.rb +20 -0
  24. data/lib/lebowski/foundation/mixins/stall_support.rb +79 -0
  25. data/lib/lebowski/foundation/mixins/user_actions.rb +302 -0
  26. data/lib/lebowski/foundation/mixins/wait_actions.rb +44 -0
  27. data/lib/lebowski/foundation/object_array.rb +305 -0
  28. data/lib/lebowski/foundation/panes/alert.rb +117 -0
  29. data/lib/lebowski/foundation/panes/main.rb +20 -0
  30. data/lib/lebowski/foundation/panes/menu.rb +100 -0
  31. data/lib/lebowski/foundation/panes/modal.rb +21 -0
  32. data/lib/lebowski/foundation/panes/palette.rb +21 -0
  33. data/lib/lebowski/foundation/panes/pane.rb +24 -0
  34. data/lib/lebowski/foundation/panes/panel.rb +25 -0
  35. data/lib/lebowski/foundation/panes/picker.rb +43 -0
  36. data/lib/lebowski/foundation/panes/sheet.rb +21 -0
  37. data/lib/lebowski/foundation/proxy_factory.rb +87 -0
  38. data/lib/lebowski/foundation/proxy_object.rb +670 -0
  39. data/lib/lebowski/foundation/sc_object.rb +38 -0
  40. data/lib/lebowski/foundation/views/button.rb +20 -0
  41. data/lib/lebowski/foundation/views/checkbox.rb +63 -0
  42. data/lib/lebowski/foundation/views/collection.rb +304 -0
  43. data/lib/lebowski/foundation/views/container.rb +32 -0
  44. data/lib/lebowski/foundation/views/disclosure.rb +59 -0
  45. data/lib/lebowski/foundation/views/grid.rb +21 -0
  46. data/lib/lebowski/foundation/views/label.rb +30 -0
  47. data/lib/lebowski/foundation/views/list.rb +67 -0
  48. data/lib/lebowski/foundation/views/list_item.rb +280 -0
  49. data/lib/lebowski/foundation/views/menu_item.rb +27 -0
  50. data/lib/lebowski/foundation/views/radio.rb +32 -0
  51. data/lib/lebowski/foundation/views/segmented.rb +97 -0
  52. data/lib/lebowski/foundation/views/select_field.rb +139 -0
  53. data/lib/lebowski/foundation/views/support/simple_item_array.rb +249 -0
  54. data/lib/lebowski/foundation/views/text_field.rb +108 -0
  55. data/lib/lebowski/foundation/views/view.rb +108 -0
  56. data/lib/lebowski/runtime.rb +7 -0
  57. data/lib/lebowski/runtime/errors/remote_control_command_execution_error.rb +9 -0
  58. data/lib/lebowski/runtime/errors/remote_control_command_timeout_error.rb +9 -0
  59. data/lib/lebowski/runtime/errors/remote_control_error.rb +9 -0
  60. data/lib/lebowski/runtime/errors/selenium_server_error.rb +9 -0
  61. data/lib/lebowski/runtime/object_encoder.rb +123 -0
  62. data/lib/lebowski/runtime/sprout_core_driver.rb +14 -0
  63. data/lib/lebowski/runtime/sprout_core_extensions.rb +600 -0
  64. data/lib/lebowski/scui.rb +18 -0
  65. data/lib/lebowski/scui/mixins/node_item_view_support.rb +136 -0
  66. data/lib/lebowski/scui/mixins/terminal_view_support.rb +25 -0
  67. data/lib/lebowski/scui/views/combo_box.rb +119 -0
  68. data/lib/lebowski/scui/views/date_picker.rb +148 -0
  69. data/lib/lebowski/scui/views/linkit.rb +36 -0
  70. data/lib/lebowski/spec.rb +17 -0
  71. data/lib/lebowski/spec/core.rb +21 -0
  72. data/lib/lebowski/spec/matchers/be.rb +63 -0
  73. data/lib/lebowski/spec/matchers/has.rb +40 -0
  74. data/lib/lebowski/spec/matchers/match_supporters/has_object_function.rb +67 -0
  75. data/lib/lebowski/spec/matchers/match_supporters/has_predicate_with_no_prefix.rb +50 -0
  76. data/lib/lebowski/spec/matchers/match_supporters/has_predicate_with_prefix_has.rb +50 -0
  77. data/lib/lebowski/spec/matchers/match_supporters/match_supporter.rb +29 -0
  78. data/lib/lebowski/spec/matchers/method_missing.rb +24 -0
  79. data/lib/lebowski/spec/operators/operator.rb +20 -0
  80. data/lib/lebowski/spec/operators/that.rb +116 -0
  81. data/lib/lebowski/spec/util.rb +26 -0
  82. data/lib/lebowski/version.rb +17 -0
  83. data/resources/selenium-server.jar +0 -0
  84. data/resources/user-extensions.js +1421 -0
  85. metadata +198 -0
@@ -0,0 +1,117 @@
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 Foundation
8
+
9
+ SC_BUTTON1_STATUS = 'button1'
10
+ SC_BUTTON2_STATUS = 'button2'
11
+ SC_BUTTON3_STATUS = 'button3'
12
+
13
+ module Panes
14
+
15
+ #
16
+ # Represents a proxy to a SproutCore alert pane (SC.AlertPane)
17
+ #
18
+ class AlertPane < Lebowski::Foundation::Panes::PanelPane
19
+ include Lebowski::Foundation
20
+
21
+ representing_sc_class 'SC.AlertPane'
22
+
23
+ ALERT_TYPE_WARN = 'alert'
24
+ ALERT_TYPE_ERROR = 'error'
25
+ ALERT_TYPE_INFO = 'info'
26
+ ALERT_TYPE_PLAIN = 'blank'
27
+
28
+ ALERT_TYPES = {
29
+ :alert => ALERT_TYPE_WARN,
30
+ :warn => ALERT_TYPE_WARN,
31
+ :error => ALERT_TYPE_ERROR,
32
+ :info => ALERT_TYPE_INFO,
33
+ :plain => ALERT_TYPE_PLAIN
34
+ }
35
+
36
+ ALERT_PROPERTY_TYPE = 'icon'
37
+
38
+ BUTTON_ONE = 'buttonOne'
39
+ BUTTON_TWO = 'buttonTwo'
40
+ BUTTON_THREE = 'buttonThree'
41
+
42
+ BUTTONS = [BUTTON_ONE, BUTTON_TWO, BUTTON_THREE]
43
+
44
+ def type()
45
+ return :alert if is_alert?
46
+ return :error if is_error?
47
+ return :info if is_info?
48
+ return :plain if is_plain?
49
+ return ""
50
+ end
51
+
52
+ def is_type?(key)
53
+ if (not ALERT_TYPES.has_key?(key))
54
+ raise ArgumentError.new "require valid key: #{key}"
55
+ end
56
+
57
+ return (not (self[ALERT_PROPERTY_TYPE] =~ /#{ALERT_TYPES[key]}/i).nil?)
58
+ end
59
+
60
+ def is_alert?()
61
+ return is_type?(:alert)
62
+ end
63
+
64
+ alias_method :is_warn?, :is_alert?
65
+
66
+ def is_error?()
67
+ return is_type?(:error)
68
+ end
69
+
70
+ def is_info?()
71
+ return is_type?(:info)
72
+ end
73
+
74
+ def is_plain?()
75
+ return is_type?(:plain)
76
+ end
77
+
78
+ def button_count()
79
+ counter = 0
80
+ each_button do |button|
81
+ counter = counter.next
82
+ end
83
+ return counter
84
+ end
85
+
86
+ def each_button(&block)
87
+ raise ArgumentError.new "must provide a block" if (not block_given?)
88
+ BUTTONS.each do |button|
89
+ btn = self[button]
90
+ next if (btn == :undefined)
91
+ next if (not btn['isVisible'])
92
+ yield btn
93
+ end
94
+ end
95
+
96
+ def has_button?(title)
97
+ raise ArgumentError.new "title can not be nil" if title.nil?
98
+ each_button do |button|
99
+ return true if (not (button['title'] =~ /^#{title}$/i).nil?)
100
+ end
101
+ return false
102
+ end
103
+
104
+ def click_button(title)
105
+ raise ArgumentError.new "title can not be nil" if title.nil?
106
+ each_button do |button|
107
+ if not (button['title'] =~ /^#{title}$/i).nil?
108
+ button.click
109
+ return
110
+ end
111
+ end
112
+ end
113
+
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,20 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to a SproutCore main pane (SC.MainPane)
12
+ #
13
+ class MainPane < Lebowski::Foundation::Panes::Pane
14
+
15
+ representing_sc_class 'SC.MainPane'
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,100 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to a SproutCore menu pane (SC.MenuPane)
12
+ #
13
+ class MenuPane < Lebowski::Foundation::Panes::PickerPane
14
+
15
+ representing_sc_class "SC.MenuPane"
16
+
17
+ def menu_items()
18
+ @menu_items = create_menu_item_array if @menu_items.nil?
19
+ return @menu_items
20
+ end
21
+
22
+ protected
23
+
24
+ def create_menu_item_array()
25
+ return Support::MenuItemArray.new(self)
26
+ end
27
+
28
+ end
29
+
30
+ module Support
31
+
32
+ class MenuItemArray < Lebowski::Foundation::ObjectArray
33
+ include Lebowski
34
+
35
+ def initialize(parent, *params)
36
+ super(parent, 'menuItemViews', 'length', *params)
37
+ end
38
+
39
+ def click(title)
40
+ menu_item = nil
41
+ if title.kind_of? String
42
+ menu_item = find_first({ :title => /^#{title}$/i })
43
+ elsif title.kind_of? Regexp
44
+ menu_item = find_first({ :title => title })
45
+ else
46
+ raise ArgumentInvalidTypeError.new "title", title, String, Regexp
47
+ end
48
+ menu_item.click if (not menu_item.nil?)
49
+ end
50
+
51
+ protected
52
+
53
+ def find_indexes_process_filter(filter)
54
+ processed_filter = {}
55
+
56
+ @title_flag = :no_flag
57
+
58
+ filter.each do |key, value|
59
+ case key
60
+ when :title
61
+ @title_flag = value
62
+ else
63
+ processed_filter[key] = value
64
+ end
65
+ end
66
+
67
+ return processed_filter
68
+ end
69
+
70
+ def find_indexes_process_indexes(indexes)
71
+ processed_indexes = []
72
+
73
+ indexes.each do |index|
74
+ if @title_flag != :no_flag
75
+ next if (not menu_item_has_title?(index, @title_flag))
76
+ end
77
+
78
+ processed_indexes << index
79
+ end
80
+
81
+ return processed_indexes
82
+ end
83
+
84
+ private
85
+
86
+ def menu_item_has_title?(index, title)
87
+ menu_item = self[index]
88
+ @valueKey = @parent['itemTitleKey'] if @valueKey.nil?
89
+ value = menu_item["content.#{@valueKey}"]
90
+ return (value =~ title).kind_of?(Integer) if title.kind_of?(Regexp)
91
+ return (value == title)
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,21 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to a SproutCore modal pane (SC.ModalPane)
12
+ #
13
+ class ModalPane < Lebowski::Foundation::Panes::Pane
14
+
15
+ representing_sc_class 'SC.ModalPane'
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to a SproutCore palette pane (SC.PalettePane)
12
+ #
13
+ class PalettePane < Lebowski::Foundation::Panes::PanelPane
14
+
15
+ representing_sc_class 'SC.PalettePane'
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to the root SproutCore pane (SC.Pane)
12
+ #
13
+ class Pane < Lebowski::Foundation::Views::View
14
+
15
+ representing_sc_class 'SC.Pane'
16
+
17
+ def attached?()
18
+ return self['isPaneAttached']
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to a SproutCore panel pane (SC.PanelPane)
12
+ #
13
+ class PanelPane < Lebowski::Foundation::Panes::Pane
14
+
15
+ representing_sc_class 'SC.PanelPane'
16
+
17
+ # @see SC.PanelPane#modalPane
18
+ def modal()
19
+ return self['modalPane']
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,43 @@
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 Foundation
8
+
9
+ # Constants used by the picker pane. see SproutCore file picker.js
10
+ SC_PICKER_MENU = 'menu'
11
+ SC_PICKER_FIXED = 'fixed'
12
+ SC_PICKER_POINTER = 'pointer'
13
+
14
+ module Panes
15
+
16
+ #
17
+ # Represents a proxy to a SproutCore picker pane (SC.PickerPane)
18
+ #
19
+ class PickerPane < Lebowski::Foundation::Panes::PalettePane
20
+
21
+ representing_sc_class 'SC.PickerPane'
22
+
23
+ def is_fixed?()
24
+ return (self['preferType'] == SC_PICKER_FIXED)
25
+ end
26
+
27
+ def is_menu?()
28
+ return (self['preferType'] == SC_PICKER_MENU)
29
+ end
30
+
31
+ def is_pointer?()
32
+ return (self['preferType'] == SC_PICKER_POINTER)
33
+ end
34
+
35
+ def click_off()
36
+ modal.click
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
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 Foundation
8
+ module Panes
9
+
10
+ #
11
+ # Represents a proxy to a SproutCore sheet pane (SC.SheetPane)
12
+ #
13
+ class SheetPane < Lebowski::Foundation::Panes::PanelPane
14
+
15
+ representing_sc_class 'SC.SheetPane'
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,87 @@
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 Foundation
8
+
9
+ module ProxyFactory
10
+
11
+ @@proxies = {}
12
+
13
+ def self.has_key?(key)
14
+ return @@proxies.has_key? key.downcase
15
+ end
16
+
17
+ def self.create_proxy(key, parent, rel_path, driver=nil)
18
+ klass = nil
19
+
20
+ if key.kind_of?(String)
21
+ klass = @@proxies[key.downcase]
22
+ elsif key.kind_of?(Class) and key.ancestors.member?(Lebowski::Foundation::SCObject)
23
+ klass = key
24
+ else
25
+ raise ArgumentError.new "key is an invalid type: #{key}"
26
+ end
27
+
28
+ raise ArgumentError.new "proxy key not recognized: #{key}" if klass.nil?
29
+
30
+ if (parent.nil? and driver.nil?)
31
+ raise ArgumentError.new "must supply a driver either through the parent or driver arguments"
32
+ end
33
+
34
+ driver = driver.nil? ? parent.driver : driver
35
+
36
+ return klass.new(parent, rel_path, driver) if rel_path.kind_of? String
37
+ return klass.new(parent, "#{rel_path}", driver) if rel_path.kind_of? Integer
38
+
39
+ raise ArgumentError.new "rel_path is an invalid type: #{rel_path.class}"
40
+ end
41
+
42
+ def self.proxy(klass)
43
+ if not (klass.kind_of?(Class) and klass.ancestors.member?(Lebowski::Foundation::SCObject))
44
+ raise ArgumentError.new "class must inherit Lebowski::Foundation::Object: #{klass.class}"
45
+ end
46
+
47
+ @@proxies[klass.represented_sc_class.downcase] = klass
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
54
+
55
+ module Lebowski
56
+ module Foundation
57
+
58
+ include Views
59
+ include Panes
60
+
61
+ ProxyFactory.proxy View
62
+ ProxyFactory.proxy LabelView
63
+ ProxyFactory.proxy ButtonView
64
+ ProxyFactory.proxy ContainerView
65
+ ProxyFactory.proxy SegmentedView
66
+ ProxyFactory.proxy RadioView
67
+ ProxyFactory.proxy CheckboxView
68
+ ProxyFactory.proxy DisclosureView
69
+ ProxyFactory.proxy TextFieldView
70
+ ProxyFactory.proxy SelectFieldView
71
+ ProxyFactory.proxy MenuItemView
72
+ ProxyFactory.proxy CollectionView
73
+ ProxyFactory.proxy ListView
74
+ ProxyFactory.proxy ListItemView
75
+
76
+ ProxyFactory.proxy Pane
77
+ ProxyFactory.proxy MainPane
78
+ ProxyFactory.proxy ModalPane
79
+ ProxyFactory.proxy PanelPane
80
+ ProxyFactory.proxy AlertPane
81
+ ProxyFactory.proxy PalettePane
82
+ ProxyFactory.proxy PickerPane
83
+ ProxyFactory.proxy SheetPane
84
+ ProxyFactory.proxy MenuPane
85
+
86
+ end
87
+ end