gametel 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,3 +15,19 @@ Feature: Interacting with the list item control
15
15
  Scenario: Should be able to click a list item from a specific list
16
16
  When I click the first list item by index on the first list
17
17
  Then I should see the "Accessibility Service" list item
18
+
19
+ Scenario: Determining text inside a list item
20
+ Given I am on the custom list screen
21
+ When I ask for the first item in the list
22
+ Then I should know that it has the text "Tom"
23
+ And I should know that it has the text "This is Tom, he likes long walks in the park."
24
+
25
+ Scenario: Determining if a list item has an image
26
+ Given I am on the efficient adapter screen
27
+ When I ask for the list item for "Abertam"
28
+ Then I should know that it has an image
29
+
30
+ Scenario: Knowing that a list item has no image
31
+ Given I am on the custom list screen
32
+ When I ask for the first item in the list
33
+ Then I should know that it does not have an image
@@ -9,3 +9,56 @@ end
9
9
  When /^I click the first list item by index on the first list$/ do
10
10
  on(MainMenuScreen).first_list_item_index_list
11
11
  end
12
+
13
+ Given /^I am on the custom list screen$/ do
14
+ on(MainMenuScreen) do |screen|
15
+ screen.views
16
+ screen.wait_for_text 'Buttons'
17
+ end
18
+ on(ViewsMenuScreen) do |screen|
19
+ screen.scroll_down
20
+ screen.lists
21
+ screen.wait_for_text "ListAdapter"
22
+ end
23
+ on(ListsMenuScreen) do |screen|
24
+ screen.custom_items
25
+ screen.wait_for_text 'Tom'
26
+ end
27
+ end
28
+
29
+ When /^I ask for the first item in the list$/ do
30
+ @list_item = on(CustomItemsScreen).tom_view
31
+ end
32
+
33
+ Then /^I should know that it has the text "(.*?)"$/ do |expected_text|
34
+ @list_item.text.should include expected_text
35
+ @list_item.should have_text expected_text
36
+ end
37
+
38
+ Given /^I am on the efficient adapter screen$/ do
39
+ on(MainMenuScreen) do |screen|
40
+ screen.views
41
+ screen.wait_for_text 'Buttons'
42
+ end
43
+ on(ViewsMenuScreen) do |screen|
44
+ screen.scroll_down
45
+ screen.lists
46
+ screen.wait_for_text "ListAdapter"
47
+ end
48
+ on(ListsMenuScreen) do |screen|
49
+ screen.efficient_adapter
50
+ screen.wait_for_text 'Abertam'
51
+ end
52
+ end
53
+
54
+ When /^I ask for the list item for "(.*?)"$/ do |arg1|
55
+ @list_item = on(EfficientAdapterScreen).abertam_view
56
+ end
57
+
58
+ Then /^I should know that it has an image$/ do
59
+ @list_item.should have_image
60
+ end
61
+
62
+ Then /^I should know that it does not have an image$/ do
63
+ @list_item.should_not have_image
64
+ end
Binary file
@@ -0,0 +1,8 @@
1
+ class CustomItemsScreen
2
+ include Gametel
3
+
4
+ list_item(:tom, :text => 'Tom')
5
+ list_item(:dick, :text => 'Dick')
6
+ list_item(:harry, :text => 'Harry')
7
+ list_item(:larry, :text => 'Larry')
8
+ end
@@ -0,0 +1,5 @@
1
+ class EfficientAdapterScreen
2
+ include Gametel
3
+
4
+ list_item(:abertam, :text => 'Abertam')
5
+ end
@@ -0,0 +1,22 @@
1
+ class ListsMenuScreen
2
+ include Gametel
3
+
4
+ list_item(:array, :text => 'Array')
5
+ list_item(:cursor_people, :text => 'Cursor (People)')
6
+ list_item(:cursor_phones, :text => 'Cursor (Phones)')
7
+ list_item(:list_adapter, :text => 'ListAdapter')
8
+ list_item(:separators, :text => 'Separators')
9
+ list_item(:list_adapter_collapsed, :text => 'ListAdapter Collapsed')
10
+ list_item(:cursor_phones2, :text => 'Cursor (Phones)')
11
+ list_item(:photos, :text => 'Photos')
12
+ list_item(:array_overlay, :text => 'Array (Overlay)')
13
+ list_item(:single_choice_list, :text => 'Single choice list')
14
+ list_item(:multiple_choice_list, :text => 'Multiple choice list')
15
+ list_item(:transcript, :text => 'Transcript')
16
+ list_item(:slow_adapter, :text => 'Slow Adapter')
17
+ list_item(:efficient_adapter, :text => 'Efficient Adapter')
18
+ list_item(:selection_mode, :text => 'Selection Model')
19
+ list_item(:border_selection_mode, :text => 'Border selection mode')
20
+ list_item(:activate_items, :text => 'Activate items')
21
+ list_item(:custom_items, :text => 'Custom items')
22
+ end
@@ -20,7 +20,7 @@ class ViewsMenuScreen
20
20
  list_item(:image_view, :text => 'ImageView')
21
21
  list_item(:layout_animations, :text => 'Layout Animations')
22
22
  list_item(:layouts, :text => 'Layouts')
23
- list_item(:lists, :text => 'Lists')
23
+ list_item(:lists, :text => '^Lists$')
24
24
  list_item(:popup_menu, :text => 'Popup Menu')
25
25
  list_item(:progress_bar, :text => 'Progress Bar')
26
26
  list_item(:radio_group, :text => 'Radio Group')
data/lib/gametel.rb CHANGED
@@ -104,6 +104,7 @@ module Gametel
104
104
  #
105
105
  def wait_for_text(text_to_find)
106
106
  platform.wait_for_text(text_to_find)
107
+ raise "Timed out waiting for the text '#{text_to_find}'" unless platform.last_json
107
108
  end
108
109
 
109
110
  end
@@ -81,6 +81,9 @@ module Gametel
81
81
  define_method(name) do
82
82
  platform.press_list_item(locator)
83
83
  end
84
+ define_method("#{name}_view") do
85
+ Gametel::Views::ListItem.new(platform, locator)
86
+ end
84
87
  end
85
88
 
86
89
  #
@@ -0,0 +1,36 @@
1
+ require 'brazenhead'
2
+
3
+ module Gametel
4
+ module Platforms
5
+ module ListItem
6
+
7
+ def press_list_item(locator)
8
+ list = locator[:list] ? locator[:list] : 0
9
+ result = click_in_list(locator[:index] + 1, list) if locator[:index]
10
+ result = click_on_text(locator[:text]) if locator[:text]
11
+ end
12
+
13
+ def text_from_list_item(locator)
14
+ list_item(locator) do |device|
15
+ device.get_current_text_views('@@the_view@@', :target => 'Robotium')
16
+ end
17
+ last_json.map { |text_view| text_view['text'] }
18
+ end
19
+
20
+ def list_item_has_image(locator)
21
+ list_item(locator) do |device|
22
+ device.get_current_image_views('@@the_view@@', :target => 'Robotium')
23
+ end
24
+ last_json[0]['hasDrawable'] if last_json[0]
25
+ end
26
+
27
+ def list_item(locator, &block)
28
+ chain_calls do |device|
29
+ device.list_item_by_text(locator[:text], :target => 'Brazenhead',
30
+ :variable => '@@the_view@@')
31
+ block.call device if block
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -5,6 +5,7 @@ require File.join(File.dirname(__FILE__), 'brazenhead', 'progress')
5
5
  require File.join(File.dirname(__FILE__), 'brazenhead', 'spinner')
6
6
  require File.join(File.dirname(__FILE__), 'brazenhead', 'text')
7
7
  require File.join(File.dirname(__FILE__), 'brazenhead', 'view')
8
+ require File.join(File.dirname(__FILE__), 'brazenhead', 'list_item')
8
9
 
9
10
 
10
11
  module Gametel
@@ -17,6 +18,7 @@ module Gametel
17
18
  include Gametel::Platforms::Spinner
18
19
  include Gametel::Platforms::Text
19
20
  include Gametel::Platforms::View
21
+ include Gametel::Platforms::ListItem
20
22
 
21
23
  ENTER_KEY = 66
22
24
 
@@ -69,15 +71,6 @@ module Gametel
69
71
  result = click_on_view_by_id(locator[:id]) if locator[:id]
70
72
  end
71
73
 
72
- #
73
- # press a list item
74
- #
75
- def press_list_item(locator)
76
- list = locator[:list] ? locator[:list] : 0
77
- result = click_in_list(locator[:index] + 1, list) if locator[:index]
78
- result = click_on_text(locator[:text]) if locator[:text]
79
- end
80
-
81
74
  #
82
75
  # click a checkbox
83
76
  #
@@ -1,3 +1,3 @@
1
1
  module Gametel
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
data/lib/gametel/views.rb CHANGED
@@ -5,3 +5,4 @@ require 'gametel/views/radio_button'
5
5
  require 'gametel/views/checkbox'
6
6
  require 'gametel/views/progress'
7
7
  require 'gametel/views/spinner'
8
+ require 'gametel/views/list_item'
@@ -0,0 +1,28 @@
1
+ module Gametel
2
+ module Views
3
+ class ListItem < View
4
+
5
+ def text
6
+ platform.text_from_list_item(locator)
7
+ end
8
+
9
+ def has_text?(text)
10
+ the_text = ''
11
+ self.text.each do |txt|
12
+ the_text += txt + ' '
13
+ end
14
+ return the_text.include? text
15
+ end
16
+
17
+ def has_image?
18
+ platform.list_item_has_image(locator)
19
+ end
20
+
21
+ protected
22
+
23
+ def build_property_methods
24
+ # do nothing
25
+ end
26
+ end
27
+ end
28
+ end
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.3
4
+ version: 0.5.4
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-10-12 00:00:00.000000000 Z
13
+ date: 2012-10-27 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.3
22
+ version: 0.4.5
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.3
30
+ version: 0.4.5
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: ADB
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +134,9 @@ files:
134
134
  - features/support/screens/buttons_screen.rb
135
135
  - features/support/screens/controls_menu_screen.rb
136
136
  - features/support/screens/controls_screen.rb
137
+ - features/support/screens/custom_items_screen.rb
138
+ - features/support/screens/efficient_adapter_screen.rb
139
+ - features/support/screens/lists_menu_screen.rb
137
140
  - features/support/screens/main_menu_screen.rb
138
141
  - features/support/screens/seek_bar_screen.rb
139
142
  - features/support/screens/views_menu_screen.rb
@@ -144,6 +147,7 @@ files:
144
147
  - lib/gametel/navigation.rb
145
148
  - lib/gametel/platforms/brazenhead/basic.rb
146
149
  - lib/gametel/platforms/brazenhead/button.rb
150
+ - lib/gametel/platforms/brazenhead/list_item.rb
147
151
  - lib/gametel/platforms/brazenhead/progress.rb
148
152
  - lib/gametel/platforms/brazenhead/spinner.rb
149
153
  - lib/gametel/platforms/brazenhead/text.rb
@@ -153,6 +157,7 @@ files:
153
157
  - lib/gametel/views.rb
154
158
  - lib/gametel/views/button.rb
155
159
  - lib/gametel/views/checkbox.rb
160
+ - lib/gametel/views/list_item.rb
156
161
  - lib/gametel/views/progress.rb
157
162
  - lib/gametel/views/radio_button.rb
158
163
  - lib/gametel/views/spinner.rb
@@ -173,18 +178,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
178
  - - ! '>='
174
179
  - !ruby/object:Gem::Version
175
180
  version: '0'
176
- segments:
177
- - 0
178
- hash: -3608907023518404738
179
181
  required_rubygems_version: !ruby/object:Gem::Requirement
180
182
  none: false
181
183
  requirements:
182
184
  - - ! '>='
183
185
  - !ruby/object:Gem::Version
184
186
  version: '0'
185
- segments:
186
- - 0
187
- hash: -3608907023518404738
188
187
  requirements: []
189
188
  rubyforge_project:
190
189
  rubygems_version: 1.8.24
@@ -226,6 +225,9 @@ test_files:
226
225
  - features/support/screens/buttons_screen.rb
227
226
  - features/support/screens/controls_menu_screen.rb
228
227
  - features/support/screens/controls_screen.rb
228
+ - features/support/screens/custom_items_screen.rb
229
+ - features/support/screens/efficient_adapter_screen.rb
230
+ - features/support/screens/lists_menu_screen.rb
229
231
  - features/support/screens/main_menu_screen.rb
230
232
  - features/support/screens/seek_bar_screen.rb
231
233
  - features/support/screens/views_menu_screen.rb