Skip to content

Commit e76e6dd

Browse files
Merge pull request #151 from DylanLacey/docs
Update tests
2 parents ecbbb18 + 7ef61e1 commit e76e6dd

File tree

2 files changed

+169
-0
lines changed

2 files changed

+169
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
describe 'common/device' do
2+
# Not yet implemented
3+
t 'shake' do
4+
end
5+
6+
t 'remove & install' do
7+
#remove 'com.example.android.apis'
8+
#install ENV['APP_PATH']
9+
end
10+
11+
t 'background_app' do
12+
background_app 5
13+
end
14+
15+
t 'is_installed' do
16+
is_installed?('fake_app').must_equal false
17+
end
18+
19+
t 'reset' do
20+
reset
21+
s_texts[0].must_equal 'API Demos'
22+
end
23+
24+
t 'close & launch' do
25+
closeApp
26+
launch
27+
end
28+
29+
t 'current_activity' do
30+
current_activity.must_equal '.ApiDemos'
31+
end
32+
33+
t 'available_contexts' do
34+
available_contexts.must_equal ["NATIVE_APP"]
35+
end
36+
37+
t 'current_context' do
38+
current_context.must_equal "NATIVE_APP"
39+
end
40+
41+
t 'current_context=' do
42+
current_context= "WEBVIEW"
43+
current_context.must_equal "WEBVIEW"
44+
end
45+
46+
t 'within_context' do
47+
$driver.within_context "NATIVE_APP" do
48+
current_context.must_equal "NATIVE_APP"
49+
end
50+
end
51+
52+
t 'switch_to_default_context' do
53+
switch_to_default_context
54+
current_context.must_equal 'NATIVE_APP'
55+
end
56+
57+
t 'app_strings' do
58+
strs = app_strings
59+
strs.has_key?("activity_save_restore").must_equal true
60+
end
61+
62+
t 'complex_find' do
63+
act = complex_find [[3, 'Accessibility'], [14, true]]
64+
act.class.must_equal Selenium::WebDriver::Element
65+
end
66+
67+
t 'action_chain' do
68+
e = find_element(:name, "Accessibility")
69+
Appium::TouchAction.new.press(:element => e, x: 0.5, y: 0.5).release(:element => e).perform
70+
sleep 2
71+
find_element(:name, "Custom View")
72+
back
73+
end
74+
75+
t 'swipe' do
76+
Appium::TouchAction.new.swipe(start_x: 0.75, start_y: 0.25, end_x: 0.75, end_y: 0.5, duration: 1.5).perform
77+
end
78+
79+
t 'pinch & zoom' do
80+
s_text('Graphics').click
81+
s_text('BitmapMesh').click
82+
zoom 200
83+
pinch 75
84+
end
85+
86+
t 'push and pull file' do
87+
file = "A Fine Day"
88+
path = "/data/local/tmp/remote.txt"
89+
push_file path, file
90+
read_file = pull_file path
91+
read_file.must_equal file
92+
end
93+
end
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
describe 'common/device' do
2+
before_first { screen.must_equal catalog }
3+
4+
t 'lock' do
5+
lock 5
6+
tag('button').name.must_equal 'SlideToUnlock'
7+
8+
# It appears that lockForDuration doesn't.
9+
closeApp
10+
launch
11+
end
12+
13+
t 'background_app' do
14+
background_app 5
15+
screen.must_equal catalog
16+
end
17+
18+
t 'is_installed' do
19+
installed = is_installed? "Derrp"
20+
installed.must_equal false
21+
end
22+
23+
t 'shake' do
24+
shake
25+
end
26+
27+
t 'close and launch' do
28+
closeApp
29+
launch
30+
tag('navigationBar').name.must_equal 'UICatalog'
31+
end
32+
33+
t 'reset' do
34+
reset
35+
end
36+
37+
t 'available_contexts' do
38+
available_contexts.must_equal ["NATIVE_APP"]
39+
end
40+
41+
t 'current_context' do
42+
current_context.must_equal nil
43+
end
44+
45+
t 'switch_to_default_context' do
46+
switch_to_default_context
47+
current_context.must_equal nil
48+
end
49+
50+
t 'app_strings' do
51+
app_strings.must_include "SearchBarExplain"
52+
end
53+
54+
t 'action_chain' do
55+
ac = Appium::TouchAction.new
56+
e = find_element(:name, 'Buttons, Various uses of UIButton')
57+
ac.press element: e, x: 10, y: 10
58+
ac.perform
59+
back
60+
end
61+
62+
t 'swipe' do
63+
swipe start_x: 75, start_y: 500, end_x: 75, end_y: 0, duration: 0.8
64+
end
65+
66+
t 'pinch & zoom' do
67+
s_text('Images, Use of UIImageView').click
68+
zoom 200
69+
pinch 75
70+
end
71+
72+
t 'file movement' do
73+
read_file = pull_file 'Library/AddressBook/AddressBook.sqlitedb'
74+
read_file.start_with?('SQLite format').must_equal true
75+
end
76+
end

0 commit comments

Comments
 (0)