gametel 0.5.1 → 0.5.2

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.
@@ -0,0 +1,14 @@
1
+ Feature: Navigation through the screens of the application
2
+
3
+ Scenario: Navigating to a screen using the default route
4
+ When I navigate to the Controls screen
5
+ Then I should see the text "Checkbox 1" on the screen
6
+
7
+ Scenario: Navigating to a screen using a named route
8
+ When I navigate to the Buttons screen using the "button_route" route
9
+ Then I should see the text "Views/Buttons" on the screen
10
+
11
+ Scenario: Navigating to a screen starting with a current screen
12
+ Given I am on the the ViewsMenuScreen
13
+ When I navigate to the Controls screen
14
+ Then I should see the text "Checkbox 1" on the screen
@@ -7,3 +7,14 @@ Feature: Working with Spinners
7
7
  Scenario: Retrieving the selected Spinner text by index
8
8
  When I'm on the controls screen
9
9
  Then I can see the spinner value referenced by "index" is "Mercury"
10
+
11
+ Scenario: Setting the selected item in a Spinner by id
12
+ When I'm on the controls screen
13
+ And I select item number "3" from the spinner using "id"
14
+ Then I can see the spinner value referenced by "id" is "Mars"
15
+
16
+ Scenario: Setting the select item in a Spinner by index
17
+ When I'm on the controls screen
18
+ And I select item number "3" from the spinner using "index"
19
+ Then I can see the spinner value referenced by "index" is "Mars"
20
+
@@ -0,0 +1,12 @@
1
+ When /^I navigate to the Controls screen$/ do
2
+ navigate_to(ControlsScreen)
3
+ end
4
+
5
+ When /^I navigate to the Buttons screen using the "(.*?)" route$/ do |route|
6
+ navigate_to(ButtonScreen, :using => route.to_sym)
7
+ end
8
+
9
+ Given /^I am on the the ViewsMenuScreen$/ do
10
+ on(MainMenuScreen).views
11
+ on(ViewsMenuScreen)
12
+ end
@@ -3,3 +3,8 @@ Then /^I can see the spinner value referenced by "(.*?)" is "(.*?)"$/ do |how, t
3
3
  screen.send("spinner_#{how}").should eq(the_selected_value)
4
4
  end
5
5
  end
6
+
7
+ When /^I select item number "(.*?)" from the spinner using "(.*?)"$/ do |num, how|
8
+ on(ControlsScreen).send "select_spinner_#{how}", num.to_i
9
+ end
10
+
@@ -1,10 +1,10 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
2
 
3
3
  require 'rspec/expectations'
4
+ require 'require_all'
4
5
  require 'brazenhead'
5
6
  require 'brazenhead/server'
6
7
  require 'gametel'
7
- require 'gametel/navigation'
8
8
 
9
9
  World(Gametel::Navigation)
10
10
 
@@ -17,6 +17,19 @@ keystore = {
17
17
 
18
18
  server = Brazenhead::Server.new('features/support/ApiDemos.apk', keystore)
19
19
 
20
+ require_rel '/screens'
21
+
22
+ Gametel::Navigation.routes = {
23
+ :default => [[MainMenuScreen, :views],
24
+ [ViewsMenuScreen, :controls],
25
+ [ControlsMenuScreen, :light_theme],
26
+ [ControlsScreen, :button_field_id]],
27
+ :button_route => [[MainMenuScreen, :views],
28
+ [ViewsMenuScreen, :buttons],
29
+ [ButtonScreen, :normal_id]]
30
+ }
31
+
32
+
20
33
  class Driver
21
34
  include Brazenhead
22
35
  end
@@ -194,6 +194,9 @@ module Gametel
194
194
  define_method(name) do
195
195
  platform.get_spinner_value(locator)
196
196
  end
197
+ define_method("select_#{name}") do |value|
198
+ platform.select_spinner_value(locator, value)
199
+ end
197
200
  end
198
201
  end
199
202
  end
@@ -1,9 +1,58 @@
1
1
  module Gametel
2
+ #
3
+ # Module to facilitate create new gametel screen objects in
4
+ # definitions.
5
+ #
2
6
  module Navigation
7
+
8
+ class << self
9
+ attr_reader :navigation_routes
10
+
11
+ def routes=(routes)
12
+ @navigation_routes = routes
13
+ end
14
+ end
15
+
16
+ #
17
+ # create a new screen given a class name
18
+ #
3
19
  def on(cls, &block)
4
20
  @current_screen = cls.new
5
21
  block.call @current_screen if block
6
22
  @current_screen
7
23
  end
24
+
25
+ #
26
+ # Navigate to a specific screen following a predefined path.
27
+ #
28
+ def navigate_to(screen_cls, how = {:using => :default}, &block)
29
+ path = path_for how
30
+ from = @current_screen ? @current_screen.class : path[0][0]
31
+ from_index = find_index_for(path, from)
32
+ to_index = find_index_for(path, screen_cls) - 1
33
+ navigate_through_pages(path[from_index..to_index])
34
+ on(screen_cls, &block)
35
+ end
36
+
37
+ private
38
+
39
+ def path_for(how)
40
+ path = Gametel::Navigation.navigation_routes[how[:using]]
41
+ fail("Gametel::Navigation route :#{how[:using].to_s} not found") unless path
42
+ path
43
+ end
44
+
45
+ def find_index_for(path, item)
46
+ path.each_with_index { |each, index| return index if each[0] == item}
47
+ end
48
+
49
+ def navigate_through_pages(pages)
50
+ pages.each do |cls, method|
51
+ page = on(cls)
52
+ fail("Navigation method not specified on #{cls}. Please call the ") unless page.respond_to? method
53
+ page.send method
54
+ end
55
+ end
56
+
8
57
  end
9
58
  end
@@ -17,7 +17,13 @@ module Gametel
17
17
  device.to_string
18
18
  end
19
19
  end
20
-
20
+
21
+ def select_spinner_value_by_id(id, index)
22
+ chain_calls do |device|
23
+ device.id_from_name id, :variable => '@@the_id@@', :target => 'Brazenhead'
24
+ device.press_spinner_item_by_id '@@the_id@@', index, :target => 'Brazenhead'
25
+ end
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -25,7 +25,7 @@ module Gametel
25
25
  #
26
26
  def get_text(locator)
27
27
  result = get_text_by_id(locator[:id])
28
- strip_quotes_from result.body
28
+ last_json
29
29
  end
30
30
 
31
31
  #
@@ -33,7 +33,7 @@ module Gametel
33
33
  #
34
34
  def get_text_hint(locator)
35
35
  result = get_text_hint_by_id(locator[:id])
36
- strip_quotes_from result.body
36
+ last_json
37
37
  end
38
38
 
39
39
  #
@@ -41,7 +41,7 @@ module Gametel
41
41
  #
42
42
  def get_text_description(locator)
43
43
  result = get_text_description_by_id(locator[:id])
44
- strip_quotes_from result.body
44
+ last_json
45
45
  end
46
46
 
47
47
  #
@@ -102,7 +102,15 @@ module Gametel
102
102
  def get_spinner_value(locator)
103
103
  result = get_spinner_value_by_id(locator[:id]) if locator[:id]
104
104
  result = get_spinner_value_by_index(locator[:index]) if locator[:index]
105
- strip_quotes_from result.body
105
+ last_json
106
+ end
107
+
108
+ #
109
+ # select the spinner value using the item's index
110
+ #
111
+ def select_spinner_value(locator, index)
112
+ result = select_spinner_value_by_id(locator[:id], index) if locator[:id]
113
+ result = press_spinner_item(locator[:index], index) if locator[:index]
106
114
  end
107
115
 
108
116
  #
@@ -151,11 +159,6 @@ module Gametel
151
159
  result = send_key ENTER_KEY
152
160
  end
153
161
 
154
- private
155
-
156
- def strip_quotes_from(value)
157
- value.gsub('"', '')
158
- end
159
162
  end
160
163
  end
161
164
  end
@@ -1,3 +1,3 @@
1
1
  module Gametel
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -511,6 +511,12 @@ describe Gametel::Accessors do
511
511
  result.should_receive(:body).and_return('the text value')
512
512
  screen.spinner_id.should eq('the text value')
513
513
  end
514
+
515
+ it "shuld be able to select an item" do
516
+ accumulator.should_receive(:id_from_name)
517
+ accumulator.should_receive(:press_spinner_item_by_id)
518
+ screen.select_spinner_id 4
519
+ end
514
520
  end
515
521
 
516
522
  context "identified by index" do
@@ -523,6 +529,11 @@ describe Gametel::Accessors do
523
529
  result.should_receive(:body).and_return('the text value')
524
530
  screen.spinner_index.should eq('the text value')
525
531
  end
532
+
533
+ it "should be able to select an item" do
534
+ platform.should_receive(:press_spinner_item).with(1, 4)
535
+ screen.select_spinner_index 4
536
+ end
526
537
  end
527
538
  end
528
539
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gametel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-25 00:00:00.000000000 Z
13
+ date: 2012-09-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: brazenhead
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.4.1
22
+ version: 0.4.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 0.4.1
30
+ version: 0.4.2
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: ADB
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +76,22 @@ dependencies:
76
76
  - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: require_all
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
79
95
  description: High level wrapper around android drivers
80
96
  email:
81
97
  - jeff.morgan@leandog.com
@@ -90,6 +106,7 @@ files:
90
106
  - features/is_enabled.feature
91
107
  - features/list_item.feature
92
108
  - features/main_screen.feature
109
+ - features/navigation.feature
93
110
  - features/progress.feature
94
111
  - features/radio_button.feature
95
112
  - features/spinners.feature
@@ -100,6 +117,7 @@ files:
100
117
  - features/step_definitions/is_enabled_steps.rb
101
118
  - features/step_definitions/list_item_steps.rb
102
119
  - features/step_definitions/main_screen_steps.rb
120
+ - features/step_definitions/navigation_steps.rb
103
121
  - features/step_definitions/progress_steps.rb
104
122
  - features/step_definitions/radio_button_steps.rb
105
123
  - features/step_definitions/spinners_steps.rb
@@ -153,12 +171,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
171
  - - ! '>='
154
172
  - !ruby/object:Gem::Version
155
173
  version: '0'
174
+ segments:
175
+ - 0
176
+ hash: -226284468373359732
156
177
  required_rubygems_version: !ruby/object:Gem::Requirement
157
178
  none: false
158
179
  requirements:
159
180
  - - ! '>='
160
181
  - !ruby/object:Gem::Version
161
182
  version: '0'
183
+ segments:
184
+ - 0
185
+ hash: -226284468373359732
162
186
  requirements: []
163
187
  rubyforge_project:
164
188
  rubygems_version: 1.8.24
@@ -172,6 +196,7 @@ test_files:
172
196
  - features/is_enabled.feature
173
197
  - features/list_item.feature
174
198
  - features/main_screen.feature
199
+ - features/navigation.feature
175
200
  - features/progress.feature
176
201
  - features/radio_button.feature
177
202
  - features/spinners.feature
@@ -182,6 +207,7 @@ test_files:
182
207
  - features/step_definitions/is_enabled_steps.rb
183
208
  - features/step_definitions/list_item_steps.rb
184
209
  - features/step_definitions/main_screen_steps.rb
210
+ - features/step_definitions/navigation_steps.rb
185
211
  - features/step_definitions/progress_steps.rb
186
212
  - features/step_definitions/radio_button_steps.rb
187
213
  - features/step_definitions/spinners_steps.rb