gametel 0.5 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/features/button.feature +38 -0
  2. data/features/main_screen.feature +4 -0
  3. data/features/progress.feature +25 -0
  4. data/features/radio_button.feature +7 -0
  5. data/features/spinners.feature +5 -1
  6. data/features/step_definitions/checkbox_steps.rb +4 -1
  7. data/features/step_definitions/controls_steps.rb +7 -0
  8. data/features/step_definitions/main_screen_steps.rb +7 -0
  9. data/features/step_definitions/progress_steps.rb +34 -0
  10. data/features/step_definitions/radio_button_steps.rb +5 -0
  11. data/features/step_definitions/text_steps.rb +19 -0
  12. data/features/step_definitions/view_steps.rb +11 -2
  13. data/features/support/ApiDemos.apk +0 -0
  14. data/features/support/debug.keystore +0 -0
  15. data/features/support/env.rb +2 -2
  16. data/features/support/screens/buttons_screen.rb +1 -1
  17. data/features/support/screens/controls_screen.rb +8 -0
  18. data/features/support/screens/seek_bar_screen.rb +6 -0
  19. data/features/text.feature +31 -0
  20. data/features/view.feature +13 -2
  21. data/lib/gametel.rb +35 -0
  22. data/lib/gametel/accessors.rb +54 -8
  23. data/lib/gametel/platforms/brazenhead/basic.rb +1 -3
  24. data/lib/gametel/platforms/brazenhead/button.rb +42 -0
  25. data/lib/gametel/platforms/brazenhead/progress.rb +102 -0
  26. data/lib/gametel/platforms/brazenhead/spinner.rb +8 -3
  27. data/lib/gametel/platforms/brazenhead/text.rb +16 -10
  28. data/lib/gametel/platforms/brazenhead/view.rb +12 -4
  29. data/lib/gametel/platforms/brazenhead_platform.rb +29 -7
  30. data/lib/gametel/version.rb +1 -1
  31. data/lib/gametel/views.rb +5 -0
  32. data/lib/gametel/views/button.rb +30 -0
  33. data/lib/gametel/views/checkbox.rb +21 -0
  34. data/lib/gametel/views/radio_button.rb +20 -0
  35. data/lib/gametel/views/text.rb +15 -0
  36. data/lib/gametel/views/view.rb +33 -0
  37. data/spec/lib/gametel/accessors_spec.rb +477 -27
  38. data/spec/lib/gametel_spec.rb +23 -0
  39. metadata +26 -8
  40. data/features/support/screens/custom_views_screen.rb +0 -7
@@ -12,6 +12,11 @@ Feature: Interacting with buttons
12
12
  Given I'm on the buttons screen
13
13
  When I click the on/off button by "id"
14
14
  Then I should see the text "ON" on the screen
15
+
16
+ Scenario: Should be able to click a button by id
17
+ Given I'm on the buttons screen
18
+ When I click the on/off button by "index"
19
+ Then I should see the text "ON" on the screen
15
20
 
16
21
  Scenario: Should be able to click a toggle button
17
22
  Given I'm on the buttons screen
@@ -19,3 +24,36 @@ Feature: Interacting with buttons
19
24
  Then I should see the text "ON" on the screen
20
25
  When I click the on/off button
21
26
  Then I should see the text "OFF" on the screen
27
+
28
+ Scenario: Determining properties of a button by id
29
+ When I'm on the controls screen
30
+ Then the "button" field identified by "id" can determine the following properties:
31
+ | property | value |
32
+ | clickable | true |
33
+ | enabled | true |
34
+ | focusable | true |
35
+ | focused | false |
36
+ | selected | false |
37
+ | shown | true |
38
+
39
+ Scenario: Determining properties of a button by index
40
+ When I'm on the controls screen
41
+ Then the "button" field identified by "index" can determine the following properties:
42
+ | property | value |
43
+ | clickable | true |
44
+ | enabled | false |
45
+ | focusable | true |
46
+ | focused | false |
47
+ | selected | false |
48
+ | shown | true |
49
+
50
+ Scenario: Determining properties of a button by text
51
+ When I'm on the controls screen
52
+ Then the "button" field identified by "text" can determine the following properties:
53
+ | property | value |
54
+ | clickable | true |
55
+ | enabled | false |
56
+ | focusable | true |
57
+ | focused | false |
58
+ | selected | false |
59
+ | shown | true |
@@ -21,3 +21,7 @@ Feature: Interacting with the elements on the main screen
21
21
  When I hit the enter key
22
22
  Then I should see the "Accessibility Service" list item
23
23
 
24
+ Scenario: Navigating back to a particular activity and knowing where we are at
25
+ Given I'm on the buttons screen
26
+ When I go choose to go back to the "ApiDemos" activity
27
+ Then I should currently be on the "ApiDemos" activity
@@ -0,0 +1,25 @@
1
+ Feature: Interacting with progress bars
2
+
3
+ Scenario: Getting and setting the progress by id
4
+ Given I am looking at the progress of a seek bar
5
+ When I set the progress indicated by "id" to "37"
6
+ Then I should see the text "37 from touch" on the screen
7
+ And the retrieved progress indicated by "id" should be "37"
8
+
9
+ Scenario: Getting and setting the progress by index
10
+ Given I am looking at the progress of a seek bar
11
+ When I set the progress indicated by "index" to "11"
12
+ Then the retrieved progress indicated by "index" should be "11"
13
+
14
+ Scenario: Getting and setting the secondary progress by id
15
+ Given I am looking at the progress of a seek bar
16
+ When I set the secondary progress indicated by "id" to "74"
17
+ And the retrieved secondary progress indicated by "id" should be "74"
18
+
19
+ Scenario: Getting the progress max by id
20
+ When I am looking at the progress of a seek bar
21
+ Then the retrieved progress max indicated by "id" should be "100"
22
+
23
+ Scenario: Getting the progress max by index
24
+ When I am looking at the progress of a seek bar
25
+ Then the retrieved progress max indicated by "index" should be "100"
@@ -3,7 +3,14 @@ Feature: Interacting with Radio Buttons
3
3
  Scenario: Clicking on a radio button by text
4
4
  Given I'm on the controls screen
5
5
  Then I should be able to click a radio button by "text"
6
+ And the radio button identified by "text" should be checked
6
7
 
7
8
  Scenario: Clicking on a radio button by id
8
9
  Given I'm on the controls screen
9
10
  Then I should be able to click a radio button by "id"
11
+ And the radio button identified by "id" should be checked
12
+
13
+ Scenario: Clicking on a radio button by index
14
+ Given I'm on the controls screen
15
+ Then I should be able to click a radio button by "index"
16
+ And the radio button identified by "index" should be checked
@@ -1,5 +1,9 @@
1
1
  Feature: Working with Spinners
2
2
 
3
- Scenario: Retrieving the selected Spinner text
3
+ Scenario: Retrieving the selected Spinner text by id
4
4
  When I'm on the controls screen
5
5
  Then I can see the spinner value referenced by "id" is "Mercury"
6
+
7
+ Scenario: Retrieving the selected Spinner text by index
8
+ When I'm on the controls screen
9
+ Then I can see the spinner value referenced by "index" is "Mercury"
@@ -1,3 +1,6 @@
1
1
  Then /^I should be able to click a checkbox by "(.*?)"$/ do |how|
2
- on(ControlsScreen).send "checkbox_#{how}"
2
+ on(ControlsScreen) do |screen|
3
+ screen.send "checkbox_#{how}"
4
+ screen.send("checkbox_#{how}_view").should be_checked
5
+ end
3
6
  end
@@ -32,3 +32,10 @@ Then /^I should have the value "(.*?)" in the text field identified by "(.*?)"$/
32
32
  screen.send("text_field_#{how}").should eq(text_value)
33
33
  end
34
34
  end
35
+
36
+ Then /^the "(.*?)" field\'s "(.*?)" property is "(.*?)"$/ do |which, what, result|
37
+ on(ControlsScreen) do |screen|
38
+ view = screen.send("#{which}_field_id_view")
39
+ view.send("#{what}?").to_s.should == result
40
+ end
41
+ end
@@ -25,3 +25,10 @@ When /^I hit the enter key$/ do
25
25
  on(MainMenuScreen).enter
26
26
  end
27
27
 
28
+ When /^I go choose to go back to the "(.*?)" activity$/ do |activity|
29
+ on(MainMenuScreen).back_to activity
30
+ end
31
+
32
+ Then /^I should currently be on the "(.*?)" activity$/ do |activity|
33
+ on(MainMenuScreen).current_activity.should eq(activity)
34
+ end
@@ -0,0 +1,34 @@
1
+ Given /^I am looking at the progress of a seek bar$/ do
2
+ on(MainMenuScreen).views
3
+ on(ViewsMenuScreen).seek_bar
4
+ end
5
+
6
+ When /^I set the progress indicated by "(.*?)" to "(.*?)"$/ do |how, value|
7
+ on(SeekBarScreen) do |screen|
8
+ screen.send "progress_#{how}=", value.to_i
9
+ end
10
+ end
11
+
12
+ Then /^the retrieved progress indicated by "(.*?)" should be "(.*?)"$/ do |how, value|
13
+ on(SeekBarScreen) do |screen|
14
+ screen.send("progress_#{how}").should eq(value.to_i)
15
+ end
16
+ end
17
+
18
+ When /^I set the secondary progress indicated by "(.*?)" to "(.*?)"$/ do |how, value|
19
+ on(SeekBarScreen) do |screen|
20
+ screen.send "progress_#{how}_secondary=", value.to_i
21
+ end
22
+ end
23
+
24
+ When /^the retrieved secondary progress indicated by "(.*?)" should be "(.*?)"$/ do |how, value|
25
+ on(SeekBarScreen) do |screen|
26
+ screen.send("progress_#{how}_secondary").should eq(value.to_i)
27
+ end
28
+ end
29
+
30
+ Then /^the retrieved progress max indicated by "(.*?)" should be "(.*?)"$/ do |how, value|
31
+ on(SeekBarScreen) do |screen|
32
+ screen.send("progress_#{how}_max").should eq(value.to_i)
33
+ end
34
+ end
@@ -1,3 +1,8 @@
1
1
  Then /^I should be able to click a radio button by "(.*?)"$/ do |how|
2
2
  on(ControlsScreen).send "radio_button_#{how}"
3
3
  end
4
+
5
+ Then /^the radio button identified by "(.*?)" should be checked$/ do |how|
6
+ on(ControlsScreen).send("radio_button_#{how}_view").should be_checked
7
+ end
8
+
@@ -0,0 +1,19 @@
1
+ When /^I\'m on the search view filter screen$/ do
2
+ on(MainMenuScreen).views
3
+ on(ViewsMenuScreen).controls
4
+ on(ControlsMenuScreen).light_theme
5
+ end
6
+
7
+ Then /^I am am given the hint "(.*?)" for the "(.*?)" control$/ do |hint, value|
8
+ on(ControlsScreen) do |screen|
9
+ view = screen.send("#{value}_view")
10
+ view.hint.should == hint
11
+ end
12
+ end
13
+
14
+ Then /^I am am given the description "(.*?)" for the "(.*?)" control$/ do |description, value|
15
+ on(ControlsScreen) do |screen|
16
+ view = screen.send("#{value}_view")
17
+ view.description.should == description
18
+ end
19
+ end
@@ -15,6 +15,15 @@ When /^I am observing custom views$/ do
15
15
  on(ViewsMenuScreen).custom
16
16
  end
17
17
 
18
- Then /^I should see the "(.*?)" custom view$/ do |view_text|
19
- on(CustomViewScreen).send view_text
18
+ Then /^I should be able to click a view by "(.*?)"$/ do |how|
19
+ on(ControlsScreen).send "view_field_#{how}"
20
+ end
21
+
22
+ Then /^the "(.*?)" field identified by "(.*?)" can determine the following properties:$/ do |what, how, properties|
23
+ screen = ControlsScreen.new
24
+ view = screen.send "#{what}_field_#{how}_view"
25
+ properties.hashes.each do |property|
26
+ result = view.send("#{property["property"]}?")
27
+ result.to_s.should eq(property["value"]), "for field #{property["property"]}"
28
+ end
20
29
  end
Binary file
Binary file
@@ -9,13 +9,13 @@ require 'gametel/navigation'
9
9
  World(Gametel::Navigation)
10
10
 
11
11
  keystore = {
12
- :path => '~/.android/debug.keystore',
12
+ :path => 'features/support/debug.keystore',
13
13
  :alias => 'androiddebugkey',
14
14
  :password => 'android',
15
15
  :keystore_password => 'android'
16
16
  }
17
17
 
18
- server = Brazenhead::Server.new('ApiDemos/bin/ApiDemos.apk', keystore)
18
+ server = Brazenhead::Server.new('features/support/ApiDemos.apk', keystore)
19
19
 
20
20
  class Driver
21
21
  include Brazenhead
@@ -4,7 +4,7 @@ class ButtonScreen
4
4
  button(:normal_text, :text => 'Normal')
5
5
  button(:normal_index, :index => 0)
6
6
  button(:small, :text => 'Small')
7
- button(:on_off, :index => 2)
7
+ button(:on_off_index, :index => 2)
8
8
  button(:on_off_id, :id => 'button_toggle')
9
9
 
10
10
  end
@@ -4,12 +4,20 @@ class ControlsScreen
4
4
  text(:text_field_index, :index => 0)
5
5
  text(:text_field_id, :id => 'edit')
6
6
  text(:text_field_name, :content_description => 'Edit Description')
7
+ view(:view_field_id, :id => 'edit')
8
+ view(:view_field_text, :text => 'textColorPrimary')
9
+ text(:button_field_id, :id => 'button')
10
+ text(:button_disabled_field_id, :id => 'button_disabled')
7
11
  button(:enabled_save, :index => 0)
8
12
  button(:disabled_save, :index => 1)
13
+ button(:button_field_index, :index => 1)
14
+ button(:button_field_text, :text => 'Save')
9
15
  checkbox(:checkbox_index, :index => 0)
10
16
  checkbox(:checkbox_text, :text => 'Checkbox 2')
11
17
  checkbox(:checkbox_id, :id => 'check1')
12
18
  radio_button(:radio_button_text, :text => 'RadioButton 1')
13
19
  radio_button(:radio_button_id, :id => 'radio2')
20
+ radio_button(:radio_button_index, :index => 1)
14
21
  spinner(:spinner_id, :id => 'spinner1')
22
+ spinner(:spinner_index, :index => 0)
15
23
  end
@@ -0,0 +1,6 @@
1
+ class SeekBarScreen
2
+ include Gametel
3
+
4
+ progress(:progress_id, :id => 'seek')
5
+ progress(:progress_index, :index => 1)
6
+ end
@@ -24,7 +24,38 @@ Feature: Interacting with the standard text field
24
24
  When I clear the text from the text field identified by "id"
25
25
  Then I should not have the value "example text" on the control screen
26
26
 
27
+ Scenario: Retrieving the hint text identified by id
28
+ When I'm on the search view filter screen
29
+ Then I am am given the hint "Some Hint Text" for the "text_field_id" control
30
+
31
+ Scenario: Retrieving the content description text identified by id
32
+ When I'm on the search view filter screen
33
+ Then I am am given the description "Edit Description" for the "text_field_id" control
34
+
27
35
  Scenario: Retrieving text identified by index
28
36
  Given I'm on the controls screen
29
37
  When I enter "example text" into the text field identified by "id"
30
38
  Then I should have the value "example text" in the text field identified by "id"
39
+
40
+ Scenario: Determining if a text view is enabled
41
+ When I'm on the controls screen
42
+ Then the "text" field's "enabled" property is "true"
43
+
44
+ Scenario: Determining if a button view is enabled
45
+ When I'm on the controls screen
46
+ Then the "button" field's "enabled" property is "true"
47
+
48
+ Scenario: Determining if a button view is disabled
49
+ When I'm on the controls screen
50
+ Then the "button_disabled" field's "enabled" property is "false"
51
+
52
+ Scenario: Determining properties of a text view
53
+ When I'm on the controls screen
54
+ Then the "text" field identified by "id" can determine the following properties:
55
+ | property | value |
56
+ | clickable | true |
57
+ | enabled | true |
58
+ | focusable | true |
59
+ | focused | true |
60
+ | selected | false |
61
+ | shown | true |
@@ -6,5 +6,16 @@ Feature: Interacting with view elements
6
6
  Then I should see the "Command one" list item
7
7
 
8
8
  Scenario: Clicking on view by their text
9
- When I am observing custom views
10
- Then I should see the "blue" custom view
9
+ When I'm on the controls screen
10
+ Then I should be able to click a view by "text"
11
+
12
+ Scenario: Determining properties of a view
13
+ When I'm on the controls screen
14
+ Then the "view" field identified by "id" can determine the following properties:
15
+ | property | value |
16
+ | clickable | true |
17
+ | enabled | true |
18
+ | focusable | true |
19
+ | focused | true |
20
+ | selected | false |
21
+ | shown | true |
data/lib/gametel.rb CHANGED
@@ -2,11 +2,15 @@ require 'gametel/accessors'
2
2
  require 'gametel/navigation'
3
3
  require 'gametel/version'
4
4
  require 'gametel/platforms/brazenhead_platform'
5
+ require 'gametel/views'
5
6
 
6
7
  module Gametel
7
8
 
8
9
  attr_reader :platform
9
10
 
11
+ ROBOTIUM_LEFT = 21
12
+ ROBOTIUM_RIGHT = 22
13
+
10
14
  def self.included(cls)
11
15
  cls.extend Gametel::Accessors
12
16
  end
@@ -43,6 +47,23 @@ module Gametel
43
47
  platform.back
44
48
  end
45
49
 
50
+ #
51
+ # Go back to a specific activity
52
+ #
53
+ def back_to(activity)
54
+ platform.go_back_to_activity activity
55
+ end
56
+
57
+ def current_activity
58
+ platform.chain_calls do |device|
59
+ device.get_current_activity
60
+ device.get_class
61
+ device.get_simple_name
62
+ end
63
+
64
+ platform.last_response.body.gsub('"','')
65
+ end
66
+
46
67
  #
47
68
  # Press the enter key
48
69
  #
@@ -63,6 +84,20 @@ module Gametel
63
84
  def scroll_up
64
85
  platform.scroll_up
65
86
  end
87
+
88
+ #
89
+ # scroll left
90
+ #
91
+ def scroll_left
92
+ platform.scroll_to_side ROBOTIUM_LEFT
93
+ end
94
+
95
+ #
96
+ # scroll right
97
+ #
98
+ def scroll_right
99
+ platform.scroll_to_side ROBOTIUM_RIGHT
100
+ end
66
101
 
67
102
  #
68
103
  # Wait for the provided text to appear
@@ -1,12 +1,12 @@
1
1
  module Gametel
2
2
  module Accessors
3
3
  #
4
- # Generates two method to enter text into a text field and to
5
- # clear the text field
4
+ # Generates methods to enter text into a text field, clear the text
5
+ # field, get the hint as well as the description
6
6
  #
7
7
  # @example
8
8
  # text(:first_name, :index => 0)
9
- # # will generate 'first_name', 'first_name=' and 'clear_first_name' methods
9
+ # # will generate 'first_name', 'first_name=', 'clear_first_name', 'first_name_hint' and 'first_name_description' methods
10
10
  #
11
11
  # @param [String] the name used for the generated methods
12
12
  # @param [Hash] locator for how the text is found The valid
@@ -22,16 +22,19 @@ module Gametel
22
22
  platform.enter_text(value, locator)
23
23
  end
24
24
  define_method("clear_#{name}") do
25
- platform.clear_text(locator)
25
+ platform.clear_text(locator)
26
+ end
27
+ define_method("#{name}_view") do
28
+ Gametel::Views::Text.new(platform, locator)
26
29
  end
27
30
  end
28
31
 
29
32
  #
30
- # Generates one method to click a button.
33
+ # Generates a method to click a button and determine if it is enabled.
31
34
  #
32
35
  # @example
33
36
  # button(:save, :text => 'Save')
34
- # # will generate 'save' method
37
+ # # will generate 'save' and 'save_enabled?' methods
35
38
  #
36
39
  # @param [String] the name used for the generated methods
37
40
  # @param [Hash] locator for how the button is found The valid
@@ -44,6 +47,9 @@ module Gametel
44
47
  define_method(name) do
45
48
  platform.press_button(locator)
46
49
  end
50
+ define_method("#{name}_view") do
51
+ Gametel::Views::Button.new(platform, locator)
52
+ end
47
53
  end
48
54
 
49
55
  #
@@ -95,6 +101,9 @@ module Gametel
95
101
  define_method(name) do
96
102
  platform.click_checkbox(locator)
97
103
  end
104
+ define_method("#{name}_view") do
105
+ Gametel::Views::CheckBox.new(platform, locator)
106
+ end
98
107
  end
99
108
 
100
109
  #
@@ -108,12 +117,16 @@ module Gametel
108
117
  # @param [Hash] locator for how the checkbox is found The valid
109
118
  # keys are:
110
119
  # * :text
120
+ # * :index
111
121
  # * :id
112
122
  #
113
123
  def radio_button(name, locator)
114
124
  define_method(name) do
115
125
  platform.click_radio_button(locator)
116
126
  end
127
+ define_method("#{name}_view") do
128
+ Gametel::Views::RadioButton.new(platform, locator)
129
+ end
117
130
  end
118
131
 
119
132
  #
@@ -131,6 +144,39 @@ module Gametel
131
144
  define_method(name) do
132
145
  platform.click_view(locator)
133
146
  end
147
+ define_method("#{name}_view") do
148
+ Gametel::Views::View.new(platform, locator)
149
+ end
150
+ end
151
+
152
+ #
153
+ # Generates methods to get an set the progress as well as
154
+ # the secondary progress
155
+ # @example
156
+ # spinner(:progress_item, :id => 'id_name_of_your_control')
157
+ # # will generate progress_item, progress_item=, progress_item_secondary, progress_item_secondary=
158
+ #
159
+ # @param [String] the name used for the generated methods
160
+ # @param [Hash] locator indicating an id for how the progress bar is found.
161
+ # The only valid keys are:
162
+ # * :id
163
+ #
164
+ def progress(name, locator)
165
+ define_method("#{name}") do
166
+ platform.get_progress(locator)
167
+ end
168
+ define_method("#{name}_max") do
169
+ platform.get_progress_max(locator)
170
+ end
171
+ define_method("#{name}_secondary") do
172
+ platform.get_secondary_progress(locator)
173
+ end
174
+ define_method("#{name}=") do |value|
175
+ platform.set_progress(locator, value)
176
+ end
177
+ define_method("#{name}_secondary=") do |value|
178
+ platform.set_secondary_progress(locator, value)
179
+ end
134
180
  end
135
181
 
136
182
  #
@@ -146,9 +192,9 @@ module Gametel
146
192
  #
147
193
  def spinner(name, locator)
148
194
  define_method(name) do
149
- platform.get_spinner_value(locator) if locator[:id]
195
+ platform.get_spinner_value(locator)
150
196
  end
151
197
  end
152
198
  end
153
199
  end
154
-
200
+