Skip to content

Commit 5c9e840

Browse files
Update tests to work with new spec gem
1 parent 0331fe0 commit 5c9e840

File tree

23 files changed

+190
-113
lines changed

23 files changed

+190
-113
lines changed

android_tests/Gemfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
source 'https://rubygems.org'
2-
gem 'test_runner', '>= 0.9.37'
3-
gem 'fakefs', '~> 0.5.0'
4-
gem 'rake', '~> 10.2.2'
1+
eval File.read('../Gemfile')

android_tests/lib/android/specs/android/element/textfield.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ def right
99
'Right is always right'
1010
end
1111

12-
before_first do
12+
def before_first
1313
# nav to activity
1414
text('app').click
1515
text('activity').click
1616
text('custom title').click
1717
end
1818

19-
after_last do
19+
def after_last
2020
# back to start
2121
3.times { back }
2222
end
2323

24+
t { before_first }
25+
2426
t 'textfields' do
2527
exp = [left, right]
2628
textfields.must_equal exp
@@ -50,4 +52,6 @@ def right
5052
res = textfield_exact left
5153
res.text.must_equal left
5254
end
55+
56+
t { after_last }
5357
end

android_tests/lib/android/specs/common/element/button.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# encoding: utf-8
22

33
describe 'common/element/button' do
4-
before_first do
4+
def before_first
55
# nav to buttons activity
66
text('App').click
77
text('Activity').click
88
text('Animation').click
99
end
1010

11-
after_last do
11+
def after_last
1212
# nav back to home activity
1313
3.times { back }
1414
end
@@ -17,6 +17,8 @@ def fade_in
1717
'Fade in'
1818
end
1919

20+
t { before_first }
21+
2022
t 'button' do
2123
# by index
2224
button(1).name.must_equal fade_in
@@ -54,4 +56,6 @@ def fade_in
5456
# select the second button containing 'in'
5557
button_num('in', 2).name.must_equal 'Zoom in'
5658
end
59+
60+
t { after_last }
5761
end

android_tests/lib/run.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# encoding: utf-8
22
require 'rubygems'
3-
require 'test_runner'
43
require 'spec'
54
require 'fakefs/safe'
5+
require_relative '../../lib/appium_lib'
6+
67
=begin
78
node server.js -V --fast-reset --without-delay
89

android_tests/selendroid/appium.txt

-5
This file was deleted.

appium_lib.gemspec

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ Gem::Specification.new do |s|
3030
s.add_runtime_dependency 'toml', '~> 0.0', '>= 0.0.4'
3131
s.add_runtime_dependency 'posix-spawn', '~> 0.3', '>= 0.3.8'
3232

33+
s.add_development_dependency 'hashdiff', '~> 0.2.0'
34+
s.add_development_dependency 'spec', '~> 5.3.4'
35+
s.add_development_dependency 'fakefs', '~> 0.5.0'
36+
3337
s.add_development_dependency 'rake', '~> 10.2', '>= 10.2.2'
3438
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7.3'
3539

3640
s.files = `git ls-files`.split "\n"
37-
end
41+
end

ios_tests/Gemfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
source 'https://rubygems.org'
2-
gem 'test_runner', '>= 0.9.37'
3-
gem 'rake', '~> 10.2.2'
4-
gem 'selenium-webdriver', '>= 2.41.0'
1+
eval File.read('../Gemfile')

ios_tests/lib/ios/specs/common/device.rb

+75-71
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,79 @@
11
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
2+
def before_first
3+
screen.must_equal catalog
4+
end
5+
6+
t { before_first }
7+
8+
t 'lock' do
9+
lock 5
10+
tag('button').name.must_equal 'SlideToUnlock'
11+
12+
# It appears that lockForDuration doesn't.
13+
closeApp
14+
launch
15+
end
16+
17+
t 'background_app' do
18+
background_app 5
19+
screen.must_equal catalog
20+
end
21+
22+
t 'is_installed' do
23+
installed = is_installed? "Derrp"
24+
installed.must_equal false
25+
end
26+
27+
t 'shake' do
28+
shake
29+
end
30+
31+
t 'close and launch' do
32+
closeApp
33+
launch
34+
tag('navigationBar').name.must_equal 'UICatalog'
35+
end
36+
37+
t 'reset' do
38+
reset
39+
end
40+
41+
t 'available_contexts' do
42+
available_contexts.must_equal ["NATIVE_APP"]
43+
end
44+
45+
t 'current_context' do
46+
current_context.must_equal nil
47+
end
48+
49+
t 'switch_to_default_context' do
50+
switch_to_default_context
51+
current_context.must_equal nil
52+
end
53+
54+
t 'app_strings' do
55+
app_strings.must_include "SearchBarExplain"
56+
end
57+
58+
t 'action_chain' do
59+
ac = Appium::TouchAction.new
60+
e = find_element(:name, 'Buttons, Various uses of UIButton')
61+
ac.press element: e, x: 10, y: 10
62+
ac.perform
63+
back
64+
end
65+
66+
t 'swipe' do
67+
swipe start_x: 75, start_y: 500, end_x: 75, end_y: 0, duration: 0.8
68+
end
69+
70+
t 'pinch & zoom' do
71+
s_text('Images, Use of UIImageView').click
72+
zoom 200
73+
pinch 75
74+
end
75+
76+
t 'file movement' do
7377
read_file = pull_file 'Library/AddressBook/AddressBook.sqlitedb'
7478
read_file.start_with?('SQLite format').must_equal true
7579
end

ios_tests/lib/ios/specs/common/element/button.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# encoding: utf-8
22

33
describe 'common/element/button' do
4-
before_first do
4+
def before_first
55
screen.must_equal catalog
66
# nav to buttons activity
77
wait { name('buttons').click }
88
end
99

10-
after_last do
10+
def after_last
1111
# nav back to start
1212
back_click
1313
end
1414

15+
t { before_first }
16+
1517
def gray
1618
'Gray'
1719
end
@@ -53,4 +55,6 @@ def gray
5355
# select the second button containing 'in'
5456
button_num('in', 2).name.must_equal 'More info'
5557
end
58+
59+
t { after_last }
5660
end

ios_tests/lib/ios/specs/common/element/text.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# encoding: utf-8
22

33
describe 'common/element/text' do
4-
before_first { screen.must_equal catalog }
4+
def before_first
5+
screen.must_equal catalog
6+
end
7+
8+
t { before_first }
9+
510
t 's_texts' do
611
exp = ['UICatalog', 'Buttons, Various uses of UIButton', 'Controls, Various uses of UIControl', 'TextFields, Uses of UITextField', 'SearchBar, Use of UISearchBar', 'TextView, Use of UITextField', 'Pickers, Uses of UIDatePicker, UIPickerView', 'Images, Use of UIImageView', 'Web, Use of UIWebView', 'Segments, Various uses of UISegmentedControl', 'Toolbar, Uses of UIToolbar', 'Alerts, Various uses of UIAlertView, UIActionSheet', 'Transitions, Shows UIViewAnimationTransitions']
712
s_texts_names.must_equal exp

ios_tests/lib/ios/specs/common/element/window.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# encoding: utf-8
22

33
describe 'common/element/window' do
4-
before_first { screen.must_equal catalog }
4+
def before_first
5+
screen.must_equal catalog
6+
end
7+
8+
t { before_first }
9+
510
t 'window_size' do
611
size = window_size
712
size.width.class.must_equal Fixnum

ios_tests/lib/ios/specs/common/helper.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# encoding: utf-8
22
# rake ios[common/helper]
33
describe 'common/helper.rb' do
4-
before_first { screen.must_equal catalog }
4+
def before_first
5+
screen.must_equal catalog
6+
end
7+
8+
t { before_first }
9+
510
wait_time = [0.2, 0.2] # max_wait, interval
611

712
=begin

ios_tests/lib/ios/specs/common/patch.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
=end
88

99
describe 'common/patch.rb' do
10-
before_first { screen.must_equal catalog }
10+
def before_first
11+
screen.must_equal catalog
12+
end
13+
14+
t { before_first }
15+
1116
# Attributes are busted in Android.
1217
# Blocked on https://github.com/appium/appium/issues/628
1318
describe 'Selenium::WebDriver::Element methods' do

ios_tests/lib/ios/specs/common/version.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# encoding: utf-8
22

33
describe 'version.rb' do
4-
before_first { screen.must_equal catalog }
4+
def before_first
5+
screen.must_equal catalog
6+
end
7+
8+
t { before_first }
9+
510
t '::Appium::VERSION' do
611
::Appium::VERSION.must_match /(\d+)\.(\d+).(\d+)/
712
end

ios_tests/lib/ios/specs/driver.rb

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# encoding: utf-8
22
# rake ios[driver]
33
describe 'driver' do
4-
before_first { screen.must_equal catalog }
4+
def before_first
5+
screen.must_equal catalog
6+
end
7+
8+
t { before_first }
59

610
def is_sauce
711
ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
@@ -35,10 +39,18 @@ def is_sauce
3539
sauce_username: nil,
3640
sauce_access_key: nil,
3741
port: 4723,
38-
device: 'ios',
42+
device: :ios,
3943
debug: true }
4044

41-
actual.must_equal expected
45+
if actual != expected
46+
diff = HashDiff.diff expected, actual
47+
diff = "diff (expected, actual):\n#{diff}"
48+
# example:
49+
# change :ios in expected to match 'ios' in actual
50+
# [["~", "caps.platformName", :ios, "ios"]]
51+
message = "\n\nactual:\n\n: #{actual.ai}expected:\n\n#{expected.ai}\n\n#{diff}"
52+
fail message
53+
end
4254
end
4355

4456
t 'verify attributes are immutable' do

0 commit comments

Comments
 (0)