Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.11.2 #578

Merged
merged 44 commits into from
Oct 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d13ff16
Merge branch 'master' into develop
jmoody Oct 15, 2014
59698f0
Call 'strings' in the context of xcrun
jmoody Oct 15, 2014
a8c22f5
Script and plists for disabling instruments permissions
jmoody Oct 15, 2014
8ed6631
Authorize instruments in before_script on Travis
jmoody Oct 15, 2014
f4fc931
Merge pull request #560 from calabash/feature/disable-instruments-per…
jmoody Oct 15, 2014
95c2343
Fix ruby check for travis XTC tests
jmoody Oct 15, 2014
238738a
Add ios8? method to device class
jmoody Oct 15, 2014
a1cdf0b
Adds ios8? to environment helpers
jmoody Oct 15, 2014
80c62e9
Spec resources can return server_version output
jmoody Oct 15, 2014
df47667
Specs for environment helpers ios8?
jmoody Oct 15, 2014
7ca01af
Device spec should use Resources server_version
jmoody Oct 15, 2014
2dfadad
Add screen_dimensions to Resources device_for_mocking
jmoody Oct 15, 2014
d3a46df
Enable reset app sandbox spec on travis
jmoody Oct 15, 2014
87d77d0
Whitespace changes: reset-app-sandbox spec
jmoody Oct 15, 2014
fd5415c
Merge pull request #562 from calabash/feature/enable-reset-app-sandbo…
jmoody Oct 16, 2014
1626e7d
Merge pull request #561 from calabash/feature/add-ios8-to-device-and-…
jmoody Oct 16, 2014
e090c05
Uia type string can handle iOS8 UIWebView edge cases
jmoody Oct 16, 2014
db6878c
Whitespace change in uia.rb
jmoody Oct 16, 2014
6224639
Add uia_result and uia_type_string specs
jmoody Oct 16, 2014
727ed73
Replace instance_eval with send in spec
jmoody Oct 17, 2014
b2b5543
Rename 'res' variable to 'result'
jmoody Oct 20, 2014
ac0b6a7
Updating the uia_type_string code-level docs
jmoody Oct 20, 2014
a0e74f5
Merge pull request #563 from calabash/feature/fix-uia-type-string-on-…
jmoody Oct 21, 2014
1cc3b32
Adding 0.11.2 changelog
jmoody Oct 23, 2014
3f3ffaa
Whitespace change (trailing newline) [skip ci]
jmoody Oct 23, 2014
404bdc8
Deprecate Device#screen_size; use screen_dimensions
jmoody Oct 23, 2014
3d58ad0
Reformat code comments
jmoody Oct 23, 2014
d6b4a73
Determine screen size in normalization method
jmoody Oct 23, 2014
90de99b
Turn JSON parse exception into meaningful error
jmoody Oct 23, 2014
3837284
Merge pull request #572 from calabash/feature/fix-touch-coordinated-n…
jmoody Oct 23, 2014
7fc9163
Merge pull request #573 from calabash/feature/suppress-JSON-parse-err…
jmoody Oct 23, 2014
9237768
Updating spec binary resources
jmoody Oct 23, 2014
e2ff9d6
Rename spec Resources#alt_xcodes_gte_xc51_hash
jmoody Oct 24, 2014
653305e
Restrict Xcode 5 testing to 5.1.1
jmoody Oct 24, 2014
8c7a8e0
Skip testing specs on Xcode 6.0; test 6.0.1
jmoody Oct 24, 2014
0e7101b
Restrict testing to devices connected by USB
jmoody Oct 24, 2014
78bb697
Updating cucumber test binaries
jmoody Oct 24, 2014
082d848
Updates Xcode/iOS version compat tests for specs
jmoody Oct 24, 2014
ddae83d
Update specs with new server version
jmoody Oct 24, 2014
ff6f2ea
Fix simulator selection for 'reset sandbox' spec
jmoody Oct 24, 2014
bb8e041
Updated change log with more details
jmoody Oct 24, 2014
662447f
Bumped gem version to 0.11.2
jmoody Oct 24, 2014
5766d66
Bumped min server version to 0.11.2
jmoody Oct 24, 2014
1843745
Update Xcode 6.1 preference path issue
jmoody Oct 24, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: objective-c

before_script:
- script/ci/travis/instruments-auth.sh
- gem install json
- gem uninstall -Vax --force --no-abort-on-dependent calabash-cucumber
- gem uninstall -Vax --force --no-abort-on-dependent run_loop
Expand All @@ -9,9 +10,9 @@ before_script:
- script/ci/travis/bundle-install.rb

script:
# Skip XTC run on all but 2.1.1 to avoid redundant testing. This is just a
# Skip XTC run on all but 2.1.2 to avoid redundant testing. This is just a
# smoke test to ensure a job can be validated; the ruby version is immaterial.
- if [[ ( ! -z $XTC_API_TOKEN && `ruby -e 'print RUBY_VERSION'` == '2.1.1' ) ]]; then script/ci/travis/xtc-submit-ci.rb; fi
- if [[ ( ! -z $XTC_API_TOKEN && `ruby -e 'print RUBY_VERSION'` == '2.1.2' ) ]]; then script/ci/travis/xtc-submit-ci.rb; fi
- script/ci/travis/install-gem-ci.rb
- script/ci/travis/rspec-ci.rb
- script/ci/travis/cucumber-ci.rb --tags ~@no_ci
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,25 @@ def find_and_normalize(ui_query)
def normalize_rect_for_orientation!(orientation, rect)
orientation = orientation.to_sym
launcher = Calabash::Cucumber::Launcher.launcher

# Coordinate translations for orientation is handled in the server for iOS 8+
# https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICoordinateSpace_protocol/index.html
if launcher.ios_major_version.to_i >= 8
return ## Orientation management changed in iOS 8:
# ## https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICoordinateSpace_protocol/index.html
return
end
dimensions = launcher.device.screen_dimensions
if dimensions
screen_size = {width: dimensions[:width]*dimensions[:sample]/dimensions[:scale],
height: dimensions[:height]*dimensions[:sample]/dimensions[:scale]}

# We cannot use Device#screen_dimensions here because on iPads the height
# and width are the opposite of what we expect.
# @todo Move all coordinate/orientation translation into the server.
device = launcher.device
if device.ipad?
screen_size = { :width => 768, :height => 1024 }
elsif device.iphone_4in?
screen_size = { :width => 320, :height => 568 }
else
screen_size = launcher.device.screen_size
screen_size = { :width => 320, :height => 480 }
end

case orientation
when :right
cx = rect['center_x']
Expand All @@ -150,5 +158,4 @@ def normalize_rect_for_orientation!(orientation, rect)
# no-op by design.
end
end

end
end
16 changes: 10 additions & 6 deletions calabash-cucumber/lib/calabash-cucumber/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ def ios_major_version
version_hash(ios_version)[:major_version]
end

# Is this device running iOS 8?
# @return [Boolean] true if the major version of the OS is 8
def ios8?
ios_major_version.eql?('8')
end

# Is this device running iOS 7?
# @return [Boolean] true if the major version of the OS is 7
def ios7?
Expand All @@ -238,15 +244,13 @@ def ios5?
ios_major_version.eql?('5')
end

# The screen size of the device.
# @deprecated 0.11.2 Replaced with screen_dimensions.
#
# @note These values are not dynamically computed; they are constants.
#
# @note These values are for portrait or upside orientations
# The screen size of the device.
#
# @return [Hash] representation of the screen size as a hash with keys
# `:width` and `:height`
# @return [Hash] representation of the screen size
def screen_size
_deprecated('0.11.2', 'Replaced with screen_dimensions', :warn)
return screen_dimensions if screen_dimensions
return { :width => 768, :height => 1024 } if ipad?
return { :width => 320, :height => 568 } if iphone_4in?
Expand Down
12 changes: 12 additions & 0 deletions calabash-cucumber/lib/calabash-cucumber/environment_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ def ios7?
_OS_ENV.eql?(_canonical_os_version(:ios7)) || _default_device_or_create().ios7?
end

# Is the device under test running iOS 8?
#
# @note
# **WARNING:** The `OS` env variable has been deprecated and should
# never be set.
#
# @raise [RuntimeError] if the server cannot be reached
# @return [Boolean] true if device under test is running iOS 8
def ios8?
_default_device_or_create.ios8?
end

# Is the app that is being tested an iPhone app emulated on an iPad?
#
# @see Calabash::Cucumber::IPad
Expand Down
2 changes: 1 addition & 1 deletion calabash-cucumber/lib/calabash-cucumber/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ def server_version_from_bundle(app_bundle_path)

server_version = nil
exe_paths.each do |path|
server_version_string = `strings "#{path}" | grep -E 'CALABASH VERSION'`.chomp!
server_version_string = `xcrun strings "#{path}" | grep -E 'CALABASH VERSION'`.chomp!
if server_version_string
server_version = server_version_string.split(' ').last
break
Expand Down
41 changes: 32 additions & 9 deletions calabash-cucumber/lib/calabash-cucumber/uia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ def uia(command, options={})
case run_loop[:uia_strategy]
when :preferences
res = http({:method => :post, :path => 'uia'}, {:command => command}.merge(options))
res = JSON.parse(res)

begin
res = JSON.parse(res)
rescue TypeError, JSON::ParserError => _
raise "Could not parse response '#{res}'; the app has probably crashed"
end

if res['outcome'] != 'SUCCESS'
raise "uia action failed because: #{res['reason']}\n#{res['details']}"
end
Expand Down Expand Up @@ -234,13 +240,32 @@ def uia_type_string(string, opt_text_before='', escape=true)
indexes = string.enum_for(:scan, /\\/).map { Regexp.last_match.begin(0) }
indexes.reverse.each { |idx| string = string.insert(idx, '\\') }
end
res = uia_handle_command(:typeString, string, opt_text_before)
status = res['status']
if status.eql?('error')
value = res['value']
raise "could not type '#{string}' - '#{value}'"
result = uia_handle_command(:typeString, string, opt_text_before)

# When 'status' == 'success', we get back result['value']. Sometimes,
# the 'value' key is not present in the result - in which case we assume
# success without error.
return if result.nil?

# Typing on UIWebViews returns result['value'] => ':nil'. There might
# be other cases where result is _not_ a Hash.
return unless result.is_a? Hash

# If there is no 'status' key, then we assume success. Syntax errors
# should be caught upstream.
# https://github.com/calabash/calabash-ios/issues/374
return unless result.has_key? 'status'

status = result['status']

# If status is not 'error' we punt. Should never happen.
return if status != 'error'

if result.has_key? 'value'
raise "Could not type '#{string}' - UIAutomation returned an error: '#{result['value']}'"
else
raise "Could not type '#{string}' - UIAutomation returned '#{result}'"
end
status
end

# @!visibility private
Expand Down Expand Up @@ -385,8 +410,6 @@ def uia_result(s)
s
end
end


end
end
end
4 changes: 2 additions & 2 deletions calabash-cucumber/lib/calabash-cucumber/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Cucumber

# @!visibility public
# The Calabash iOS gem version.
VERSION = '0.11.1'
VERSION = '0.11.2'

# @!visibility public
# The minimum required version of the calabash.framework or, for Xamarin
# users, the Calabash component.
MIN_SERVER_VERSION = '0.11.1'
MIN_SERVER_VERSION = '0.11.2'
end
end
13 changes: 7 additions & 6 deletions calabash-cucumber/spec/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CoreIncluded
end

describe 'Xcode regression' do
xcode_installs = Resources.shared.alt_xcodes_gte_xc51_hash
xcode_installs = Resources.shared.alt_xcode_details_hash
if xcode_installs.empty?
it 'no alternative Xcode installs' do
expect(true).to be == true
Expand Down Expand Up @@ -80,7 +80,7 @@ class CoreIncluded
let(:core_instance) { CoreIncluded.new }

xctools = RunLoop::XCTools.new
physical_devices = xctools.instruments :devices
physical_devices = Resources.shared.physical_devices_for_testing(xctools)

if physical_devices.empty?
it 'no devices attached to this computer' do
Expand All @@ -92,7 +92,7 @@ class CoreIncluded
end
else
physical_devices.each do |device|
if device.version >= RunLoop::Version.new('8.0') and xctools.xcode_version < RunLoop::Version.new('6.0')
if Resources.shared.incompatible_xcode_ios_version(device.version, xctools.xcode_version)
it "Skipping #{device.name} iOS #{device.version} with Xcode #{version} - combination not supported" do
expect(true).to be == true
end
Expand Down Expand Up @@ -123,14 +123,15 @@ class CoreIncluded
let(:launcher) { Calabash::Cucumber::Launcher.new }
let(:core_instance) { CoreIncluded.new }

xcode_installs = Resources.shared.alt_xcodes_gte_xc51_hash
physical_devices = RunLoop::XCTools.new.instruments :devices
xcode_installs = Resources.shared.alt_xcode_details_hash
xctools = RunLoop::XCTools.new
physical_devices = Resources.shared.physical_devices_for_testing(xctools)
if not xcode_installs.empty? and Resources.shared.ideviceinstaller_available? and not physical_devices.empty?
xcode_installs.each do |install_hash|
version = install_hash[:version]
path = install_hash[:path]
physical_devices.each do |device|
if device.version >= RunLoop::Version.new('8.0') and version < RunLoop::Version.new('6.0')
if Resources.shared.incompatible_xcode_ios_version(device.version, version)
it "Skipping #{device.name} iOS #{device.version} with Xcode #{version} - combination not supported" do
expect(true).to be == true
end
Expand Down
20 changes: 20 additions & 0 deletions calabash-cucumber/spec/device_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe Calabash::Cucumber::Device do

# noinspection RubyStringKeysInHashInspection
let(:simulator_data) { Resources.shared.server_version :simulator }
let(:endpoint) { 'http://localhost:37265' }

describe '#ios8?' do
it 'returns false when target is not iOS 8' do
device = Calabash::Cucumber::Device.new(endpoint, simulator_data)
expect(device.ios8?).to be == false
end

it 'returns true when target is iOS 8' do
simulator_data['iOS_version'] = '8.0'
device = Calabash::Cucumber::Device.new(endpoint, simulator_data)
expect(device.ios8?).to be == true
end
end

end
32 changes: 32 additions & 0 deletions calabash-cucumber/spec/environment_helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Calabash
module RspecTests
module EnvironmentHelpers
class TestObject
include Calabash::Cucumber::EnvironmentHelpers
end
end
end
end

describe Calabash::Cucumber::EnvironmentHelpers do

let(:simulator_data) { Resources.shared.server_version :simulator }
let(:endpoint) { 'http://localhost:37265' }
let(:test_obj) { Calabash::RspecTests::EnvironmentHelpers::TestObject.new }

describe 'ios8?' do
it 'returns true when device under test is iOS 8' do
simulator_data['iOS_version'] = '8.0'
device = Calabash::Cucumber::Device.new(endpoint, simulator_data)
expect(test_obj).to receive(:default_device).and_return(device)
expect(test_obj.ios8?).to be == true
end

it 'returns false when device under test is not iOS 8' do
simulator_data['iOS_version'] = '7.0'
device = Calabash::Cucumber::Device.new(endpoint, simulator_data)
expect(test_obj).to receive(:default_device).and_return(device)
expect(test_obj.ios8?).to be == false
end
end
end
4 changes: 2 additions & 2 deletions calabash-cucumber/spec/launcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def args_for_reset_app_sandbox(sdk='7.1')
abp = Resources.shared.app_bundle_path :lp_simple_example
actual = launcher.server_version_from_bundle abp
expect(actual).not_to be == nil
expect(RunLoop::Version.new(actual).to_s).to be == '0.11.1'
expect(RunLoop::Version.new(actual).to_s).to be == '0.11.2'
end

it 'and when there is a space is the path' do
Expand All @@ -309,7 +309,7 @@ def args_for_reset_app_sandbox(sdk='7.1')
abp = File.expand_path(File.join(dir, 'LPSimpleExample-cal.app'))
actual = launcher.server_version_from_bundle abp
expect(actual).not_to be == nil
expect(RunLoop::Version.new(actual).to_s).to be == '0.11.1'
expect(RunLoop::Version.new(actual).to_s).to be == '0.11.2'
end
end

Expand Down
38 changes: 17 additions & 21 deletions calabash-cucumber/spec/reset_app_sandbox_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def path_to_containers(udid, simulator)

describe 'Xcode < 6' do
xcode_selected = Resources.shared.xcode_select_xcode_hash
xcode_installs = Resources.shared.alt_xcodes_gte_xc51_hash + [xcode_selected]
xcode_installs = Resources.shared.alt_xcode_details_hash + [xcode_selected]
max_version = RunLoop::Version.new('5.1.1')
xcode5 = xcode_installs.delete_if { |hash| hash[:version] > max_version }.sample
if xcode5.nil?
Expand Down Expand Up @@ -212,7 +212,7 @@ def path_to_containers(udid, simulator)

describe 'Xcode >= 6.0' do
xcode_selected = Resources.shared.xcode_select_xcode_hash
xcode_installs = Resources.shared.alt_xcodes_gte_xc51_hash + [xcode_selected]
xcode_installs = Resources.shared.alt_xcode_details_hash + [xcode_selected]
min_version = RunLoop::Version.new('6.0')
xcode_versions = xcode_installs.delete_if { |hash| hash[:version] < min_version }
if xcode_versions.empty?
Expand All @@ -224,34 +224,29 @@ def path_to_containers(udid, simulator)
describe "Xcode #{xcode6[:version]}" do
let(:helper) { Calabash::Rspec::ResetAppSandbox::Helper.new }

if Resources.shared.travis_ci?
it 'Skipping default simulator test on Travis CI; Simulator environment is not stable enough' do
expect(true).to be == true
end
else
it 'can reset the default simulator' do
ENV['DEVELOPER_DIR'] = xcode6[:path]
sim_control = RunLoop::SimControl.new
helper.launch_and_stop_simulator(launcher, sim_control, 'simulator')
it 'can reset the default simulator' do
ENV['DEVELOPER_DIR'] = xcode6[:path]
sim_control = RunLoop::SimControl.new
helper.launch_and_stop_simulator(launcher, sim_control, 'simulator')

target_simulator = helper.default_simulator_as_device(sim_control)
udid = target_simulator.udid
target_simulator = helper.default_simulator_as_device(sim_control)
udid = target_simulator.udid

app_bundles = helper.path_to_sim_app_bundles(udid, target_simulator)
expect(File).to exist(app_bundles)
app_bundles = helper.path_to_sim_app_bundles(udid, target_simulator)
expect(File).to exist(app_bundles)

installed_apps = helper.installed_apps(udid, target_simulator)
expect(installed_apps).to include('LPSimpleExample-cal.app')
installed_apps = helper.installed_apps(udid, target_simulator)
expect(installed_apps).to include('LPSimpleExample-cal.app')

launcher.reset_app_sandbox
launcher.reset_app_sandbox

containers = helper.path_to_containers(udid, target_simulator)
expect(File).not_to exist(containers)
end
containers = helper.path_to_containers(udid, target_simulator)
expect(File).not_to exist(containers)
end

describe 'can reset a simulator if :udid option is passed' do
helper = Calabash::Rspec::ResetAppSandbox::Helper.new
ENV['DEVELOPER_DIR'] = xcode6[:path]
sim_control = RunLoop::SimControl.new
target_simulator = helper.random_core_simulator(sim_control)
instruments_launch_name = helper.instruments_launch_name(target_simulator)
Expand All @@ -276,6 +271,7 @@ def path_to_containers(udid, simulator)

describe 'respects the DEVICE_TARGET env var' do
helper = Calabash::Rspec::ResetAppSandbox::Helper.new
ENV['DEVELOPER_DIR'] = xcode6[:path]
sim_control = RunLoop::SimControl.new
target_simulator = helper.random_core_simulator(sim_control)
instruments_launch_name = helper.instruments_launch_name(target_simulator)
Expand Down
Loading