calabash-cucumber 0.16.2 → 0.16.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c76734ed962d6499a9320be6098ff8fc9bd2a00e
|
4
|
+
data.tar.gz: 5899f941d20500625327f94c9070f2bfe4db1573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b12531775965c0f235935bbbd35bd81f95dc56a46102b12de4139781cea0cc1a9392f6dd1b8803972484668797d49b4c900fce3ea9ed8e618581e5dd2783ed72
|
7
|
+
data.tar.gz: a65e9bf5bfb413bb127a1f8e375a72ae38575e448a1c2ec68067749cb671875c8c75769a2d588b65dffe5dfb3ebbb42ad28035e2497bdab640b1f125e24e821f
|
@@ -143,6 +143,21 @@ module Calabash
|
|
143
143
|
RunLoop::Version.new(_default_device_or_create.ios_version)
|
144
144
|
end
|
145
145
|
|
146
|
+
# The screen dimensions of the device under test.
|
147
|
+
#
|
148
|
+
# This is a hash of form:
|
149
|
+
# {
|
150
|
+
# :sample => 1,
|
151
|
+
# :height => 1334,
|
152
|
+
# :width => 750,
|
153
|
+
# :scale" => 2
|
154
|
+
# }
|
155
|
+
# @raise [RuntimeError] If the server cannot be reached.
|
156
|
+
# @return [RunLoop::Version] The version of the iOS running on the device.
|
157
|
+
def screen_dimensions
|
158
|
+
_default_device_or_create.screen_dimensions
|
159
|
+
end
|
160
|
+
|
146
161
|
# Is the device under test running iOS 5?
|
147
162
|
#
|
148
163
|
# @note
|
@@ -6,6 +6,18 @@ require 'calabash-cucumber/utils/logging'
|
|
6
6
|
|
7
7
|
module Calabash
|
8
8
|
module Cucumber
|
9
|
+
|
10
|
+
|
11
|
+
# Raised when there is a problem involving a keyboard mode. There are
|
12
|
+
# three keyboard modes: docked, split, and undocked.
|
13
|
+
#
|
14
|
+
# All iPads support these keyboard modes, but the user can disable them
|
15
|
+
# in Settings.app.
|
16
|
+
#
|
17
|
+
# The iPhone 6+ family also supports keyboard modes, but Calabash does
|
18
|
+
# support keyboard modes on these devices.
|
19
|
+
class KeyboardModeError < StandardError; ; end
|
20
|
+
|
9
21
|
# Collection of methods for interacting with the keyboard.
|
10
22
|
#
|
11
23
|
# We've gone to great lengths to provide the fastest keyboard entry possible.
|
@@ -80,36 +92,23 @@ module Calabash
|
|
80
92
|
# @return [Boolean] if a keyboard is visible and docked.
|
81
93
|
def docked_keyboard_visible?
|
82
94
|
res = query(_qstr_for_keyboard).first
|
95
|
+
|
83
96
|
return false if res.nil?
|
84
97
|
|
85
98
|
return true if device_family_iphone?
|
86
99
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
when :right
|
97
|
-
if ios8?
|
98
|
-
rect['center_x'] == 512 and rect['center_y'] == 592
|
99
|
-
else
|
100
|
-
rect['center_x'] == 176 and rect['center_y'] == 512
|
101
|
-
end
|
102
|
-
when :up
|
103
|
-
if ios8?
|
104
|
-
rect['center_x'] == 384 and rect['center_y'] == 892
|
105
|
-
else
|
106
|
-
rect['center_x'] == 384 and rect['center_y'] == 132
|
107
|
-
end
|
108
|
-
when :down
|
109
|
-
rect['center_x'] == 384 and rect['center_y'] == 892
|
110
|
-
else
|
111
|
-
false
|
100
|
+
orientation = status_bar_orientation.to_sym
|
101
|
+
keyboard_height = res['rect']['height']
|
102
|
+
keyboard_y = res['rect']['y']
|
103
|
+
scale = screen_dimensions[:scale]
|
104
|
+
|
105
|
+
if orientation == :left || orientation == :right
|
106
|
+
screen_height = screen_dimensions[:width]/scale
|
107
|
+
else
|
108
|
+
screen_height = screen_dimensions[:height]/scale
|
112
109
|
end
|
110
|
+
|
111
|
+
screen_height - keyboard_height == keyboard_y
|
113
112
|
end
|
114
113
|
|
115
114
|
# Returns true if an undocked keyboard is visible.
|
@@ -593,10 +592,6 @@ module Calabash
|
|
593
592
|
res = send_uia_command({:command => "#{_query_uia_hide_keyboard_button}.rect()"})
|
594
593
|
origin = res['value']['origin']
|
595
594
|
{:x => origin['x'], :y => origin['y']}
|
596
|
-
|
597
|
-
# this did not work.
|
598
|
-
#size = res['value']['size']
|
599
|
-
#{:x => (origin['x'] (size['width']/2)), :y => (origin['y'] (size['height']/2))}
|
600
595
|
end
|
601
596
|
|
602
597
|
# @!visibility private
|
@@ -700,8 +695,10 @@ module Calabash
|
|
700
695
|
# there are 10 pt btw the key and the popup and each row is 50 pt
|
701
696
|
# NB: no amount of offsetting seems to allow touching the top row
|
702
697
|
# when the keyboard is split
|
698
|
+
|
699
|
+
x_offset = 40
|
703
700
|
y_offset = 10 + 50 + 25
|
704
|
-
end_pt = {:x => (start_pt[:x] -
|
701
|
+
end_pt = {:x => (start_pt[:x] - x_offset), :y => (start_pt[:y] - y_offset)}
|
705
702
|
uia_pan_offset(start_pt, end_pt, {:duration => 1.0})
|
706
703
|
else
|
707
704
|
pan(_query_for_keyboard_mode_key, nil, {})
|
@@ -726,15 +723,23 @@ module Calabash
|
|
726
723
|
return if device_family_iphone?
|
727
724
|
|
728
725
|
mode = ipad_keyboard_mode
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
726
|
+
|
727
|
+
return if mode == :docked
|
728
|
+
|
729
|
+
if ios9?
|
730
|
+
raise KeyboardModeError,
|
731
|
+
'Changing keyboard modes is not supported on iOS 9'
|
732
|
+
else
|
733
|
+
case mode
|
734
|
+
when :split then
|
735
|
+
_touch_bottom_keyboard_mode_row
|
736
|
+
when :undocked then
|
737
|
+
_touch_top_keyboard_mode_row
|
738
|
+
when :docked then
|
739
|
+
# already docked
|
740
|
+
else
|
741
|
+
screenshot_and_raise "expected '#{mode}' to be one of #{_ipad_keyboard_modes}"
|
742
|
+
end
|
738
743
|
end
|
739
744
|
|
740
745
|
begin
|
@@ -748,7 +753,6 @@ module Calabash
|
|
748
753
|
end
|
749
754
|
end
|
750
755
|
|
751
|
-
|
752
756
|
# Ensures that the iPad keyboard is undocked.
|
753
757
|
#
|
754
758
|
# Undocked means the keyboard is floating in the middle of the view.
|
@@ -762,35 +766,42 @@ module Calabash
|
|
762
766
|
# @raise [RuntimeError] if there is no visible keyboard
|
763
767
|
# @raise [RuntimeError] an undocked keyboard was not achieved
|
764
768
|
def ensure_undocked_keyboard
|
765
|
-
wait_for_keyboard
|
769
|
+
wait_for_keyboard
|
766
770
|
|
767
771
|
return if device_family_iphone?
|
768
772
|
|
769
773
|
mode = ipad_keyboard_mode
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
774
|
+
|
775
|
+
return if mode == :undocked
|
776
|
+
|
777
|
+
if ios9?
|
778
|
+
raise KeyboardModeError,
|
779
|
+
'Changing keyboard modes is not supported on iOS 9'
|
780
|
+
else
|
781
|
+
case mode
|
782
|
+
when :split then
|
783
|
+
# keep these condition separate because even though they do the same
|
784
|
+
# thing, the else condition is a hack
|
785
|
+
if ios5?
|
786
|
+
# iOS 5 has no 'Merge' feature in split keyboard, so dock first then
|
787
|
+
# undock from docked mode
|
788
|
+
_touch_bottom_keyboard_mode_row
|
789
|
+
_wait_for_keyboard_in_mode(:docked)
|
790
|
+
else
|
791
|
+
# in iOS > 5, it seems to be impossible consistently touch the
|
792
|
+
# the top keyboard mode popup button, so we punt
|
793
|
+
_touch_bottom_keyboard_mode_row
|
794
|
+
_wait_for_keyboard_in_mode(:docked)
|
795
|
+
end
|
796
|
+
_touch_top_keyboard_mode_row
|
797
|
+
when :undocked then
|
798
|
+
# already undocked
|
799
|
+
when :docked then
|
800
|
+
_touch_top_keyboard_mode_row
|
779
801
|
else
|
780
|
-
|
781
|
-
|
782
|
-
_touch_bottom_keyboard_mode_row
|
783
|
-
_wait_for_keyboard_in_mode(:docked)
|
784
|
-
end
|
785
|
-
_touch_top_keyboard_mode_row
|
786
|
-
when :undocked then
|
787
|
-
# already undocked
|
788
|
-
when :docked then
|
789
|
-
_touch_top_keyboard_mode_row
|
790
|
-
else
|
791
|
-
screenshot_and_raise "expected '#{mode}' to be one of #{_ipad_keyboard_modes}"
|
802
|
+
screenshot_and_raise "expected '#{mode}' to be one of #{_ipad_keyboard_modes}"
|
803
|
+
end
|
792
804
|
end
|
793
|
-
|
794
805
|
_wait_for_keyboard_in_mode(:undocked)
|
795
806
|
end
|
796
807
|
|
@@ -814,17 +825,24 @@ module Calabash
|
|
814
825
|
return if device_family_iphone?
|
815
826
|
|
816
827
|
mode = ipad_keyboard_mode
|
817
|
-
case mode
|
818
|
-
when :split then
|
819
|
-
# already split
|
820
|
-
when :undocked then
|
821
|
-
_touch_bottom_keyboard_mode_row
|
822
|
-
when :docked then
|
823
|
-
_touch_bottom_keyboard_mode_row
|
824
|
-
else
|
825
|
-
screenshot_and_raise "expected '#{mode}' to be one of #{_ipad_keyboard_modes}"
|
826
|
-
end
|
827
828
|
|
829
|
+
return if mode == :split
|
830
|
+
|
831
|
+
if ios9?
|
832
|
+
raise KeyboardModeError,
|
833
|
+
'Changing keyboard modes is not supported on iOS 9'
|
834
|
+
else
|
835
|
+
case mode
|
836
|
+
when :split then
|
837
|
+
# already split
|
838
|
+
when :undocked then
|
839
|
+
_touch_bottom_keyboard_mode_row
|
840
|
+
when :docked then
|
841
|
+
_touch_bottom_keyboard_mode_row
|
842
|
+
else
|
843
|
+
screenshot_and_raise "expected '#{mode}' to be one of #{_ipad_keyboard_modes}"
|
844
|
+
end
|
845
|
+
end
|
828
846
|
_wait_for_keyboard_in_mode(:split)
|
829
847
|
end
|
830
848
|
|
@@ -277,16 +277,16 @@ class Calabash::Cucumber::Launcher
|
|
277
277
|
merged_opts = default_opts.merge opts
|
278
278
|
|
279
279
|
sim_control = opts.fetch(:sim_control, RunLoop::SimControl.new)
|
280
|
+
xcode = sim_control.xcode
|
281
|
+
|
280
282
|
if sim_control.xcode_version_gte_6?
|
281
283
|
default_sim = RunLoop::Core.default_simulator(xcode)
|
282
284
|
name_or_udid = merged_opts[:udid] || ENV['DEVICE_TARGET'] || default_sim
|
283
285
|
|
284
|
-
target_simulator =
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
target_simulator = device
|
289
|
-
end
|
286
|
+
target_simulator = sim_control.simulators.find do |sim|
|
287
|
+
[name_or_udid == sim.instruments_identifier(xcode),
|
288
|
+
name_or_udid == sim.udid,
|
289
|
+
name_or_udid == sim.name].any?
|
290
290
|
end
|
291
291
|
|
292
292
|
if target_simulator.nil?
|