calabash 2.0.0.pre10 → 2.0.0.pre11

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -17
  3. data/bin/calabash +3 -4
  4. data/lib/calabash.rb +53 -10
  5. data/lib/calabash/android.rb +89 -28
  6. data/lib/calabash/android/adb.rb +32 -20
  7. data/lib/calabash/android/application.rb +1 -1
  8. data/lib/calabash/android/build/builder.rb +1 -1
  9. data/lib/calabash/android/build/java_keystore.rb +1 -1
  10. data/lib/calabash/android/build/resigner.rb +1 -1
  11. data/lib/calabash/android/device.rb +22 -66
  12. data/lib/calabash/android/device/helper_application.rb +95 -0
  13. data/lib/calabash/android/environment.rb +14 -1
  14. data/lib/calabash/android/gestures.rb +6 -22
  15. data/lib/calabash/android/interactions.rb +14 -17
  16. data/lib/calabash/android/lib/.irbrc +9 -1
  17. data/lib/calabash/android/lib/AndroidManifest.xml +23 -2
  18. data/lib/calabash/android/lib/HelperApplication.apk +0 -0
  19. data/lib/calabash/android/lib/HelperApplicationTestServer.apk +0 -0
  20. data/lib/calabash/android/lib/TestServer.apk +0 -0
  21. data/lib/calabash/android/life_cycle.rb +3 -3
  22. data/lib/calabash/android/orientation.rb +8 -8
  23. data/lib/calabash/android/physical_buttons.rb +19 -16
  24. data/lib/calabash/android/server.rb +1 -1
  25. data/lib/calabash/android/text.rb +12 -12
  26. data/lib/calabash/android/web.rb +12 -0
  27. data/lib/calabash/application.rb +3 -0
  28. data/lib/calabash/cli/generate.rb +8 -18
  29. data/lib/calabash/cli/helpers.rb +4 -9
  30. data/lib/calabash/cli/run.rb +1 -1
  31. data/lib/calabash/console_helpers.rb +179 -11
  32. data/lib/calabash/device.rb +4 -19
  33. data/lib/calabash/gestures.rb +292 -198
  34. data/lib/calabash/interactions.rb +3 -40
  35. data/lib/calabash/internal.rb +48 -0
  36. data/lib/calabash/ios.rb +76 -16
  37. data/lib/calabash/ios/automator.rb +9 -0
  38. data/lib/calabash/ios/automator/automator.rb +217 -0
  39. data/lib/calabash/ios/automator/coordinates.rb +37 -0
  40. data/lib/calabash/ios/automator/device_agent.rb +379 -0
  41. data/lib/calabash/ios/conditions.rb +1 -1
  42. data/lib/calabash/ios/console_helpers.rb +2 -2
  43. data/lib/calabash/ios/date_picker.rb +10 -8
  44. data/lib/calabash/ios/device.rb +0 -1
  45. data/lib/calabash/ios/device/device_implementation.rb +9 -21
  46. data/lib/calabash/ios/device/gestures_mixin.rb +53 -55
  47. data/lib/calabash/ios/device/keyboard_mixin.rb +21 -0
  48. data/lib/calabash/ios/device/rotation_mixin.rb +3 -65
  49. data/lib/calabash/ios/gestures.rb +24 -90
  50. data/lib/calabash/ios/interactions.rb +1 -6
  51. data/lib/calabash/ios/lib/.irbrc +9 -2
  52. data/lib/calabash/ios/orientation.rb +8 -8
  53. data/lib/calabash/ios/runtime.rb +14 -14
  54. data/lib/calabash/ios/scroll.rb +25 -17
  55. data/lib/calabash/ios/slider.rb +11 -18
  56. data/lib/calabash/ios/text.rb +20 -74
  57. data/lib/calabash/ios/uia.rb +1 -1
  58. data/lib/calabash/ios/web.rb +10 -0
  59. data/lib/calabash/lib/skeleton/{Gemfile → Gemfile.skeleton} +0 -0
  60. data/lib/calabash/lib/skeleton/config/{cucumber.yml → cucumber.yml.skeleton} +0 -0
  61. data/lib/calabash/lib/skeleton/features/{sample.feature → sample.feature.skeleton} +0 -0
  62. data/lib/calabash/lib/skeleton/features/step_definitions/{calabash_steps.rb → sample_steps.rb.skeleton} +8 -8
  63. data/lib/calabash/lib/skeleton/features/support/{dry_run.rb → dry_run.rb.skeleton} +2 -5
  64. data/lib/calabash/lib/skeleton/features/support/{env.rb → env.rb.skeleton} +2 -8
  65. data/lib/calabash/lib/skeleton/features/support/hooks.rb.skeleton +34 -0
  66. data/lib/calabash/life_cycle.rb +16 -8
  67. data/lib/calabash/location.rb +14 -15
  68. data/lib/calabash/orientation.rb +8 -8
  69. data/lib/calabash/page.rb +1 -4
  70. data/lib/calabash/retry.rb +33 -0
  71. data/lib/calabash/screenshot.rb +3 -3
  72. data/lib/calabash/stubs.rb +21 -0
  73. data/lib/calabash/text.rb +31 -19
  74. data/lib/calabash/utility.rb +41 -8
  75. data/lib/calabash/version.rb +1 -1
  76. data/lib/calabash/wait.rb +177 -192
  77. data/lib/calabash/web.rb +44 -0
  78. metadata +39 -32
  79. data/lib/calabash/ios/device/text_mixin.rb +0 -21
  80. data/lib/calabash/lib/skeleton/features/support/hooks.rb +0 -83
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1788f3f3e1bfd128768042749d0b7d5dbdebb8ab
4
- data.tar.gz: 68d92c0989f89f7b4d4cf55a23a0daed83fa25e1
3
+ metadata.gz: f3765e67e7cec21052896d43ad8e3b52ab873aa9
4
+ data.tar.gz: a25e627e951abd1f87d3aae55745fb3451853a75
5
5
  SHA512:
6
- metadata.gz: f46b1426f57a039bebe2ac8e59c015f6ad2720217cb37b0e8df118614fa958a4d2cb2ec62890dee52dbb41980c5111c435567c7756ae746487bf69797ceae898
7
- data.tar.gz: 5ed96dfbd5603d13ba3dbbc4a976bb7839641b74d514c178c71f0c2fe6f26f9f8e1cae7bd11b5acc6b5f1bbbf7ffd58037c95180ba0fcb3d99b5a384565061a9
6
+ metadata.gz: b4bf50f53dc792ff9854f068761d3ab3f464a4028c777292529a3172c5dd681a489b74ac1467aec1fa3954073e7425b27b43a39a2cab1e8e30a4a551f5043c06
7
+ data.tar.gz: 331293d4107302ccd412ef857d3a274977fe872ad93b642f00eb12689e16a1a889b157c6f13cf80493d34b6ed9c96993f6516ee9ab6ab18a09aae2cb681db537
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Calabash
6
6
 
7
- Automated Acceptance Testing for Mobile Apps
7
+ Automated Acceptance Testing for Mobile Apps.
8
8
 
9
9
  ## Rake
10
10
 
@@ -29,25 +29,13 @@ rake yard:publish # Generate and publish docs
29
29
 
30
30
  ```
31
31
  $ be rake unit # All unit tests.
32
- $ be rake spec # All tests. Launches iOS Simulators, etc.
33
32
  $ be guard # Run unit tests as you develop.
34
33
  ```
35
34
 
36
- ### Cucumber Android
37
-
38
- **NOTE** If you find you cannot launch on Android, be sure you run the
39
- `copy\_repos` and `changing\_old\_files.sh` script.
35
+ ### Integration tests
40
36
 
41
37
  ```
42
- $ bundle update
43
- $ rake android:build
44
- $ cd cucumber/android
45
- $ be calabash resign ../../spec/resources/android/xtc-android-sample.apk
46
- $ be calabash build ../../spec/resources/android/xtc-android-sample.apk
47
- $ be cucumber
38
+ $ rake integration:page-object-model # Run POM tests
39
+ $ rake integration:ruby # Run tests ensuing correct Ruby interfacing
40
+ $ rake integration:cli # Run command line interface tests
48
41
  ```
49
-
50
- ### Cucumber iOS
51
-
52
- See `cucumber/ios/README.md`.
53
-
@@ -11,7 +11,6 @@ module Calabash
11
11
  include Calabash::CLI::Console
12
12
  include Calabash::CLI::Generate
13
13
  include Calabash::CLI::Resign
14
- include Calabash::CLI::Run
15
14
  include Calabash::CLI::SetupKeystore
16
15
 
17
16
  def initialize(arguments)
@@ -69,12 +68,12 @@ module Calabash
69
68
  parse_resign_arguments!
70
69
  when 'console'
71
70
  parse_console_arguments!
72
- when 'generate'
71
+ when 'generate-cucumber'
73
72
  parse_generate_arguments!
74
- when 'run'
75
- parse_run_arguments!
76
73
  when 'setup-keystore'
77
74
  parse_setup_keystore_arguments!
75
+ when 'used-bundler' # For testing purposes
76
+ puts Calabash::Utility.used_bundler?
78
77
  when 'help'
79
78
  argument = @arguments.shift
80
79
 
@@ -1,14 +1,18 @@
1
- # Calabash is a Behavior-driven development (BDD) framework for Android and
2
- # iOS. It supports both native and hybrid app testing.
1
+ # Calabash is a mobile automation tool used for automatic UI-testing.
2
+ # It supports Android and iOS, both native and hybrid app testing.
3
3
  #
4
4
  # It is developed and maintained by Xamarin and is released under the Eclipse
5
5
  # Public License.
6
6
  module Calabash
7
+ class RequiredBothPlatformsError < LoadError
8
+ end
9
+
7
10
  require 'calabash/version'
8
11
  require 'calabash/environment'
9
12
  require 'calabash/logger'
10
13
  require 'calabash/color'
11
14
  require 'calabash/utility'
15
+ require 'calabash/retry'
12
16
  require 'calabash/application'
13
17
  require 'calabash/device'
14
18
  require 'calabash/http'
@@ -24,9 +28,11 @@ module Calabash
24
28
  require 'calabash/query'
25
29
  require 'calabash/text'
26
30
  require 'calabash/interactions'
31
+ require 'calabash/web'
27
32
  require 'calabash/defaults'
28
33
  require 'calabash/legacy'
29
34
  require 'calabash/console_helpers'
35
+ require 'calabash/internal'
30
36
 
31
37
 
32
38
  require 'calabash/patch'
@@ -42,6 +48,7 @@ module Calabash
42
48
  include Calabash::Orientation
43
49
  include Calabash::Text
44
50
  include Calabash::Interactions
51
+ include Calabash::Web
45
52
  extend Calabash::Defaults
46
53
 
47
54
  require 'calabash/page'
@@ -54,9 +61,9 @@ module Calabash
54
61
  # @example
55
62
  # # android/pages/my_page.rb
56
63
  # class Android::MyPage < Calabash::Page
57
- # include Calabash::Android
58
- #
59
- # # [...]
64
+ # def method
65
+ # # [...]
66
+ # end
60
67
  # end
61
68
  #
62
69
  # # step definition
@@ -71,7 +78,7 @@ module Calabash
71
78
  # # pages/abstract_login_page.rb
72
79
  # class AbstractLoginPage < Calabash::Page
73
80
  # def login(username, password)
74
- # enter_text_in(username_field, username)
81
+ # cal.enter_text_in(username_field, username)
75
82
  # # [...]
76
83
  # end
77
84
  #
@@ -84,8 +91,6 @@ module Calabash
84
91
  #
85
92
  # # pages/android_login_page.rb
86
93
  # class Android::LoginPage < SharedLoginPage
87
- # include Calabash::Android
88
- #
89
94
  # private
90
95
  #
91
96
  # def username_field
@@ -122,8 +127,9 @@ module Calabash
122
127
  if page_class.is_a?(Class)
123
128
  modules = page_class.included_modules.map(&:to_s)
124
129
 
125
- unless modules.include?("Calabash::#{platform_module}")
126
- raise "Page '#{page_class}' does not include Calabash::#{platform_module}"
130
+ if modules.include?("Calabash::#{platform_module}")
131
+ Logger.warn("Page '#{page_class}' includes Calabash::#{platform_module}. It is recommended not to include Calabash.")
132
+ Logger.warn("Use cal.<method> for cross-platform methods, cal_android.<method> for Android-only and cal_ios.<method> for iOS-only")
127
133
  end
128
134
 
129
135
  if modules.include?('Calabash::Android') &&
@@ -131,6 +137,10 @@ module Calabash
131
137
  raise "Page '#{page_class}' includes both Calabash::Android and Calabash::IOS"
132
138
  end
133
139
 
140
+ unless page_class.ancestors.include?(Calabash::Page)
141
+ raise "Page '#{page_class}' is not a Calabash::Page"
142
+ end
143
+
134
144
  page = page_class.send(:new, self)
135
145
 
136
146
  if page.is_a?(Calabash::Page)
@@ -317,3 +327,36 @@ if Calabash::Environment::DEBUG_CALLED_METHODS
317
327
 
318
328
  set_trace_func(trace_func)
319
329
  end
330
+
331
+ # @!visibility private
332
+ class CalabashMethodsInternal
333
+ include ::Calabash
334
+ end
335
+
336
+ # @!visibility private
337
+ class CalabashMethods < BasicObject
338
+ include ::Calabash
339
+
340
+ instance_methods.each do |method_name|
341
+ define_method(method_name) do |*args, &block|
342
+ ::CalabashMethodsInternal.new.send(method_name, *args, &block)
343
+ end
344
+ end
345
+ end
346
+
347
+ # Returns a object that exposes all of the public Calabash cross-platform API.
348
+ # This method should *always* be used to access the Calabash API. By default,
349
+ # all methods are executed using the default device and the default
350
+ # application.
351
+ #
352
+ # For OS specific methods use {cal_android} and {cal_ios}
353
+ #
354
+ # All API methods are available with documentation in {Calabash}
355
+ #
356
+ # @see {Calabash}
357
+ #
358
+ # @return [Object] Instance responding to all cross-platform Calabash methods
359
+ # in the API.
360
+ def cal
361
+ CalabashMethods.new
362
+ end
@@ -1,4 +1,35 @@
1
1
  module Calabash
2
+ # @!visibility private
3
+ module AndroidInternal
4
+ require 'calabash'
5
+
6
+ require 'calabash/android/environment'
7
+ require 'calabash/android/application'
8
+ require 'calabash/android/build'
9
+ require 'calabash/android/device'
10
+ require 'calabash/android/screenshot'
11
+ require 'calabash/android/server'
12
+ require 'calabash/android/adb'
13
+ require 'calabash/android/gestures'
14
+ require 'calabash/android/interactions'
15
+ require 'calabash/android/orientation'
16
+ require 'calabash/android/physical_buttons'
17
+ require 'calabash/android/text'
18
+ require 'calabash/android/web'
19
+ require 'calabash/android/console_helpers'
20
+ require 'calabash/android/life_cycle'
21
+ require 'calabash/android/scroll'
22
+
23
+ include Calabash::Android::Gestures
24
+ include Calabash::Android::Interactions
25
+ include Calabash::Android::LifeCycle
26
+ include Calabash::Android::Orientation
27
+ include Calabash::Android::PhysicalButtons
28
+ include Calabash::Android::Text
29
+ include Calabash::Android::Scroll
30
+ include Calabash::Android::Web
31
+ end
32
+
2
33
  # Contains the Android implementations of the Calabash APIs.
3
34
  module Android
4
35
  # @!visibility private
@@ -12,9 +43,6 @@ module Calabash
12
43
  # @!visibility private
13
44
  HELPER_APPLICATION_TEST_SERVER = File.join(File.dirname(__FILE__), 'android', 'lib', 'HelperApplicationTestServer.apk')
14
45
 
15
- require 'calabash'
16
- include Calabash
17
-
18
46
  # @!visibility private
19
47
  def self.extended(base)
20
48
  Calabash.send(:extended, base)
@@ -25,32 +53,14 @@ module Calabash
25
53
  Calabash.send(:included, base)
26
54
  end
27
55
 
56
+ require 'calabash'
57
+ # Hide from documentation
58
+ send(:include, Calabash)
59
+
28
60
  require 'calabash/android/defaults'
29
61
  extend Calabash::Android::Defaults
30
62
 
31
- require 'calabash/android/environment'
32
- require 'calabash/android/application'
33
- require 'calabash/android/build'
34
- require 'calabash/android/device'
35
- require 'calabash/android/screenshot'
36
- require 'calabash/android/server'
37
- require 'calabash/android/adb'
38
- require 'calabash/android/gestures'
39
- require 'calabash/android/interactions'
40
- require 'calabash/android/orientation'
41
- require 'calabash/android/physical_buttons'
42
- require 'calabash/android/text'
43
- require 'calabash/android/console_helpers'
44
- require 'calabash/android/life_cycle'
45
- require 'calabash/android/scroll'
46
-
47
- include Calabash::Android::Gestures
48
- include Calabash::Android::Interactions
49
- include Calabash::Android::LifeCycle
50
- include Calabash::Android::Orientation
51
- include Calabash::Android::PhysicalButtons
52
- include Calabash::Android::Text
53
- include Calabash::Android::Scroll
63
+ include ::Calabash::AndroidInternal
54
64
 
55
65
  # @!visibility private
56
66
  def self.binary_location(name, abi, using_pie)
@@ -73,5 +83,56 @@ module Calabash
73
83
  end
74
84
  end
75
85
 
76
- # Setup environment on load
77
- Calabash::Android::Environment.setup
86
+ unless Calabash::Environment.variable("CAL_NO_DEPENDENCIES") == "1"
87
+ # Setup environment on load
88
+ Calabash::Android::Environment.setup
89
+ end
90
+
91
+ # @!visibility private
92
+ class CalabashAndroidMethodsInternal
93
+ include ::Calabash::Android
94
+ end
95
+
96
+ # @!visibility private
97
+ class CalabashAndroidMethods < BasicObject
98
+ include ::Calabash::AndroidInternal
99
+
100
+ instance_methods.each do |method_name|
101
+ define_method(method_name) do |*args, &block|
102
+ ::CalabashAndroidMethodsInternal.new.send(method_name, *args, &block)
103
+ end
104
+ end
105
+ end
106
+
107
+ # Returns a object that exposes all of the public Calabash Android API.
108
+ # This method should *always* be used to access the Calabash API. By default,
109
+ # all methods are executed using the default device and the default
110
+ # application.
111
+ #
112
+ # For iOS specific methods use {cal_ios}. For cross-platform methods use {cal}.
113
+ #
114
+ # All Android API methods are available with documentation in
115
+ # {Calabash::Android}
116
+ #
117
+ # @see Calabash::Android
118
+ #
119
+ # @return [Object] Instance responding to all Calabash Android methods
120
+ # in the API.
121
+ def cal_android
122
+ CalabashAndroidMethods.new
123
+ end
124
+
125
+ # We also want to patch `cal` to invoke the Android implementations
126
+ class CalabashMethodsInternal
127
+ include ::Calabash::Android
128
+
129
+ instance_methods.each do |method_name|
130
+ define_method(method_name) do |*args, &block|
131
+ ::CalabashAndroidMethodsInternal.new.send(method_name, *args, &block)
132
+ end
133
+ end
134
+ end
135
+
136
+ if defined?(::Calabash::IOSInternal)
137
+ raise Calabash::RequiredBothPlatformsError, "Cannot require both calabash/android and calabash/ios"
138
+ end
@@ -182,34 +182,40 @@ module Calabash
182
182
  # exit_code_s =
183
183
  # [6] "0\r\n"
184
184
 
185
- index = result.lines.index {|line| line.start_with?(shell_name)}
185
+ unless shell_name.empty?
186
+ index = result.lines.index {|line| line.start_with?(shell_name)}
186
187
 
187
- if index.nil?
188
- raise ADBCallError.new("Could not parse output #{ADB.dot_string(result, 100)}", result)
189
- end
188
+ if index.nil?
189
+ raise ADBCallError.new("Could not parse output #{ADB.dot_string(result, 100)}", result)
190
+ end
190
191
 
191
- # Remove the commands
192
- out = result.lines[index+1..-1]
192
+ # Remove the commands
193
+ out = result.lines[index+1..-1]
193
194
 
194
- last_line = out.last
195
- end_index = nil
195
+ last_line = out.last
196
+ end_index = nil
196
197
 
197
- 15.times do |i|
198
- if last_line[-(END_STRING.length+i-1)..-i] == END_STRING
199
- end_index = -i
200
- break
198
+ 15.times do |i|
199
+ if last_line[-(END_STRING.length+i-1)..-i] == END_STRING
200
+ end_index = -i
201
+ break
202
+ end
201
203
  end
202
- end
203
204
 
204
- if end_index.nil?
205
- raise ADBCallError.new("Could not parse output #{ADB.dot_string(result, 100)}", result)
206
- end
205
+ if end_index.nil?
206
+ raise ADBCallError.new("Could not parse output #{ADB.dot_string(result, 100)}", result)
207
+ end
207
208
 
208
- # Get the result from the command
209
- command_result = out[0..-2].join + last_line[0..(end_index - END_STRING.length)]
209
+ # Get the result from the command
210
+ command_result = out[0..-2].join + last_line[0..(end_index - END_STRING.length)]
210
211
 
211
- # Get the exit code
212
- exit_code_s = out[-1][end_index+1..-1]
212
+ # Get the exit code
213
+ exit_code_s = out[-1][end_index+1..-1]
214
+ else # Some devices (like Android N) have started just giving us the result without all the spam
215
+ out = result.lines
216
+ command_result = out[0..-2].join
217
+ exit_code_s = out[-1][END_STRING.length..-1]
218
+ end
213
219
 
214
220
  unless options[:no_exit_code_check]
215
221
  unless exit_code_s.to_i.to_s == exit_code_s.chomp
@@ -271,6 +277,12 @@ module Calabash
271
277
 
272
278
  #result.lines.index {|line| !line.start_with?('echo')}
273
279
 
280
+ # Some devices (like Android N) have started just giving us the results
281
+ if result.strip == "test"
282
+ @shell_name = ""
283
+ return @shell_name
284
+ end
285
+
274
286
  # "shell@hammerhead:/ $ echo \"foo\"; exit 0\r\r\n"
275
287
  shell_name_line = result.lines[-2]
276
288
 
@@ -29,7 +29,7 @@ module Calabash
29
29
 
30
30
  unless File.exist?(test_server_path)
31
31
  Logger.error "Test-server '#{test_server_path}' does not exist."
32
- Logger.error "Build it using: 'calabash build \"#{application_path}\"'"
32
+ Logger.error "Build it using: '#{Calabash::Utility.bundle_exec_prepend}calabash build \"#{application_path}\"'"
33
33
  Logger.error ''
34
34
  raise "Test-server '#{test_server_path}' does not exist."
35
35
  end
@@ -38,7 +38,7 @@ module Calabash
38
38
  end
39
39
  @logger.log ""
40
40
  @logger.log "You can resign the app with #{keystores.first.location} by running:
41
- calabash resign \"#{@application_path}\""
41
+ #{Calabash::Utility.bundle_exec_prepend}calabash resign \"#{@application_path}\""
42
42
 
43
43
  @logger.log ""
44
44
  @logger.log "Notice that resigning an app might break some functionality."
@@ -155,7 +155,7 @@ module Calabash
155
155
  begin
156
156
  keystore = JSON.parse(IO.read(CALABASH_KEYSTORE_SETTINGS_FILENAME))
157
157
  rescue JSON::ParserError => e
158
- Logger.error('Could not parse keystore settings. Please run calabash setup-keystore again')
158
+ Logger.error("Could not parse keystore settings. Please run #{Calabash::Utility.bundle_exec_prepend}calabash setup-keystore again")
159
159
 
160
160
  raise e
161
161
  end
@@ -67,7 +67,7 @@ module Calabash
67
67
  java_keystore = JavaKeystore.get_keystores.first
68
68
 
69
69
  if java_keystore.nil?
70
- raise 'No keystores found. You can specify the keystore location and credentials using calabash setup-keystore'
70
+ raise "No keystores found. You can specify the keystore location and credentials using #{Calabash::Utility.bundle_exec_prepend}calabash setup-keystore"
71
71
  end
72
72
 
73
73
  java_keystore.sign_apk(app_path, dest_path)