lib/calabash-cucumber/actions/instruments_actions.rb in calabash-cucumber-0.11.1 vs lib/calabash-cucumber/actions/instruments_actions.rb in calabash-cucumber-0.11.2
- old
+ new
@@ -119,21 +119,29 @@
# @!visibility private
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']
rect['center_x'] = rect['center_y']
rect['center_y'] = screen_size[:width] - cx
@@ -148,7 +156,6 @@
rect['center_x'] = screen_size[:width] - cx
else
# no-op by design.
end
end
-
-end
\ No newline at end of file
+end