calabash 1.9.9.pre3 → 2.0.0.prelegacy

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -33
  3. data/bin/calabash +45 -36
  4. data/lib/calabash.rb +137 -13
  5. data/lib/calabash/android.rb +6 -0
  6. data/lib/calabash/android/adb.rb +25 -1
  7. data/lib/calabash/android/application.rb +14 -3
  8. data/lib/calabash/android/build/builder.rb +16 -3
  9. data/lib/calabash/android/build/java_keystore.rb +10 -0
  10. data/lib/calabash/android/build/resigner.rb +23 -1
  11. data/lib/calabash/android/build/test_server.rb +2 -0
  12. data/lib/calabash/android/defaults.rb +1 -0
  13. data/lib/calabash/android/device.rb +55 -3
  14. data/lib/calabash/android/environment.rb +10 -0
  15. data/lib/calabash/android/interactions.rb +106 -3
  16. data/lib/calabash/android/legacy.rb +143 -0
  17. data/lib/calabash/android/lib/TestServer.apk +0 -0
  18. data/lib/calabash/android/life_cycle.rb +6 -4
  19. data/lib/calabash/android/physical_buttons.rb +12 -1
  20. data/lib/calabash/android/screenshot.rb +1 -0
  21. data/lib/calabash/android/scroll.rb +115 -0
  22. data/lib/calabash/android/server.rb +3 -1
  23. data/lib/calabash/android/text.rb +16 -25
  24. data/lib/calabash/application.rb +29 -0
  25. data/lib/calabash/cli/build.rb +15 -1
  26. data/lib/calabash/cli/console.rb +9 -5
  27. data/lib/calabash/cli/generate.rb +5 -0
  28. data/lib/calabash/cli/helpers.rb +7 -1
  29. data/lib/calabash/cli/resign.rb +1 -0
  30. data/lib/calabash/cli/run.rb +10 -6
  31. data/lib/calabash/cli/setup_keystore.rb +2 -0
  32. data/lib/calabash/color.rb +7 -0
  33. data/lib/calabash/console_helpers.rb +4 -2
  34. data/lib/calabash/defaults.rb +1 -0
  35. data/lib/calabash/device.rb +8 -9
  36. data/lib/calabash/environment.rb +5 -0
  37. data/lib/calabash/gestures.rb +159 -66
  38. data/lib/calabash/http/retriable_client.rb +3 -1
  39. data/lib/calabash/interactions.rb +68 -5
  40. data/lib/calabash/ios.rb +4 -0
  41. data/lib/calabash/ios/application.rb +8 -1
  42. data/lib/calabash/ios/conditions.rb +3 -1
  43. data/lib/calabash/ios/date_picker.rb +412 -0
  44. data/lib/calabash/ios/defaults.rb +1 -0
  45. data/lib/calabash/ios/device.rb +1 -0
  46. data/lib/calabash/ios/device/device_implementation.rb +33 -16
  47. data/lib/calabash/ios/device/gestures_mixin.rb +202 -48
  48. data/lib/calabash/ios/device/ipad_1x_2x_mixin.rb +253 -0
  49. data/lib/calabash/ios/device/keyboard_mixin.rb +2 -0
  50. data/lib/calabash/ios/device/rotation_mixin.rb +11 -8
  51. data/lib/calabash/ios/device/routes/condition_route_mixin.rb +1 -0
  52. data/lib/calabash/ios/device/routes/handle_route_mixin.rb +5 -1
  53. data/lib/calabash/ios/device/routes/map_route_mixin.rb +1 -0
  54. data/lib/calabash/ios/device/routes/response_parser.rb +1 -0
  55. data/lib/calabash/ios/device/routes/uia_route_mixin.rb +44 -6
  56. data/lib/calabash/ios/device/runtime_attributes.rb +4 -5
  57. data/lib/calabash/ios/device/text_mixin.rb +2 -0
  58. data/lib/calabash/ios/device/uia_keyboard_mixin.rb +9 -0
  59. data/lib/calabash/ios/device/uia_mixin.rb +1 -0
  60. data/lib/calabash/ios/gestures.rb +82 -8
  61. data/lib/calabash/ios/interactions.rb +30 -1
  62. data/lib/calabash/ios/orientation.rb +21 -21
  63. data/lib/calabash/ios/runtime.rb +154 -2
  64. data/lib/calabash/ios/slider.rb +70 -0
  65. data/lib/calabash/ios/text.rb +11 -47
  66. data/lib/calabash/ios/uia.rb +24 -2
  67. data/lib/calabash/legacy.rb +7 -0
  68. data/lib/calabash/lib/skeleton/config/cucumber.yml +1 -3
  69. data/lib/calabash/lib/skeleton/features/support/dry_run.rb +8 -0
  70. data/lib/calabash/lib/skeleton/features/support/env.rb +15 -1
  71. data/lib/calabash/life_cycle.rb +78 -32
  72. data/lib/calabash/location.rb +2 -1
  73. data/lib/calabash/orientation.rb +0 -1
  74. data/lib/calabash/page.rb +51 -5
  75. data/lib/calabash/patch.rb +1 -0
  76. data/lib/calabash/patch/array.rb +7 -7
  77. data/lib/calabash/query.rb +17 -2
  78. data/lib/calabash/query_result.rb +14 -0
  79. data/lib/calabash/screenshot.rb +28 -8
  80. data/lib/calabash/text.rb +105 -8
  81. data/lib/calabash/utility.rb +6 -6
  82. data/lib/calabash/version.rb +1 -1
  83. data/lib/calabash/wait.rb +37 -11
  84. metadata +14 -7
@@ -2,10 +2,24 @@ module Calabash
2
2
  module CLI
3
3
  # @!visibility private
4
4
  module Build
5
+ # @!visibility private
5
6
  def parse_build_arguments!
6
7
  fail('Should only build test-server for Android') unless @platform.nil? || @platform == :android
7
8
 
8
9
  application = @arguments.shift
10
+ test_server_path = nil
11
+
12
+ arg = @arguments.shift
13
+
14
+ if arg != nil
15
+ if arg == '-o'
16
+ test_server_path = @arguments.shift
17
+
18
+ if test_server_path == nil
19
+ raise 'Expected an output path for the test-server'
20
+ end
21
+ end
22
+ end
9
23
 
10
24
  if application.nil?
11
25
  fail('Must supply application as first parameter to build', :build)
@@ -18,7 +32,7 @@ module Calabash
18
32
  case extension
19
33
  when '.apk'
20
34
  set_platform!(:android)
21
- Calabash::Android::Build::Builder.new(application_path).build
35
+ Calabash::Android::Build::Builder.new(application_path).build(test_server_path)
22
36
  when '.ipa', '.app'
23
37
  set_platform!(:ios)
24
38
  fail('Should only build test-server for Android')
@@ -3,6 +3,7 @@ module Calabash
3
3
  module CLI
4
4
  # @!visibility private
5
5
  module Console
6
+ # @!visibility private
6
7
  def parse_console_arguments!
7
8
  application = @arguments.shift
8
9
 
@@ -22,12 +23,14 @@ module Calabash
22
23
  when '.apk'
23
24
  set_platform!(:android)
24
25
 
25
- # Create the test server if it does not exist
26
- test_server = Android::Build::TestServer.new(application_path)
26
+ unless Environment::TEST_SERVER_PATH
27
+ # Create the test server if it does not exist
28
+ test_server = Android::Build::TestServer.new(application_path)
27
29
 
28
- unless test_server.exists?
29
- Logger.info('Test server does not exist. Creating test server.')
30
- Calabash::Android::Build::Builder.new(application_path).build
30
+ unless test_server.exists?
31
+ Logger.info('Test server does not exist. Creating test server.')
32
+ Calabash::Android::Build::Builder.new(application_path).build
33
+ end
31
34
  end
32
35
 
33
36
  enter_console(application_path)
@@ -45,6 +48,7 @@ module Calabash
45
48
  end
46
49
  end
47
50
 
51
+ # @!visibility private
48
52
  def enter_console(application_path)
49
53
  irbrc_path = Environment::IRBRC
50
54
 
@@ -5,6 +5,7 @@ module Calabash
5
5
  module CLI
6
6
  # @!visibility private
7
7
  module Generate
8
+ # @!visibility private
8
9
  def parse_generate_arguments!
9
10
  if File.exist?('features')
10
11
  puts "A features directory already exists. Please remove this to continue."
@@ -22,6 +23,7 @@ module Calabash
22
23
  cucumber_config = File.read(file(File.join('config', 'cucumber.yml')))
23
24
 
24
25
  env = File.read(file(File.join('features', 'support', 'env.rb')))
26
+ dry_run = File.read(file(File.join('features', 'support', 'dry_run.rb')))
25
27
  sample_feature = File.read(file(File.join('features', 'sample.feature')))
26
28
  calabash_steps = File.read(file(File.join('features', 'step_definitions', 'calabash_steps.rb')))
27
29
 
@@ -46,6 +48,7 @@ module Calabash
46
48
  File.open(File.join('features', 'step_definitions', 'calabash_steps.rb'), 'w') {|file| file.write(calabash_steps) }
47
49
  File.open(File.join('features', 'support', 'hooks.rb'), 'w') {|file| file.write(hooks) }
48
50
  File.open(File.join('features', 'support', 'env.rb'), 'w') {|file| file.write(env) }
51
+ File.open(File.join('features', 'support', 'dry_run.rb'), 'w') {|file| file.write(dry_run) }
49
52
 
50
53
  gemfile = File.readlines(file(File.join('Gemfile')))
51
54
 
@@ -68,10 +71,12 @@ module Calabash
68
71
  end
69
72
  end
70
73
 
74
+ # @!visibility private
71
75
  def file(file)
72
76
  File.join(Calabash::Environment::SKELETON_DIR_PATH, file)
73
77
  end
74
78
 
79
+ # @!visibility private
75
80
  def msg(title, &block)
76
81
  puts "\n" + "-"*10 + title + "-"*10
77
82
  block.call
@@ -3,6 +3,7 @@ module Calabash
3
3
  module CLI
4
4
  # @!visibility private
5
5
  module Helpers
6
+ # @!visibility private
6
7
  HELP = {
7
8
  help: 'help',
8
9
  generate: 'generate',
@@ -14,6 +15,7 @@ module Calabash
14
15
  build: 'build <apk>'
15
16
  }
16
17
 
18
+ # @!visibility private
17
19
  def key_for_command(command)
18
20
  HELP.each do |key, value|
19
21
  if value.split(' ').first == command
@@ -24,6 +26,7 @@ module Calabash
24
26
  nil
25
27
  end
26
28
 
29
+ # @!visibility private
27
30
  def print_usage_for(key, output=STDOUT)
28
31
  if key.nil? || HELP[key].nil?
29
32
  output.write <<EOF
@@ -37,6 +40,7 @@ EOF
37
40
  end
38
41
  end
39
42
 
43
+ # @!visibility private
40
44
  def print_usage(output=STDOUT)
41
45
  output.write <<EOF
42
46
  Usage: calabash [options] <command-name> [command specific options]
@@ -64,7 +68,7 @@ EOF
64
68
  #{HELP[:resign]}
65
69
  resigns the app with the currently configured keystore.
66
70
 
67
- #{HELP[:build]}
71
+ #{HELP[:build]} [-o <output_file>]
68
72
  builds the test server that will be used when testing the app.
69
73
 
70
74
  iOS specific commands
@@ -101,11 +105,13 @@ EOF
101
105
  EOF
102
106
  end
103
107
 
108
+ # @!visibility private
104
109
  def help
105
110
  file_name = File.join(File.dirname(__FILE__), '..', 'doc', 'calabash_help.txt')
106
111
  system("less \"#{file_name}\"")
107
112
  end
108
113
 
114
+ # @!visibility private
109
115
  def fail(reason, command=nil)
110
116
  STDERR.write("#{reason}\n")
111
117
 
@@ -3,6 +3,7 @@ module Calabash
3
3
  module CLI
4
4
  # @!visibility private
5
5
  module Resign
6
+ # @!visibility private
6
7
  def parse_resign_arguments!
7
8
  fail('Can only resign Android applications') unless @platform.nil? || @platform == :android
8
9
 
@@ -3,6 +3,7 @@ module Calabash
3
3
  module CLI
4
4
  # @!visibility private
5
5
  module Run
6
+ # @!visibility private
6
7
  def parse_run_arguments!
7
8
  first_argument = @arguments.first # Do not remove the entry from the arguments yet - it might be a cucumber arg
8
9
 
@@ -30,12 +31,14 @@ module Calabash
30
31
  when '.apk'
31
32
  set_platform!(:android)
32
33
 
33
- # Create the test server if it does not exist
34
- test_server = Android::Build::TestServer.new(application_path)
34
+ unless Environment::TEST_SERVER_PATH
35
+ # Create the test server if it does not exist
36
+ test_server = Android::Build::TestServer.new(application_path)
35
37
 
36
- unless test_server.exists?
37
- Logger.info('Test server does not exist. Creating test server.')
38
- Calabash::Android::Build::Builder.new(application_path).build
38
+ unless test_server.exists?
39
+ Logger.info('Test server does not exist. Creating test server.')
40
+ Calabash::Android::Build::Builder.new(application_path).build
41
+ end
39
42
  end
40
43
 
41
44
  run(application_path, @arguments)
@@ -54,6 +57,7 @@ module Calabash
54
57
  end
55
58
  end
56
59
 
60
+ # @!visibility private
57
61
  def run(application_path, cucumber_arguments)
58
62
  cucumber_environment = {}
59
63
  cucumber_environment['CAL_DEBUG'] = Environment::DEBUG ? '1' : '0'
@@ -88,7 +92,7 @@ module Calabash
88
92
  end
89
93
  end
90
94
 
91
- arguments = ['-S', 'cucumber', '-p', @platform.to_s, *cucumber_arguments]
95
+ arguments = ['-S', 'cucumber', *cucumber_arguments]
92
96
 
93
97
  Logger.debug("Starting Ruby with arguments: #{arguments.join(', ')} and environment #{cucumber_environment.to_s}")
94
98
 
@@ -6,6 +6,7 @@ module Calabash
6
6
  module CLI
7
7
  # @!visibility private
8
8
  module SetupKeystore
9
+ # @!visibility private
9
10
  def parse_setup_keystore_arguments!
10
11
  set_platform!(:android)
11
12
 
@@ -25,6 +26,7 @@ module Calabash
25
26
  puts "Saved your settings to '#{Android::Build::JavaKeystore::CALABASH_KEYSTORE_SETTINGS_FILENAME}'. You can edit the settings manually or run this setup script again"
26
27
  end
27
28
 
29
+ # @!visibility private
28
30
  def prompt(message, secure = false)
29
31
  puts message
30
32
 
@@ -1,30 +1,37 @@
1
1
  module Calabash
2
2
  # @!visibility private
3
3
  module Color
4
+ # @!visibility private
4
5
  def self.colorize(string, color)
5
6
  "\e[#{color}m#{string}\e[0m"
6
7
  end
7
8
 
9
+ # @!visibility private
8
10
  def self.red(string)
9
11
  colorize(string, 31)
10
12
  end
11
13
 
14
+ # @!visibility private
12
15
  def self.green(string)
13
16
  colorize(string, 32)
14
17
  end
15
18
 
19
+ # @!visibility private
16
20
  def self.yellow(string)
17
21
  colorize(string, 33)
18
22
  end
19
23
 
24
+ # @!visibility private
20
25
  def self.blue(string)
21
26
  colorize(string, 34)
22
27
  end
23
28
 
29
+ # @!visibility private
24
30
  def self.magenta(string)
25
31
  colorize(string, 35)
26
32
  end
27
33
 
34
+ # @!visibility private
28
35
  def self.cyan(string)
29
36
  colorize(string, 36)
30
37
  end
@@ -4,7 +4,6 @@ module Calabash
4
4
 
5
5
  # Methods you can use in the Calabash console to help you
6
6
  # interact with your app.
7
- # @!visibility private
8
7
  module ConsoleHelpers
9
8
 
10
9
  # Outputs all visible elements as a tree.
@@ -30,13 +29,15 @@ module Calabash
30
29
  true
31
30
  end
32
31
 
33
- # Clear the console.
32
+ # Clear the console history. Note that this also clears the contents
33
+ # given to Calabash::ConsoleHelpers#copy.
34
34
  def clear
35
35
  ConsoleHelpers.clear
36
36
  true
37
37
  end
38
38
 
39
39
  # Puts a message of the day.
40
+ # @!visibility private
40
41
  def message_of_the_day
41
42
  messages = [
42
43
  "Let's get this done!",
@@ -141,6 +142,7 @@ module Calabash
141
142
  readline_history.last(length)
142
143
  end
143
144
 
145
+ # @!visibility private
144
146
  FILTER_REGEX = Regexp.union(/\s*copy(\(|\z)/, /\s*tree(\(|\z)/,
145
147
  /\s*flash(\(|\z)/, /\s*classes(\(|\z)/,
146
148
  /\s*ids(\(|\z)/, /\s*start_app(\(|\z)/,
@@ -1,4 +1,5 @@
1
1
  module Calabash
2
+ # Runtime defaults.
2
3
  module Defaults
3
4
  # Get the default device. The device represents a physical device,
4
5
  # an emulator, or a simulator. Calabash will communicate with this
@@ -1,4 +1,6 @@
1
1
  module Calabash
2
+ # A model of the device under test. Can be a physical Android or iOS device,
3
+ # an Android emulator, or an iOS simulator.
2
4
  class Device
3
5
  include Utility
4
6
 
@@ -138,9 +140,6 @@ module Calabash
138
140
  gesture_options[:at] ||= {}
139
141
  gesture_options[:at][:x] ||= 50
140
142
  gesture_options[:at][:y] ||= 50
141
- gesture_options[:offset] ||= {}
142
- gesture_options[:offset][:x] ||= 0
143
- gesture_options[:offset][:y] ||= 0
144
143
  gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
145
144
 
146
145
  _tap(query, gesture_options)
@@ -156,9 +155,6 @@ module Calabash
156
155
  gesture_options[:at] ||= {}
157
156
  gesture_options[:at][:x] ||= 50
158
157
  gesture_options[:at][:y] ||= 50
159
- gesture_options[:offset] ||= {}
160
- gesture_options[:offset][:x] ||= 0
161
- gesture_options[:offset][:y] ||= 0
162
158
  gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
163
159
 
164
160
  _double_tap(query, gesture_options)
@@ -174,9 +170,6 @@ module Calabash
174
170
  gesture_options[:at] ||= {}
175
171
  gesture_options[:at][:x] ||= 50
176
172
  gesture_options[:at][:y] ||= 50
177
- gesture_options[:offset] ||= {}
178
- gesture_options[:offset][:x] ||= 0
179
- gesture_options[:offset][:y] ||= 0
180
173
  gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
181
174
  gesture_options[:duration] ||= 1
182
175
 
@@ -237,6 +230,7 @@ module Calabash
237
230
  end
238
231
 
239
232
  gesture_options = options.dup
233
+ gesture_options[:duration] ||= 0.5
240
234
  gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
241
235
 
242
236
  _pinch(direction, query, gesture_options)
@@ -259,6 +253,11 @@ module Calabash
259
253
  abstract_method!
260
254
  end
261
255
 
256
+ # @!visibility private
257
+ def keyboard_visible?
258
+ abstract_method!
259
+ end
260
+
262
261
  private
263
262
 
264
263
  # @!visibility private
@@ -11,6 +11,7 @@ module Calabash
11
11
  ENV[name]
12
12
  end
13
13
 
14
+ # @!visibility private
14
15
  # Utility method to set the value of an environment variable.
15
16
  #
16
17
  # @param [String] name of the environment variable
@@ -30,6 +31,10 @@ module Calabash
30
31
  # Is Calabash running in debug mode. True if $CAL_DEBUG is '1'
31
32
  DEBUG = variable('CAL_DEBUG') == '1'
32
33
 
34
+ # @!visibility private
35
+ # Experimental! Print every method that is called in Calabash
36
+ DEBUG_CALLED_METHODS = variable('CAL_DEBUG_CALLED_METHODS') == '1'
37
+
33
38
  # The path of the default app under test. This value is used if no app is
34
39
  # given from the command line. e.g. $ calabash run.
35
40
  #
@@ -1,16 +1,20 @@
1
1
  module Calabash
2
- # Methods for performing gestures. Gestures are taps, flicks,
3
- # and pans.
2
+ # Methods for performing gestures. Gestures are taps, flicks, and pans.
4
3
  #
5
4
  # Many gestures take an optional :duration. On iOS, the duration must be
6
5
  # between 0.5 and 60 (seconds). This is a limitation of the UIAutomation API.
6
+ #
7
+ # @note All gestures have _undefined return values._ This is intentional.
8
+ # Please do not rely on return values of gestures in your tests. For
9
+ # convenience when working in the console, some gestures return sensible
10
+ # values. However, these values are subject to change.
7
11
  module Gestures
8
12
 
9
13
  # How long do we wait for a view to appear by default when performing a
10
14
  # gesture.
11
15
  DEFAULT_GESTURE_WAIT_TIMEOUT = 3
12
16
 
13
- # Performs a `tap` on the (first) view that matches `query`.
17
+ # Performs a **tap** on the first view that matches `query`.
14
18
  #
15
19
  # Taps the center of the view by default.
16
20
  #
@@ -19,33 +23,25 @@ module Calabash
19
23
  #
20
24
  # ┬ ┌─────────────────────────────────────┐
21
25
  # | │2 3│
22
- # | │ 4
26
+ # | │
23
27
  # | │ │
24
28
  # 200 px │ 1 │
25
29
  # | │ │
26
- # | │ 7 5 │ 6
27
30
  # | │ │
31
+ # | │ 4 │
28
32
  # ┴ └─────────────────────────────────────┘
29
33
  #
30
34
  # 1. tap("* marked:'email'")
31
35
  # 2. tap("* marked:'email'", at: {x: 0, y: 0})
32
36
  # 3. tap("* marked:'email'", at: {x: 100, y: 0})
33
- # 4. tap("* marked:'email'", offset: {y: -40})
34
- # 5. tap("* marked:'email'", offset: {x: 20, y: 40})
35
- # 6. tap("* marked:'email'", at: {x: 100, y: 75}, offset: {x: 80})
36
- # 7. tap("* marked:'email'", at: {x: 50, y: 100},
37
- # offset: {x: -80, y: -40})
37
+ # 4. tap("* marked:'email'", at: {x: 50, y: 100})
38
38
  #
39
- # @param [String] query A query describing the view to tap.
39
+ # @param [String, Hash, Calabash::Query] query A query describing the view
40
+ # to tap.
40
41
  # @param [Hash] options Options for modifying the details of the touch.
41
42
  # @option options [Hash] :at ({x: 50, y: 50}) The point at which the
42
43
  # gesture originates from. It is a percentage-based translation using
43
- # top-left `(0,0)` as the reference point. This translation is always
44
- # applied before any `:offset`.
45
- # @option options [Hash] :offset ({x: 0, y: 0}) Offset to touch point.
46
- # Offset supports an `:x` and `:y` key and causes the touch to be
47
- # offset with `(x,y)`. This offset is always applied _after_ any
48
- # translation performed by `:at`.
44
+ # top-left `(0,0)` as the reference point.
49
45
  # @raise [ViewNotFoundError] If the `query` returns no results.
50
46
  # @raise [ArgumentError] If `query` is invalid.
51
47
  def tap(query, options={})
@@ -54,8 +50,17 @@ module Calabash
54
50
  Device.default.tap(Query.new(query), options)
55
51
  end
56
52
 
57
- # Performs a `double_tap` on the (first) view that matches `query`.
58
- # @see tap
53
+ # Performs a **double_tap** on the first view that matches `query`.
54
+ #
55
+ # @see #tap
56
+ #
57
+ # @param [String, Hash, Calabash::Query] query A query describing the view
58
+ # to tap.
59
+ # @param [Hash] options Options for modifying the details of the touch.
60
+ # @option options [Hash] :at ({x: 50, y: 50}) The point at which the
61
+ # gesture originates from. It is a percentage-based translation using
62
+ # top-left `(0,0)` as the reference point.
63
+ #
59
64
  # @raise [ViewNotFoundError] If the `query` returns no results.
60
65
  # @raise [ArgumentError] If `query` is invalid.
61
66
  def double_tap(query, options={})
@@ -64,12 +69,14 @@ module Calabash
64
69
  Device.default.double_tap(Query.new(query), options)
65
70
  end
66
71
 
67
- # Performs a `long_press` on the (first) view that matches `query`.
72
+ # Performs a **long_press** on the first view that matches `query`.
73
+ #
68
74
  # On iOS this is often referred to as _touch-and-hold_. On Android this
69
75
  # is known variously as _press_, _long-push_, _press-and-hold_, or _hold_.
70
76
  #
71
- # @see tap
77
+ # @see #tap
72
78
  #
79
+ # @param [String] query A query describing the view to tap.
73
80
  # @param [Hash] options Options for modifying the details of the touch.
74
81
  # @option options [Number] :duration (1.0) The amount of time in seconds to
75
82
  # press. On iOS, the duration must be between 0.5 and 60.
@@ -82,11 +89,14 @@ module Calabash
82
89
  Device.default.long_press(Query.new(query), options)
83
90
  end
84
91
 
85
- # Performs a `pan` on the (first) view that matches `query`.
92
+ # Performs a **pan** on the first view that matches `query`.
93
+ #
86
94
  # A pan is a straight line swipe that pauses at the final point
87
95
  # before releasing the gesture. This is the general purpose pan method. For
88
96
  # standardized pans see `pan_left`, `pan_right`, `pan_up`, and `pan_down`.
89
97
  #
98
+ # Also known as **scroll** and **swipe**.
99
+ #
90
100
  # @example
91
101
  # Consider a pan on a scrollable view. When the finger is is released,
92
102
  # the velocity of the view is zero.
@@ -112,7 +122,8 @@ module Calabash
112
122
  # @see Calabash::IOS::Scroll#scroll_to_item
113
123
  # @see Calabash::IOS::Scroll#scroll_to_item_with_mark
114
124
  #
115
- # @param [String] query A query describing the view to pan inside.
125
+ # @param [String, Hash, Calabash::Query] query A query describing the view
126
+ # to pan inside.
116
127
  # @param [Hash] from `({:x, :y})` The point at which the gesture
117
128
  # originates from.
118
129
  # @param [Hash] to `({:x, :y})` The point at which the gesture
@@ -132,9 +143,11 @@ module Calabash
132
143
  Device.default.pan(Query.new(query), from, to, options)
133
144
  end
134
145
 
135
- # Performs a `pan` from the center of the first view that matches
146
+ # Performs a **pan** from the center of the first view that matches
136
147
  # `query_from` to the center of the first view that matches `query_to`.
137
148
  #
149
+ # Also known as **drag and drop**.
150
+ #
138
151
  # @example
139
152
  # Panning between two elements.
140
153
  # `pan_between("* id:'first'", "* id:'second'")`
@@ -171,56 +184,64 @@ module Calabash
171
184
  Device.default.pan_between(Query.new(query_from), Query.new(query_to), options)
172
185
  end
173
186
 
174
- # Performs a `pan` heading `left` on the (first) view that matches `query`.
175
- # @see pan
187
+ # Performs a **pan** heading _left_ on the first view that matches `query`.
188
+ #
189
+ # @see #pan
176
190
  def pan_left(query, options={})
177
191
  pan(query, {x: 90, y: 50}, {x: 10, y: 50}, options)
178
192
  end
179
193
 
180
- # Performs a `pan` heading `right` on the (first) view that matches
181
- # `query`.
182
- # @see pan
194
+ # Performs a **pan** heading _right_ on the first view that matches `query`.
195
+ #
196
+ # @see #pan
183
197
  def pan_right(query, options={})
184
198
  pan(query, {x: 10, y: 50}, {x: 90, y: 50}, options)
185
199
  end
186
200
 
187
- # Performs a `pan` heading `up` on the (first) view that matches `query`.
188
- # @see pan
201
+ # Performs a **pan** heading _up_ on the first view that matches `query`.
202
+ #
203
+ # @see #pan
189
204
  def pan_up(query, options={})
190
205
  pan(query, {x: 50, y: 90}, {x: 50, y: 10}, options)
191
206
  end
192
207
 
193
- # Performs a `pan` heading `down` on the (first) view that matches `query`.
194
- # @see pan
208
+ # Performs a **pan** heading _down_ on the first view that matches `query`.
209
+ #
210
+ # @see #pan
195
211
  def pan_down(query, options={})
196
212
  pan(query, {x: 50, y: 10}, {x: 50, y: 90}, options)
197
213
  end
198
214
 
199
- # Performs a `pan` heading `left` on the screen.
200
- # @see pan_left
215
+ # Performs a **pan** heading _left_ on the screen.
216
+ #
217
+ # @see #pan
201
218
  def pan_screen_left(options={})
202
219
  pan_left('*', options)
203
220
  end
204
221
 
205
- # Performs a `pan` heading `right` on the screen.
206
- # @see pan_right
222
+ # Performs a **pan** heading _right_ on the screen.
223
+ #
224
+ # @see #pan
207
225
  def pan_screen_right(options={})
208
226
  pan_right('*', options)
209
227
  end
210
228
 
211
- # Performs a `pan` heading `up` on the screen.
212
- # @see pan_up
229
+ # Performs a **pan** heading _up_ on the screen.
230
+ #
231
+ # @see #pan
213
232
  def pan_screen_up(options={})
214
233
  _pan_screen_up(options)
215
234
  end
216
235
 
217
- # Performs a `pan` heading `down` on the screen.
218
- # @see pan_down
236
+ # Performs a **pan** heading _down_ on the screen.
237
+ #
238
+ # @see #pan
219
239
  def pan_screen_down(options={})
220
240
  _pan_screen_down(options)
221
241
  end
222
242
 
223
- # Performs a `flick` on the (first) view that matches `query`.
243
+ # Performs a **flick** on the first view that matches `query`.
244
+ #
224
245
  # A flick is a straight line swipe that **lifts the finger while
225
246
  # the gesture is still in motion**. This will often cause scrollable
226
247
  # views to continue moving for some time after the gesture is released.
@@ -257,91 +278,163 @@ module Calabash
257
278
  Device.default.flick(Query.new(query), from, to, options)
258
279
  end
259
280
 
260
- # Performs a `flick` heading `left` on the (first) view that matches `query`.
261
- # @see flick
281
+ # Performs a **flick** heading _left_ on the first view that matches `query`.
282
+ # @see #flick
262
283
  def flick_left(query, options={})
263
284
  flick(query, {x: 90, y: 50}, {x: 10, y: 50}, options)
264
285
  end
265
286
 
266
- # Performs a `flick` heading `right` on the (first) view that matches
287
+ # Performs a **flick** heading _right_ on the first view that matches
267
288
  # `query`.
268
- # @see flick
289
+ # @see #flick
269
290
  def flick_right(query, options={})
270
291
  flick(query, {x: 10, y: 50}, {x: 90, y: 50}, options)
271
292
  end
272
293
 
273
- # Performs a `flick` heading `up` on the (first) view that matches `query`.
274
- # @see flick
294
+ # Performs a **flick** heading _up_ on the first view that matches `query`.
295
+ # @see #flick
275
296
  def flick_up(query, options={})
276
297
  flick(query, {x: 50, y: 90}, {x: 50, y: 10}, options)
277
298
  end
278
299
 
279
- # Performs a `flick` heading `down` on the (first) view that matches `query`.
280
- # @see flick
300
+ # Performs a **flick** heading _down_ on the first view that matches `query`.
301
+ # @see #flick
281
302
  def flick_down(query, options={})
282
303
  flick(query, {x: 50, y: 10}, {x: 50, y: 90}, options)
283
304
  end
284
305
 
285
- # Performs a `flick` heading `left` on the screen.
286
- # @see flick_left
306
+ # Performs a **flick** heading _left_ on the screen.
307
+ # @see #flick
287
308
  def flick_screen_left(options={})
288
309
  flick_left('*', options)
289
310
  end
290
311
 
291
- # Performs a `flick` heading `right` on the screen.
292
- # @see flick_right
312
+ # Performs a **flick** heading _right_ on the screen.
313
+ # @see #flick
293
314
  def flick_screen_right(options={})
294
315
  flick_right('*', options)
295
316
  end
296
317
 
297
- # Performs a `flick` heading `up` on the screen.
298
- # @see flick_up
318
+ # Performs a **flick** heading _up_ on the screen.
319
+ # @see #flick
299
320
  def flick_screen_up(options={})
300
321
  _flick_screen_up(options)
301
322
  end
302
323
 
303
- # Performs a `flick` heading `down` on the screen.
304
- # @see flick_down
324
+ # Performs a **flick** heading _down_ on the screen.
325
+ # @see #flick
305
326
  def flick_screen_down(options={})
306
327
  _flick_screen_down(options)
307
328
  end
308
329
 
309
- # Performs a `pinch` outwards.
330
+ # Performs a **pinch** outwards on the first view match by `query`.
331
+ #
332
+ # @param [String, Hash, Calabash::Query] query A query describing the view
333
+ # to pinch.
334
+ # @param [Hash] options Options for controlling the pinch.
335
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
336
+ # the duration must be between 0.5 and 60.
337
+ #
338
+ # @raise [ViewNotFoundError] If the `query` returns no results.
339
+ # @raise [ArgumentError] If `query` is invalid.
340
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
310
341
  def pinch_out(query, options={})
311
342
  Device.default.pinch(:out, query, options)
312
343
  end
313
344
 
314
- # Performs a `pinch` inwards.
345
+ # Performs a **pinch** inwards on the first view match by `query`.
346
+ #
347
+ # @param [String, Hash, Calabash::Query] query A query describing the view
348
+ # to pinch.
349
+ # @param [Hash] options Options for controlling the pinch.
350
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
351
+ # the duration must be between 0.5 and 60.
352
+ #
353
+ # @raise [ViewNotFoundError] If the `query` returns no results.
354
+ # @raise [ArgumentError] If `query` is invalid.
355
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
315
356
  def pinch_in(query, options={})
316
357
  Device.default.pinch(:in, query, options)
317
358
  end
318
359
 
319
- # Performs a `pinch` outwards on the screen.
360
+ # Performs a **pinch** outwards on the screen.
361
+ #
362
+ # @param [Hash] options Options for controlling the pinch.
363
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
364
+ # the duration must be between 0.5 and 60.
365
+ #
366
+ # @raise [ViewNotFoundError] If the `query` returns no results.
367
+ # @raise [ArgumentError] If `query` is invalid.
368
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
320
369
  def pinch_screen_out(options={})
321
370
  _pinch_screen(:out, options)
322
371
  end
323
372
 
324
- # Performs a `pinch` inwards on the screen.
373
+ # Performs a **pinch** inwards on the screen.
374
+ #
375
+ # @param [Hash] options Options for controlling the pinch.
376
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
377
+ # the duration must be between 0.5 and 60.
378
+ #
379
+ # @raise [ViewNotFoundError] If the `query` returns no results.
380
+ # @raise [ArgumentError] If `query` is invalid.
381
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
325
382
  def pinch_screen_in(options={})
326
383
  _pinch_screen(:in, options)
327
384
  end
328
385
 
329
- # Performs a `pinch` to zoom out.
386
+ # Performs a **pinch** to zoom out.
387
+ #
388
+ # @param [String, Hash, Calabash::Query] query A query describing the view
389
+ # to pinch.
390
+ # @param [Hash] options Options for controlling the pinch.
391
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
392
+ # the duration must be between 0.5 and 60.
393
+ #
394
+ # @raise [ViewNotFoundError] If the `query` returns no results.
395
+ # @raise [ArgumentError] If `query` is invalid.
396
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
330
397
  def pinch_to_zoom_out(query, options={})
331
398
  _pinch_to_zoom(:out, query, options)
332
399
  end
333
400
 
334
- # Performs a `pinch` to zoom in.
401
+ # Performs a **pinch** to zoom in.
402
+ #
403
+ # @param [String, Hash, Calabash::Query] query A query describing the view
404
+ # to pinch.
405
+ # @param [Hash] options Options for controlling the pinch.
406
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
407
+ # the duration must be between 0.5 and 60.
408
+ #
409
+ # @raise [ViewNotFoundError] If the `query` returns no results.
410
+ # @raise [ArgumentError] If `query` is invalid.
411
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
335
412
  def pinch_to_zoom_in(query, options={})
336
413
  _pinch_to_zoom(:in, query, options)
337
414
  end
338
415
 
339
- # Performs a `pinch` to zoom in on the screen.
416
+ # Performs a **pinch** on the screen to zoom in.
417
+ #
418
+ # @param [Hash] options Options for controlling the pinch.
419
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
420
+ # the duration must be between 0.5 and 60.
421
+ #
422
+ # @raise [ViewNotFoundError] If the `query` returns no results.
423
+ # @raise [ArgumentError] If `query` is invalid.
424
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
340
425
  def pinch_screen_to_zoom_in(options={})
341
426
  _pinch_screen_to_zoom(:in, options)
342
427
  end
343
428
 
344
- # Performs a `pinch` to zoom in on the screen.
429
+ # Performs a **pinch** on the screen to zoom out.
430
+ #
431
+ # @param [Hash] options Options for controlling the pinch.
432
+ # @option options [Numeric] :duration The duration of the pinch. On iOS,
433
+ # the duration must be between 0.5 and 60.
434
+ #
435
+ # @raise [ViewNotFoundError] If the `query` returns no results.
436
+ # @raise [ArgumentError] If `query` is invalid.
437
+ # @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
345
438
  def pinch_screen_to_zoom_out(options={})
346
439
  _pinch_screen_to_zoom(:out, options)
347
440
  end