Skip to content

Commit 7ac67e3

Browse files
committedApr 28, 2014
Fix android/helper
1 parent 4754137 commit 7ac67e3

File tree

2 files changed

+16
-43
lines changed

2 files changed

+16
-43
lines changed
 

‎android_tests/lib/android/specs/android/helper.rb

+16-32
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,33 @@
11
# rake android[android/helper]
22
describe 'android/helper' do
3-
t 'tag_name_to_android' do
4-
act = tag_name_to_android 'abslist'
5-
exp = ['android.widget.AbsListView']
6-
act.must_equal exp
7-
8-
act = tag_name_to_android 'button'
9-
exp = %w(android.widget.Button android.widget.ImageButton)
10-
act.must_equal exp
11-
12-
msg = ''
13-
begin; tag_name_to_android 'zz'; rescue Exception => e; msg = e.message; end
14-
msg.must_equal 'Invalid tag name zz'
15-
end
16-
17-
t 'find_eles_attr' do
3+
t 'tags' do
184
exp = ["API Demos", "Accessibility", "Animation", "App", "Content", "Graphics", "Media", "NFC", "OS", "Preference", "Text", "Views"]
195

206
# must wait for page to load
21-
ignore { wait_true(10) { find_eles_attr(:text) == exp } }
22-
act = find_eles_attr :text
7+
ignore { wait_true(10) { tags('android.widget.TextView').map { |e| e.text } == exp } }
8+
act = tags('android.widget.TextView').map { |e| e.text }
239

2410
act.must_equal exp
2511
end
2612

2713
def page_class_data
28-
(<<-TXT).gsub ' ', ''
29-
12x android.widget.TextView
30-
4x android.widget.FrameLayout
31-
4x android.widget.LinearLayout
32-
2x android.view.View
33-
1x android.widget.ListView
34-
1x android.widget.ImageView
14+
(<<-TXT).strip
15+
12x android.widget.TextView
16+
4x android.widget.FrameLayout
17+
2x android.widget.LinearLayout
18+
2x android.view.View
19+
1x android.widget.ListView
20+
1x android.widget.ImageView
21+
1x hierarchy
3522
TXT
3623
end
3724

3825
# t 'get_selendroid_inspect' # only works on selendroid
3926
t 'get_page_class' do
4027
# digit values change based on screen size
41-
exp = page_class_data.gsub(/\d+/,'')
42-
act = get_page_class.gsub(' ', '').gsub(/\d+/,'')
28+
# larger screens have more elements
29+
exp = page_class_data.gsub(/\d+/, '')
30+
act = get_page_class.gsub(/\d+/, '')
4331
act.must_equal exp
4432
end
4533

@@ -53,10 +41,6 @@ def page_class_data
5341
# t 'get_inspect' do # tested by get_android_inspect
5442
# t 'page' do # tested by get_android_inspect
5543

56-
t 'fast_duration' do
57-
fast_duration.must_equal 0.0357
58-
end
59-
6044
def id_key
6145
'animation_2_instructions'
6246
end
@@ -84,8 +68,8 @@ def id_value
8468
end
8569

8670
t 'find by id' do
87-
name('accessibility').click
88-
name('accessibility node provider').click
71+
find('accessibility').click
72+
find('accessibility node provider').click
8973
id 'accessibility_node_provider' # Accessibility/Accessibility Node Provider
9074
2.times { back }
9175
end

‎lib/appium_lib/android/helper.rb

-11
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ def page class_name=false
7676
nil
7777
end
7878

79-
# JavaScript code from https://github.com/appium/appium/blob/master/app/android.js
80-
#
81-
# ```javascript
82-
# Math.round(1.0/28.0 * 28) = 1
83-
# ```
84-
#
85-
# We want steps to be exactly 1. If it's zero then a tap is used instead of a swipe.
86-
def fast_duration
87-
0.0357 # 1.0/28.0
88-
end
89-
9079
# Lists package, activity, and adb shell am start -n value for current app.
9180
# Works on local host only (not remote).
9281
# noinspection RubyArgCount

0 commit comments

Comments
 (0)
Please sign in to comment.