calabash-cucumber 0.9.169.pre5 → 0.9.169.pre6
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.
- checksums.yaml +4 -4
- data/calabash-cucumber.gemspec +1 -1
- data/features-skeleton/support/01_launch.rb +5 -7
- data/lib/calabash-cucumber/actions/instruments_actions.rb +4 -0
- data/lib/calabash-cucumber/actions/playback_actions.rb +4 -0
- data/lib/calabash-cucumber/core.rb +14 -0
- data/lib/calabash-cucumber/launcher.rb +18 -16
- data/lib/calabash-cucumber/operations.rb +11 -1
- data/lib/calabash-cucumber/uia.rb +9 -0
- data/lib/calabash-cucumber/utils/simulator_accessibility.rb +126 -70
- data/lib/calabash-cucumber/version.rb +2 -2
- data/lib/calabash-cucumber/wait_helpers.rb +20 -14
- data/spec/bin/calabash_ios_sim_spec.rb +1 -1
- data/spec/launcher_spec.rb +100 -10
- data/spec/resources/enable-accessibility/6.1/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.0.3-64/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.0.3/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.1-64/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.1/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
- data/spec/simulator_accessibility_spec.rb +129 -67
- metadata +48 -38
@@ -10,6 +10,8 @@ module Calabash
|
|
10
10
|
include Calabash::Cucumber::Core
|
11
11
|
include Calabash::Cucumber::TestsHelpers
|
12
12
|
|
13
|
+
CLIENT_TIMEOUT_ADDITION = 5
|
14
|
+
|
13
15
|
class WaitError < RuntimeError
|
14
16
|
end
|
15
17
|
|
@@ -114,8 +116,11 @@ module Calabash
|
|
114
116
|
end
|
115
117
|
|
116
118
|
def wait_for_condition(options = {})
|
117
|
-
|
118
|
-
|
119
|
+
timeout = options[:timeout]
|
120
|
+
unless timeout && timeout > 0
|
121
|
+
timeout = 30
|
122
|
+
end
|
123
|
+
options[:query] = options[:query] || '*'
|
119
124
|
if options.has_key?(:condition)
|
120
125
|
opt_condition = options[:condition]
|
121
126
|
if opt_condition.is_a?(Symbol)
|
@@ -127,22 +132,23 @@ module Calabash
|
|
127
132
|
end
|
128
133
|
options[:condition] = options[:condition] || CALABASH_CONDITIONS[:none_animating]
|
129
134
|
options[:post_timeout] = options[:post_timeout] || 0
|
130
|
-
|
131
|
-
retry_frequency = options[:
|
132
|
-
options[:
|
133
|
-
|
134
|
-
|
135
|
+
|
136
|
+
retry_frequency = options[:frequency] = options[:frequency] || 0.2
|
137
|
+
timeout_message = options[:timeout_message] = options[:timeout_message] || "Timeout waiting (#{options[:timeout]}) for condition (#{options[:condition]})"
|
138
|
+
screenshot_on_error = true
|
139
|
+
if options.key?(:screenshot_on_error)
|
140
|
+
screenshot_on_error = options[:screenshot_on_error]
|
141
|
+
end
|
135
142
|
|
136
143
|
begin
|
137
|
-
Timeout::timeout(
|
138
|
-
loop do
|
144
|
+
Timeout::timeout(timeout+CLIENT_TIMEOUT_ADDITION, WaitError) do
|
139
145
|
res = http({:method => :post, :path => 'condition'},
|
140
146
|
options)
|
141
147
|
res = JSON.parse(res)
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
148
|
+
unless res['outcome'] == 'SUCCESS'
|
149
|
+
raise WaitError.new(res['reason'])
|
150
|
+
end
|
151
|
+
sleep(options[:post_timeout]) if options[:post_timeout] > 0
|
146
152
|
end
|
147
153
|
rescue WaitError => e
|
148
154
|
msg = timeout_message || e
|
@@ -158,7 +164,7 @@ module Calabash
|
|
158
164
|
raise wait_error(msg)
|
159
165
|
end
|
160
166
|
rescue Exception => e
|
161
|
-
handle_error_with_options(e,nil,
|
167
|
+
handle_error_with_options(e,nil, screenshot_on_error)
|
162
168
|
end
|
163
169
|
end
|
164
170
|
|
@@ -18,7 +18,7 @@ describe 'calabash ios sim cli' do
|
|
18
18
|
|
19
19
|
it 'should be able to reset the content and settings of the simulator' do
|
20
20
|
calabash_sim_reset
|
21
|
-
expect(
|
21
|
+
expect(existing_simulator_support_sdk_dirs.count).to be == 1
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
data/spec/launcher_spec.rb
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'calabash-cucumber/launcher'
|
3
|
+
require 'run_loop'
|
3
4
|
|
4
5
|
describe 'Calabash Launcher' do
|
5
6
|
|
7
|
+
UDID = '66h3hfgc466836ehcg72738eh8f322842855d2fd'
|
8
|
+
IPHONE_4IN_R_64 = 'iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1'
|
6
9
|
before(:each) do
|
7
10
|
@launcher = Calabash::Cucumber::Launcher.new
|
8
11
|
end
|
9
12
|
|
10
|
-
|
13
|
+
before(:each) do
|
14
|
+
ENV['DEVICE_TARGET'] = nil
|
15
|
+
ENV['DETECT_CONNECTED_DEVICE'] = nil
|
16
|
+
end
|
11
17
|
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
def set_device_target(val)
|
19
|
+
ENV['DEVICE_TARGET'] = val
|
20
|
+
end
|
15
21
|
|
16
|
-
|
17
|
-
ENV['DEVICE_TARGET'] = val
|
18
|
-
end
|
22
|
+
describe 'simulator_target? should respond correctly to DEVICE_TARGET' do
|
19
23
|
|
20
24
|
it 'should return true if DEVICE_TARGET is nil' do
|
21
25
|
expect(@launcher.simulator_target?).to be == false
|
@@ -33,7 +37,7 @@ describe 'Calabash Launcher' do
|
|
33
37
|
|
34
38
|
it 'should return false if DEVICE_TARGET is udid' do
|
35
39
|
# noinspection SpellCheckingInspection
|
36
|
-
set_device_target(
|
40
|
+
set_device_target(UDID)
|
37
41
|
expect(@launcher.simulator_target?).to be == false
|
38
42
|
end
|
39
43
|
|
@@ -60,7 +64,7 @@ describe 'Calabash Launcher' do
|
|
60
64
|
hash = {:device_target => 'device'}
|
61
65
|
expect(@launcher.simulator_target?(hash)).to be == false
|
62
66
|
|
63
|
-
hash = {:device_target =>
|
67
|
+
hash = {:device_target => UDID}
|
64
68
|
expect(@launcher.simulator_target?(hash)).to be == false
|
65
69
|
|
66
70
|
hash = {:device_target => 'foobar'}
|
@@ -73,4 +77,90 @@ describe 'Calabash Launcher' do
|
|
73
77
|
end
|
74
78
|
|
75
79
|
end
|
76
|
-
|
80
|
+
|
81
|
+
describe 'default launch args should respect DEVICE_TARGET' do
|
82
|
+
|
83
|
+
it "it should return 'simulator' if DEVICE_TARGET nil" do
|
84
|
+
args = @launcher.default_launch_args
|
85
|
+
expect(args[:device_target]).to be == 'simulator'
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'running with instruments' do
|
89
|
+
|
90
|
+
it 'should be running against instruments' do
|
91
|
+
args = @launcher.default_launch_args
|
92
|
+
expect(args[:launch_method]).to be == :instruments
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'running against devices' do
|
96
|
+
|
97
|
+
describe 'when DEVICE_TARGET = < udid >' do
|
98
|
+
before(:each) do
|
99
|
+
ENV['DEVICE_TARGET'] = UDID
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'it should return udid if DEVICE_TARGET is a udid' do
|
103
|
+
args = @launcher.default_launch_args
|
104
|
+
expect(args[:device_target]).to be == UDID
|
105
|
+
expect(args[:udid]).to be == UDID
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'when DEVICE_TARGET = device' do
|
110
|
+
before(:each) do
|
111
|
+
ENV['DEVICE_TARGET'] = 'device'
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'detecting connected devices' do
|
115
|
+
describe "when DETECT_CONNECTED_DEVICE == '1'" do
|
116
|
+
it 'should return a udid if DEVICE_TARGET=device if a device is connected and simulator otherwise' do
|
117
|
+
ENV['DETECT_CONNECTED_DEVICE'] = '1'
|
118
|
+
args = @launcher.default_launch_args
|
119
|
+
target = args[:device_target]
|
120
|
+
detected = RunLoop::Core.detect_connected_device
|
121
|
+
|
122
|
+
if detected
|
123
|
+
expect(target).to be == detected
|
124
|
+
expect(args[:udid]).to be == detected
|
125
|
+
else
|
126
|
+
pending('this behavior is needs verification')
|
127
|
+
expect(target).to be == 'simulator'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "when DETECT_CONNECTED_DEVICE != '1'" do
|
132
|
+
it 'should return a udid if DEVICE_TARGET=device if a device is connected and simulator otherwise' do
|
133
|
+
args = @launcher.default_launch_args
|
134
|
+
target = args[:device_target]
|
135
|
+
expect(target).to be == 'device'
|
136
|
+
expect(args[:udid]).to be == 'device'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'running against simulators' do
|
145
|
+
|
146
|
+
describe 'DEVICE_TARGET is an iphone in Xcode 5.1 format' do
|
147
|
+
before(:each) do
|
148
|
+
ENV['DEVICE_TARGET'] = IPHONE_4IN_R_64
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should return the correct simulator' do
|
152
|
+
args = @launcher.default_launch_args
|
153
|
+
expect(args[:device_target]).to be == IPHONE_4IN_R_64
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe 'running without instruments' do
|
162
|
+
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
@@ -12,7 +12,7 @@ describe 'simulator accessibility tool' do
|
|
12
12
|
expect(File.exist?(path)).to be == true
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should be able open and close the simulator' do
|
15
|
+
it 'should be able to open and close the simulator' do
|
16
16
|
cmd = "ps auxw | grep \"iPhone Simulator.app/Contents/MacOS/iPhone Simulator\" | grep -v grep"
|
17
17
|
|
18
18
|
quit_simulator
|
@@ -24,12 +24,73 @@ describe 'simulator accessibility tool' do
|
|
24
24
|
expect(`#{cmd}`.split("\n").count).to be == 1
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'should be able to return a path a com.apple.Accessibility.plist for an SDK' do
|
28
|
+
sdk = "#{simulator_app_support_dir}/7.1"
|
29
|
+
expected = "#{sdk}/Library/Preferences/com.apple.Accessibility.plist"
|
30
|
+
actual = plist_path_with_sdk_dir(sdk)
|
31
|
+
expect(actual).to be == expected
|
32
|
+
end
|
33
|
+
|
34
|
+
# brittle because some users will not have installed 6.1 or 7.0, but hey, why
|
35
|
+
# are them gem dev'ing or gem testing?
|
36
|
+
it 'should be able to return possible SDKs' do
|
37
|
+
actual = possible_simulator_sdks
|
38
|
+
instruments_version = instruments(:version)
|
39
|
+
|
40
|
+
if instruments_version == '5.1' or instruments_version == '5.1.1'
|
41
|
+
expected = ['6.1', '7.0.3', '7.0.3-64', '7.1', '7.1-64']
|
42
|
+
expect(actual).to be == expected
|
43
|
+
else
|
44
|
+
pending("Xcode version '#{instruments_version}' is not supported by this test - gem needs update!")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# brittle because some users will not have installed 6.1 or 7.0, but hey, why
|
49
|
+
# are them gem dev'ing or gem testing?
|
50
|
+
it 'should be able to return Simulator Support SDK dirs' do
|
51
|
+
actual = possible_simulator_support_sdk_dirs
|
52
|
+
instruments_version = instruments(:version)
|
53
|
+
if instruments_version == '5.1' or instruments_version == '5.1.1'
|
54
|
+
expect(actual.count).to be == 5
|
55
|
+
else
|
56
|
+
pending("Xcode version '#{instruments_version}' is not supported by this test - gem needs update!")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should be able to find existing simulator support sdk dirs' do
|
61
|
+
mocked_support_dir = File.expand_path(File.join(__FILE__, '..', 'resources/enable-accessibility/'))
|
62
|
+
self.should_receive(:simulator_app_support_dir).and_return(mocked_support_dir)
|
63
|
+
actual = existing_simulator_support_sdk_dirs
|
64
|
+
expect(actual.count).to be == 5
|
65
|
+
end
|
66
|
+
|
67
|
+
|
27
68
|
describe 'enabling accessibility' do
|
28
69
|
|
29
70
|
before(:each) do
|
30
71
|
@sim_launcher = SimLauncher::Simulator.new
|
31
72
|
@sdk_detector = SimLauncher::SdkDetector.new(@sim_launcher)
|
32
73
|
quit_simulator
|
74
|
+
|
75
|
+
@latest_sdk = @sdk_detector.latest_sdk_version
|
76
|
+
@device_target = "iPhone Retina (4-inch) - Simulator - iOS #{@latest_sdk}"
|
77
|
+
@launch_args =
|
78
|
+
{
|
79
|
+
:launch_method => :instruments,
|
80
|
+
:reset => false,
|
81
|
+
:bundle_id => nil,
|
82
|
+
:device => 'iphone',
|
83
|
+
:no_stop => false,
|
84
|
+
:no_launch => false,
|
85
|
+
:sdk_version => @latest_sdk,
|
86
|
+
:app => lp_simple_example,
|
87
|
+
:timeout => 30,
|
88
|
+
:device_target => @device_target,
|
89
|
+
:launch_retries => 1
|
90
|
+
}
|
91
|
+
|
92
|
+
@launcher = Calabash::Cucumber::Launcher.new
|
93
|
+
|
33
94
|
end
|
34
95
|
|
35
96
|
def lp_simple_example
|
@@ -47,59 +108,12 @@ describe 'simulator accessibility tool' do
|
|
47
108
|
end
|
48
109
|
end
|
49
110
|
|
50
|
-
|
51
|
-
@sdk_detector.available_sdk_versions.each do |sdk|
|
52
|
-
repopulate_sim_app_support_for_sdk(sdk)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'interacting with simulator app support sdk directories' do
|
57
|
-
it 'should be able to find all the sdk directories' do
|
58
|
-
repopulate_sim_app_support_all
|
59
|
-
|
60
|
-
expected = @sdk_detector.available_sdk_versions
|
61
|
-
actual = simulator_support_sdk_dirs
|
62
|
-
|
63
|
-
calabash_info("sdks = '#{expected}'")
|
64
|
-
actual.each { |path|
|
65
|
-
calabash_info("sdk path = '#{path}'")
|
66
|
-
}
|
67
|
-
|
68
|
-
expect(actual.count).to be == expected.count
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'enable accessibility with no AXInspector' do
|
111
|
+
describe 'on existing SDK directories' do
|
73
112
|
|
74
113
|
before(:each) do
|
75
114
|
reset_simulator_content_and_settings
|
76
|
-
|
77
|
-
@latest_sdk = @sdk_detector.latest_sdk_version
|
78
|
-
@device_target = "iPhone Retina (4-inch) - Simulator - iOS #{@latest_sdk}"
|
79
|
-
@launch_args =
|
80
|
-
{
|
81
|
-
:launch_method => :instruments,
|
82
|
-
:reset => false,
|
83
|
-
:bundle_id => nil,
|
84
|
-
:device => 'iphone',
|
85
|
-
:no_stop => false,
|
86
|
-
:no_launch => false,
|
87
|
-
:sdk_version => @latest_sdk,
|
88
|
-
:app => lp_simple_example,
|
89
|
-
:timeout => 10,
|
90
|
-
:device_target => @device_target,
|
91
|
-
:launch_retries => 1
|
92
|
-
}
|
93
|
-
|
94
|
-
@launcher = Calabash::Cucumber::Launcher.new
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should not fail if the com.apple.Accessibility.plist does not exist' do
|
98
|
-
dir = File.join(simulator_app_support_dir, "#{@latest_sdk}")
|
99
|
-
expect(enable_accessibility_in_sdk_dir(dir, {:verbose => true})).to be == false
|
100
115
|
end
|
101
116
|
|
102
|
-
|
103
117
|
it 'should not be able to launch LPSimpleExample-app b/c accessibility is not enabled' do
|
104
118
|
msgs =
|
105
119
|
[
|
@@ -111,34 +125,82 @@ describe 'simulator accessibility tool' do
|
|
111
125
|
'',
|
112
126
|
'AFAICT there is nothing to be done about this.']
|
113
127
|
calabash_warn(msgs.join("\n"))
|
114
|
-
|
128
|
+
begin
|
129
|
+
expect { @launcher.new_run_loop(@launch_args) }.to raise_error(Calabash::Cucumber::Launcher::StartError)
|
130
|
+
ensure
|
131
|
+
@launcher.stop
|
132
|
+
end
|
115
133
|
end
|
116
134
|
|
117
135
|
it 'should be able to enable accessibility for the latest sdk' do
|
118
136
|
repopulate_sim_app_support_for_sdk(@latest_sdk)
|
119
137
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
138
|
+
dir = File.join(simulator_app_support_dir, "#{@latest_sdk}")
|
139
|
+
enable_accessibility_in_sdk_dir(dir)
|
140
|
+
|
141
|
+
begin
|
142
|
+
expect(@launcher.new_run_loop(@launch_args)).to be_a(Hash)
|
143
|
+
ensure
|
144
|
+
@launcher.stop
|
145
|
+
end
|
125
146
|
|
126
|
-
|
127
|
-
|
147
|
+
end
|
148
|
+
end
|
128
149
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
150
|
+
describe 'on non-existing SDK directories' do
|
151
|
+
before(:each) do
|
152
|
+
quit_simulator
|
153
|
+
sleep(2)
|
154
|
+
existing_simulator_support_sdk_dirs.each do |dir|
|
155
|
+
FileUtils.rm_rf(dir)
|
156
|
+
end
|
133
157
|
|
134
|
-
|
135
|
-
# expect(plist_key_exists?(hash[:inspector_frame], plist)).to be == false
|
158
|
+
reset_simulator_content_and_settings
|
136
159
|
|
137
|
-
|
138
|
-
|
160
|
+
quit_simulator
|
161
|
+
# let the iOS Simulator do what it needs to do at shut-down
|
162
|
+
sleep(2)
|
163
|
+
end
|
139
164
|
|
140
|
-
|
165
|
+
it 'should be able to enable accessibility on all possible simulators' do
|
166
|
+
enable_accessibility_on_simulators
|
167
|
+
@launch_args[:sdk_version] = nil
|
168
|
+
@launch_args[:timeout] = 20
|
169
|
+
@launch_args[:launch_retries] = 3
|
170
|
+
|
171
|
+
# these configurations correspond to iOS/Hardware configurations that
|
172
|
+
# do not exist. As an example, there is no iOS 6.1 64-bit implementation,
|
173
|
+
# so a simulator like:
|
174
|
+
#
|
175
|
+
# 'iPhone Retina (4-inch 64-bit) - Simulator - iOS 6.1'
|
176
|
+
#
|
177
|
+
# does not even make sense.
|
178
|
+
#
|
179
|
+
# ditto for 'iPhone - Simulator - iOS 7.0' - there is no non-retina
|
180
|
+
# iOS 7 hardware
|
181
|
+
# -1 Apple
|
182
|
+
excluded = [
|
183
|
+
'iPhone - Simulator - iOS 7.0',
|
184
|
+
'iPhone - Simulator - iOS 7.1',
|
185
|
+
'iPhone Retina (4-inch 64-bit) - Simulator - iOS 6.1',
|
186
|
+
'iPad Retina (64-bit) - Simulator - iOS 6.1'
|
187
|
+
]
|
188
|
+
instruments(:sims).each do |simulator|
|
189
|
+
if excluded.include?(simulator)
|
190
|
+
calabash_warn("skipping simulator '#{simulator}' - instruments passed us an invalid configuration!")
|
191
|
+
else
|
192
|
+
@launch_args[:device_target] = simulator
|
193
|
+
calabash_info("starting simulator '#{simulator}'")
|
194
|
+
begin
|
195
|
+
expect(@launcher.new_run_loop(@launch_args)).to be_a(Hash)
|
196
|
+
ensure
|
197
|
+
@launcher.stop
|
198
|
+
sleep(2)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
141
202
|
end
|
203
|
+
|
142
204
|
end
|
143
205
|
end
|
144
|
-
end
|
206
|
+
end
|