calabash 2.0.0.pre11 → 2.0.0.prelegacy

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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -5
  3. data/bin/calabash +4 -3
  4. data/lib/calabash/android/adb.rb +37 -34
  5. data/lib/calabash/android/application.rb +1 -1
  6. data/lib/calabash/android/build/builder.rb +1 -1
  7. data/lib/calabash/android/build/java_keystore.rb +1 -1
  8. data/lib/calabash/android/build/resigner.rb +1 -1
  9. data/lib/calabash/android/device.rb +46 -204
  10. data/lib/calabash/android/environment.rb +1 -14
  11. data/lib/calabash/android/gestures.rb +22 -6
  12. data/lib/calabash/android/interactions.rb +17 -14
  13. data/lib/calabash/android/legacy.rb +141 -4
  14. data/lib/calabash/android/lib/.irbrc +1 -9
  15. data/lib/calabash/android/lib/AndroidManifest.xml +2 -23
  16. data/lib/calabash/android/lib/TestServer.apk +0 -0
  17. data/lib/calabash/android/life_cycle.rb +3 -3
  18. data/lib/calabash/android/orientation.rb +8 -8
  19. data/lib/calabash/android/physical_buttons.rb +16 -19
  20. data/lib/calabash/android/server.rb +1 -6
  21. data/lib/calabash/android/text.rb +12 -12
  22. data/lib/calabash/android.rb +26 -92
  23. data/lib/calabash/application.rb +0 -3
  24. data/lib/calabash/cli/generate.rb +18 -8
  25. data/lib/calabash/cli/helpers.rb +9 -4
  26. data/lib/calabash/cli/run.rb +1 -1
  27. data/lib/calabash/console_helpers.rb +11 -179
  28. data/lib/calabash/device.rb +19 -4
  29. data/lib/calabash/gestures.rb +198 -292
  30. data/lib/calabash/http/retriable_client.rb +3 -18
  31. data/lib/calabash/http.rb +0 -1
  32. data/lib/calabash/interactions.rb +40 -3
  33. data/lib/calabash/ios/conditions.rb +1 -1
  34. data/lib/calabash/ios/console_helpers.rb +2 -2
  35. data/lib/calabash/ios/date_picker.rb +8 -10
  36. data/lib/calabash/ios/device/device_implementation.rb +21 -9
  37. data/lib/calabash/ios/device/gestures_mixin.rb +55 -53
  38. data/lib/calabash/ios/device/keyboard_mixin.rb +0 -21
  39. data/lib/calabash/ios/device/rotation_mixin.rb +65 -3
  40. data/lib/calabash/ios/device/text_mixin.rb +21 -0
  41. data/lib/calabash/ios/device.rb +1 -0
  42. data/lib/calabash/ios/gestures.rb +90 -24
  43. data/lib/calabash/ios/interactions.rb +6 -1
  44. data/lib/calabash/ios/lib/.irbrc +2 -9
  45. data/lib/calabash/ios/orientation.rb +8 -8
  46. data/lib/calabash/ios/runtime.rb +14 -14
  47. data/lib/calabash/ios/scroll.rb +17 -25
  48. data/lib/calabash/ios/slider.rb +18 -11
  49. data/lib/calabash/ios/text.rb +74 -20
  50. data/lib/calabash/ios/uia.rb +1 -1
  51. data/lib/calabash/ios.rb +16 -77
  52. data/lib/calabash/legacy.rb +6 -9
  53. data/lib/calabash/lib/skeleton/{Gemfile.skeleton → Gemfile} +0 -0
  54. data/lib/calabash/lib/skeleton/config/{cucumber.yml.skeleton → cucumber.yml} +0 -0
  55. data/lib/calabash/lib/skeleton/features/{sample.feature.skeleton → sample.feature} +0 -0
  56. data/lib/calabash/lib/skeleton/features/step_definitions/{sample_steps.rb.skeleton → calabash_steps.rb} +8 -8
  57. data/lib/calabash/lib/skeleton/features/support/{dry_run.rb.skeleton → dry_run.rb} +5 -2
  58. data/lib/calabash/lib/skeleton/features/support/{env.rb.skeleton → env.rb} +8 -2
  59. data/lib/calabash/lib/skeleton/features/support/hooks.rb +83 -0
  60. data/lib/calabash/life_cycle.rb +8 -16
  61. data/lib/calabash/location.rb +15 -14
  62. data/lib/calabash/orientation.rb +8 -8
  63. data/lib/calabash/page.rb +4 -1
  64. data/lib/calabash/screenshot.rb +3 -3
  65. data/lib/calabash/text.rb +19 -31
  66. data/lib/calabash/utility.rb +8 -41
  67. data/lib/calabash/version.rb +1 -1
  68. data/lib/calabash/wait.rb +192 -177
  69. data/lib/calabash.rb +10 -53
  70. metadata +32 -43
  71. data/lib/calabash/android/device/helper_application.rb +0 -95
  72. data/lib/calabash/android/lib/HelperApplication.apk +0 -0
  73. data/lib/calabash/android/lib/HelperApplicationTestServer.apk +0 -0
  74. data/lib/calabash/android/web.rb +0 -12
  75. data/lib/calabash/http/forwarding_client.rb +0 -23
  76. data/lib/calabash/internal.rb +0 -48
  77. data/lib/calabash/ios/automator/automator.rb +0 -217
  78. data/lib/calabash/ios/automator/coordinates.rb +0 -37
  79. data/lib/calabash/ios/automator/device_agent.rb +0 -379
  80. data/lib/calabash/ios/automator.rb +0 -9
  81. data/lib/calabash/ios/legacy.rb +0 -6
  82. data/lib/calabash/ios/web.rb +0 -10
  83. data/lib/calabash/lib/skeleton/features/support/hooks.rb.skeleton +0 -34
  84. data/lib/calabash/retry.rb +0 -33
  85. data/lib/calabash/stubs.rb +0 -21
  86. data/lib/calabash/web.rb +0 -44
@@ -1,6 +1,143 @@
1
- if Calabash::Environment.variable('DEVICE_ENDPOINT')
2
- Calabash::Logger.warn("Deprecated use of old ENV variable 'DEVICE_ENDPOINT'")
1
+ if ENV["APP_PATH"]
2
+ Calabash::Environment::APP_PATH = ENV["APP_PATH"]
3
+ end
3
4
 
4
- Calabash::Android::Environment::DEVICE_ENDPOINT =
5
- URI.parse(Calabash::Environment.variable('DEVICE_ENDPOINT'))
5
+ if ENV["TEST_APP_PATH"]
6
+ Calabash::Environment::TEST_SERVER_PATH = ENV["TEST_APP_PATH"]
6
7
  end
8
+
9
+
10
+ module Calabash
11
+ module Android
12
+ class Device < Calabash::Device
13
+ def screen_on?
14
+ true
15
+ end
16
+
17
+ def md5_checksum(file_path)
18
+ "samplechecksum"
19
+ end
20
+
21
+ def adb_install_app(application)
22
+ @logger.log "Patch: Installing #{application.path}"
23
+
24
+ begin
25
+ result = adb.command("install #{application.path}", timeout: 60)
26
+ rescue ADB::ADBCallError => e
27
+ raise "Failed to install the application on device: '#{e.message}'"
28
+ end
29
+
30
+ if result.lines.last.downcase.chomp != 'success'
31
+ raise "Could not install app '#{application.identifier}': #{result.chomp}"
32
+ end
33
+
34
+ unless installed_packages.include?(application.identifier)
35
+ raise "App '#{application.identifier}' was not installed"
36
+ end
37
+ end
38
+
39
+ def _start_app(application, options={})
40
+ env_options = {}
41
+
42
+ options.fetch(:extras, {}).each do |k, v|
43
+ env_options[k] = v
44
+ end
45
+
46
+ env_options[:target_package] = application.identifier
47
+
48
+ if options[:activity]
49
+ env_options[:main_activity] = options[:activity]
50
+ end
51
+
52
+ env_options[:test_server_port] = server.test_server_port
53
+ env_options[:class] = options.fetch(:class, 'sh.calaba.instrumentationbackend.InstrumentationBackend')
54
+
55
+ if application.test_server.nil?
56
+ raise 'Invalid application. No test-server set.'
57
+ end
58
+
59
+ unless app_installed?(application.identifier)
60
+ raise "The application '#{application.identifier}' is not installed"
61
+ end
62
+
63
+ unless app_installed?(application.test_server.identifier)
64
+ raise "The test-server '#{application.test_server.identifier}' is not installed"
65
+ end
66
+
67
+ installed_app = installed_apps.find{|app| app[:package] == application.identifier}
68
+ installed_app_md5_checksum = md5_checksum(installed_app[:path])
69
+
70
+ if application.md5_checksum != installed_app_md5_checksum
71
+ raise "The specified app is not the same as the installed app (#{application.md5_checksum} != #{installed_app_md5_checksum})."
72
+ end
73
+
74
+ installed_test_server = installed_apps.find{|app| app[:package] == application.test_server.identifier}
75
+ installed_test_server_md5_checksum = md5_checksum(installed_test_server[:path])
76
+
77
+ if application.test_server.md5_checksum != installed_test_server_md5_checksum
78
+ raise "The specified test-server is not the same as the installed test-server (#{application.test_server.md5_checksum} != #{installed_test_server_md5_checksum})."
79
+ end
80
+
81
+ # We have to forward the port ourselves, as an old test-server could be
82
+ # running on the old port. If the retriable client was able to
83
+ # determine if the port had been forwarded, we would not need this.
84
+ port_forward(server.endpoint.port, server.test_server_port)
85
+
86
+ # For now, the test-server cannot rebind an existing socket.
87
+ # So we have to stop any running Calabash servers from the client
88
+ # for now.
89
+ if test_server_responding?
90
+ @logger.log("A test-server is already running on port #{server.test_server_port}")
91
+ @logger.log("Trying to stop it")
92
+
93
+ begin
94
+ _stop_app
95
+ rescue => _
96
+ raise 'Failed to stop old running test-server'
97
+ end
98
+ end
99
+
100
+ extras = ''
101
+
102
+ env_options.each_pair do |key, val|
103
+ extras = "#{extras} -e #{key.to_s} #{val.to_s}"
104
+ end
105
+
106
+ begin
107
+ instrument(application,
108
+ 'sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner',
109
+ extras)
110
+ rescue ADB::ADBCallError => e
111
+ raise "Failed to start the application: '#{e.stderr.lines.first.chomp}'"
112
+ end
113
+
114
+ begin
115
+ Retriable.retriable(tries: 30, interval: 1, timeout: 30, on: RetryError) do
116
+ unless test_server_responding?
117
+ raise RetryError
118
+ end
119
+ end
120
+ rescue RetryError => _
121
+ @logger.log('Could not contact test-server', :error)
122
+ @logger.log('For information, see the adb logcat', :error)
123
+ raise 'Could not contact test-server'
124
+ end
125
+
126
+ begin
127
+ Retriable.retriable(tries: 10, interval: 1, timeout: 10) do
128
+ unless test_server_ready?
129
+ raise RetryError
130
+ end
131
+ end
132
+ rescue RetryError => _
133
+ @logger.log('Test-server was never ready', :error)
134
+ @logger.log('For information, see the adb logcat', :error)
135
+ raise 'Test-server was never ready'
136
+ end
137
+
138
+ # Return true to avoid cluttering the console
139
+ true
140
+ end
141
+ end
142
+ end
143
+ end
@@ -39,15 +39,7 @@ end
39
39
  begin
40
40
  require 'calabash/android'
41
41
 
42
- IRB.conf[:PROMPT][:CALABASH] = {
43
- :PROMPT_I => "calabash #{Calabash::VERSION}> ",
44
- :PROMPT_S => "%03n> ",
45
- :PROMPT_C => "%03n> ",
46
- :RETURN => "%s\n"
47
- }
48
-
49
- IRB.conf[:PROMPT_MODE] = :CALABASH
50
-
42
+ extend Calabash::Android
51
43
  extend Calabash::ConsoleHelpers
52
44
 
53
45
  Calabash::Android.setup_defaults!
@@ -3,9 +3,7 @@
3
3
  package="#testPackage#"
4
4
  android:versionCode="3"
5
5
  android:versionName="0.3.0">
6
- <application android:label="instrumentation_backend"
7
- android:largeHeap="true">
8
-
6
+ <application android:label="instrumentation_backend">
9
7
  <uses-library android:name="android.test.runner" />
10
8
  <uses-library android:name="com.google.android.maps" android:required="false" />
11
9
  <activity
@@ -33,26 +31,8 @@
33
31
  android:stateNotNeeded="true"
34
32
  android:noHistory="true"
35
33
  android:excludeFromRecents="true"/>
36
- <activity
37
- android:name="sh.calaba.instrumentationbackend.FakeCameraActivity"
38
- android:label="FakeCameraActivity"
39
- android:exported="true"
40
- android:finishOnTaskLaunch="true"
41
- android:stateNotNeeded="true"
42
- android:noHistory="true"
43
- android:excludeFromRecents="true"
44
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
45
- <activity
46
- android:name="sh.calaba.instrumentationbackend.FakePickerActivity"
47
- android:label="FakePickerActivity"
48
- android:exported="true"
49
- android:finishOnTaskLaunch="true"
50
- android:stateNotNeeded="true"
51
- android:noHistory="true"
52
- android:excludeFromRecents="true"/>
53
34
  </application>
54
- <uses-sdk android:minSdkVersion="4"
55
- android:targetSdkVersion="21"/>
35
+ <uses-sdk android:minSdkVersion="4" />
56
36
  <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner" />
57
37
  <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearAppData" />
58
38
  <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearAppData2" />
@@ -67,6 +47,5 @@
67
47
  <uses-permission android:name="android.permission.INTERNET" />
68
48
  <uses-permission android:name="android.permission.GET_TASKS" />
69
49
  <uses-permission android:name="android.permission.REORDER_TASKS" />
70
- <uses-permission android:name="android.permission.CAMERA" />
71
50
 
72
51
  </manifest>
@@ -21,19 +21,19 @@ module Calabash
21
21
  raise 'No application given, and Application.default is not set'
22
22
  end
23
23
 
24
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.resume_app(path_or_application)}
24
+ Device.default.resume_app(path_or_application)
25
25
 
26
26
  true
27
27
  end
28
28
 
29
29
  # @!visibility private
30
- define_method(:_send_current_app_to_background) do |for_seconds|
30
+ def _send_current_app_to_background(for_seconds)
31
31
  package = focused_package
32
32
  activity = focused_activity
33
33
 
34
34
  go_home
35
35
  sleep(for_seconds)
36
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.resume_activity(package, activity)}
36
+ Device.default.resume_activity(package, activity)
37
37
  end
38
38
  end
39
39
  end
@@ -3,28 +3,28 @@ module Calabash
3
3
  # @!visibility private
4
4
  module Orientation
5
5
  # @!visibility private
6
- define_method(:_set_orientation_landscape) do
7
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('set_activity_orientation', 'landscape')}
6
+ def _set_orientation_landscape
7
+ Device.default.perform_action('set_activity_orientation', 'landscape')
8
8
  end
9
9
 
10
10
  # @!visibility private
11
- define_method(:_set_orientation_portrait) do
12
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('set_activity_orientation', 'portrait')}
11
+ def _set_orientation_portrait
12
+ Device.default.perform_action('set_activity_orientation', 'portrait')
13
13
  end
14
14
 
15
15
  # @!visibility private
16
- define_method(:_portrait?) do
16
+ def _portrait?
17
17
  _orientation == 'portrait'
18
18
  end
19
19
 
20
20
  # @!visibility private
21
- define_method(:_landscape?) do
21
+ def _landscape?
22
22
  _orientation == 'landscape'
23
23
  end
24
24
 
25
25
  # @!visibility private
26
- define_method(:_orientation) do
27
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('get_activity_orientation')['message']}
26
+ def _orientation
27
+ Device.default.perform_action('get_activity_orientation')['message']
28
28
  end
29
29
  end
30
30
  end
@@ -8,47 +8,44 @@ module Calabash
8
8
  module PhysicalButtons
9
9
 
10
10
  # @!visibility private
11
- def press_physical_button(key)
12
- Calabash::Internal.with_default_device(required_os: :android) do |device|
13
- device.perform_action('press_physical_key', key)
14
- end
15
-
11
+ def press_button(key)
12
+ Device.default.perform_action('press_key', key)
16
13
  true
17
14
  end
18
15
 
19
16
  # @!visibility private
20
- def press_physical_back_button
21
- press_physical_button('KEYCODE_BACK')
17
+ def press_back_button
18
+ press_button('KEYCODE_BACK')
22
19
  end
23
20
 
24
21
  # @!visibility private
25
- def press_physical_menu_button
26
- press_physical_button('KEYCODE_MENU')
22
+ def press_menu_button
23
+ press_button('KEYCODE_MENU')
27
24
  end
28
25
 
29
26
  # @!visibility private
30
- def press_physical_down_button
31
- press_physical_button('KEYCODE_DPAD_DOWN')
27
+ def press_down_button
28
+ press_button('KEYCODE_DPAD_DOWN')
32
29
  end
33
30
 
34
31
  # @!visibility private
35
- def press_physical_up_button
36
- press_physical_button('KEYCODE_DPAD_UP')
32
+ def press_up_button
33
+ press_button('KEYCODE_DPAD_UP')
37
34
  end
38
35
 
39
36
  # @!visibility private
40
- def press_physical_left_button
41
- press_physical_button('KEYCODE_DPAD_LEFT')
37
+ def press_left_button
38
+ press_button('KEYCODE_DPAD_LEFT')
42
39
  end
43
40
 
44
41
  # @!visibility private
45
- def press_physical_right_button
46
- press_physical_button('KEYCODE_DPAD_RIGHT')
42
+ def press_right_button
43
+ press_button('KEYCODE_DPAD_RIGHT')
47
44
  end
48
45
 
49
46
  # @!visibility private
50
- def press_physical_enter_button
51
- press_physical_button('KEYCODE_ENTER')
47
+ def press_enter_button
48
+ press_button('KEYCODE_ENTER')
52
49
  end
53
50
  end
54
51
  end
@@ -5,12 +5,7 @@ module Calabash
5
5
  # The default Android test server.
6
6
  def self.default
7
7
  endpoint = Environment::DEVICE_ENDPOINT
8
- Server.new(endpoint, 7102)
9
- end
10
-
11
- def self.default_helper
12
- endpoint = Environment::DEVICE_HELPER_ENDPOINT
13
- Server.new(endpoint, 8081)
8
+ Server.new(endpoint)
14
9
  end
15
10
  end
16
11
  end
@@ -6,46 +6,46 @@ module Calabash
6
6
  # pressing the back button if the keyboard is showing. If the keyboard is
7
7
  # already hidden/dismissed, nothing is done.
8
8
  def dismiss_keyboard
9
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('hide_soft_keyboard')}
9
+ Device.default.perform_action('hide_soft_keyboard')
10
10
  sleep 0.5
11
11
  end
12
12
 
13
13
  # @!visibility private
14
- define_method(:_clear_text) do
15
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('clear_text')}
14
+ def _clear_text
15
+ Device.default.perform_action('clear_text')
16
16
  end
17
17
 
18
18
  # @!visibility private
19
- define_method(:_clear_text_in) do |view|
19
+ def _clear_text_in(view)
20
20
  tap(view)
21
21
  sleep 0.5
22
22
  clear_text
23
23
  end
24
24
 
25
25
  # @!visibility private
26
- define_method(:_enter_text) do |text|
27
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.enter_text(text)}
26
+ def _enter_text(text)
27
+ Device.default.enter_text(text)
28
28
  end
29
29
 
30
30
  # @!visibility private
31
- define_method(:_enter_text_in) do |view, text|
31
+ def _enter_text_in(view, text)
32
32
  tap(view)
33
33
  sleep 0.5
34
34
  enter_text(text)
35
35
  end
36
36
 
37
37
  # @!visibility private
38
- define_method(:_tap_keyboard_action_key) do |action_key|
38
+ def _tap_keyboard_action_key(action_key)
39
39
  if action_key.nil?
40
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('press_user_action_button')}
40
+ Device.default.perform_action('press_user_action_button')
41
41
  else
42
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.perform_action('press_user_action_button', action_key.to_s)}
42
+ Device.default.perform_action('press_user_action_button', action_key.to_s)
43
43
  end
44
44
  end
45
45
 
46
46
  # @!visibility private
47
- define_method(:_keyboard_visible?) do
48
- Calabash::Internal.with_default_device(required_os: :android) {|device| device.keyboard_visible?}
47
+ def _keyboard_visible?
48
+ Device.default.keyboard_visible?
49
49
  end
50
50
  end
51
51
  end
@@ -1,7 +1,28 @@
1
1
  module Calabash
2
- # @!visibility private
3
- module AndroidInternal
2
+ # Contains the Android implementations of the Calabash APIs.
3
+ module Android
4
+ # @!visibility private
5
+ TEST_SERVER_CODE_PATH = File.join(File.dirname(__FILE__), '..', '..', 'android', 'test-server')
6
+ # @!visibility private
7
+ UNSIGNED_TEST_SERVER_APK = File.join(File.dirname(__FILE__), 'android', 'lib', 'TestServer.apk')
8
+ # @!visibility private
9
+ ANDROID_MANIFEST_PATH = File.join(File.dirname(__FILE__), 'android', 'lib', 'AndroidManifest.xml')
10
+
4
11
  require 'calabash'
12
+ include Calabash
13
+
14
+ # @!visibility private
15
+ def self.extended(base)
16
+ Calabash.send(:extended, base)
17
+ end
18
+
19
+ # @!visibility private
20
+ def self.included(base)
21
+ Calabash.send(:included, base)
22
+ end
23
+
24
+ require 'calabash/android/defaults'
25
+ extend Calabash::Android::Defaults
5
26
 
6
27
  require 'calabash/android/environment'
7
28
  require 'calabash/android/application'
@@ -15,10 +36,10 @@ module Calabash
15
36
  require 'calabash/android/orientation'
16
37
  require 'calabash/android/physical_buttons'
17
38
  require 'calabash/android/text'
18
- require 'calabash/android/web'
19
39
  require 'calabash/android/console_helpers'
20
40
  require 'calabash/android/life_cycle'
21
41
  require 'calabash/android/scroll'
42
+ require 'calabash/android/legacy'
22
43
 
23
44
  include Calabash::Android::Gestures
24
45
  include Calabash::Android::Interactions
@@ -27,40 +48,6 @@ module Calabash
27
48
  include Calabash::Android::PhysicalButtons
28
49
  include Calabash::Android::Text
29
50
  include Calabash::Android::Scroll
30
- include Calabash::Android::Web
31
- end
32
-
33
- # Contains the Android implementations of the Calabash APIs.
34
- module Android
35
- # @!visibility private
36
- TEST_SERVER_CODE_PATH = File.join(File.dirname(__FILE__), '..', '..', 'android', 'test-server')
37
- # @!visibility private
38
- UNSIGNED_TEST_SERVER_APK = File.join(File.dirname(__FILE__), 'android', 'lib', 'TestServer.apk')
39
- # @!visibility private
40
- ANDROID_MANIFEST_PATH = File.join(File.dirname(__FILE__), 'android', 'lib', 'AndroidManifest.xml')
41
- # @!visibility private
42
- HELPER_APPLICATION = File.join(File.dirname(__FILE__), 'android', 'lib', 'HelperApplication.apk')
43
- # @!visibility private
44
- HELPER_APPLICATION_TEST_SERVER = File.join(File.dirname(__FILE__), 'android', 'lib', 'HelperApplicationTestServer.apk')
45
-
46
- # @!visibility private
47
- def self.extended(base)
48
- Calabash.send(:extended, base)
49
- end
50
-
51
- # @!visibility private
52
- def self.included(base)
53
- Calabash.send(:included, base)
54
- end
55
-
56
- require 'calabash'
57
- # Hide from documentation
58
- send(:include, Calabash)
59
-
60
- require 'calabash/android/defaults'
61
- extend Calabash::Android::Defaults
62
-
63
- include ::Calabash::AndroidInternal
64
51
 
65
52
  # @!visibility private
66
53
  def self.binary_location(name, abi, using_pie)
@@ -78,61 +65,8 @@ module Calabash
78
65
 
79
66
  file
80
67
  end
81
-
82
- require 'calabash/android/legacy'
83
68
  end
84
69
  end
85
70
 
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
71
+ # Setup environment on load
72
+ Calabash::Android::Environment.setup
@@ -3,9 +3,6 @@ require 'digest'
3
3
  module Calabash
4
4
  # A representation of an application that is under test.
5
5
  class Application
6
- require 'calabash/android/application'
7
- require 'calabash/ios/application'
8
-
9
6
  # @!visibility private
10
7
  include Calabash::Utility
11
8
 
@@ -17,14 +17,24 @@ module Calabash
17
17
  exit 1
18
18
  end
19
19
 
20
- cucumber_config = File.read(file(File.join('config', 'cucumber.yml.skeleton')))
20
+ reset_between = :features
21
+ reset_method = :clear
21
22
 
22
- env = File.read(file(File.join('features', 'support', 'env.rb.skeleton')))
23
- dry_run = File.read(file(File.join('features', 'support', 'dry_run.rb.skeleton')))
24
- sample_feature = File.read(file(File.join('features', 'sample.feature.skeleton')))
25
- calabash_steps = File.read(file(File.join('features', 'step_definitions', 'sample_steps.rb.skeleton')))
23
+ cucumber_config = File.read(file(File.join('config', 'cucumber.yml')))
26
24
 
27
- hooks = File.read(file(File.join('features', 'support', 'hooks.rb.skeleton')))
25
+ env = File.read(file(File.join('features', 'support', 'env.rb')))
26
+ dry_run = File.read(file(File.join('features', 'support', 'dry_run.rb')))
27
+ sample_feature = File.read(file(File.join('features', 'sample.feature')))
28
+ calabash_steps = File.read(file(File.join('features', 'step_definitions', 'calabash_steps.rb')))
29
+
30
+ hooks = File.read(file(File.join('features', 'support', 'hooks.rb')))
31
+ hooks.sub!("#!DEFAULT_RESET_BETWEEN#!", ":#{reset_between}")
32
+
33
+ if reset_method.nil?
34
+ hooks.sub!("#!DEFAULT_RESET_METHOD#!", 'nil')
35
+ else
36
+ hooks.sub!("#!DEFAULT_RESET_METHOD#!", ":#{reset_method}")
37
+ end
28
38
 
29
39
  FileUtils.mkdir('config')
30
40
 
@@ -35,12 +45,12 @@ module Calabash
35
45
  FileUtils.mkdir('features/support')
36
46
 
37
47
  File.open(File.join('features', 'sample.feature'), 'w') {|file| file.write(sample_feature) }
38
- File.open(File.join('features', 'step_definitions', 'sample_steps.rb'), 'w') {|file| file.write(calabash_steps) }
48
+ File.open(File.join('features', 'step_definitions', 'calabash_steps.rb'), 'w') {|file| file.write(calabash_steps) }
39
49
  File.open(File.join('features', 'support', 'hooks.rb'), 'w') {|file| file.write(hooks) }
40
50
  File.open(File.join('features', 'support', 'env.rb'), 'w') {|file| file.write(env) }
41
51
  File.open(File.join('features', 'support', 'dry_run.rb'), 'w') {|file| file.write(dry_run) }
42
52
 
43
- gemfile = File.readlines(file(File.join('Gemfile.skeleton')))
53
+ gemfile = File.readlines(file(File.join('Gemfile')))
44
54
 
45
55
  unless File.exist?('Gemfile')
46
56
  File.open('Gemfile', 'w') do |file|
@@ -6,7 +6,8 @@ module Calabash
6
6
  # @!visibility private
7
7
  HELP = {
8
8
  help: 'help',
9
- :'generate-cucumber' => 'generate-cucumber',
9
+ generate: 'generate',
10
+ run: 'run [application] [cucumber options]',
10
11
  console: 'console [application]',
11
12
  version: 'version',
12
13
  setup_keystore: 'setup-keystore',
@@ -34,7 +35,7 @@ EOF
34
35
  else
35
36
  output.write <<EOF
36
37
  Usage:
37
- #{Calabash::Utility.bundle_exec_prepend}calabash [options] #{HELP[key]}
38
+ calabash [options] #{HELP[key]}
38
39
  EOF
39
40
  end
40
41
  end
@@ -42,14 +43,18 @@ EOF
42
43
  # @!visibility private
43
44
  def print_usage(output=STDOUT)
44
45
  output.write <<EOF
45
- Usage: #{Calabash::Utility.bundle_exec_prepend}calabash [options] <command-name> [command specific options]
46
+ Usage: calabash [options] <command-name> [command specific options]
46
47
  <command-name> can be one of
47
48
  #{HELP[:help]} [command]
48
49
  print help information.
49
50
 
50
- #{HELP[:'generate-cucumber']}
51
+ #{HELP[:generate]}
51
52
  generate a Cucumber project folder structure.
52
53
 
54
+ #{HELP[:run]}
55
+ runs Cucumber in the current folder with the environment needed.
56
+ the cucumber options will be passed unchanged to cucumber
57
+
53
58
  #{HELP[:console]}
54
59
  starts an interactive console to interact with your app via Calabash
55
60
 
@@ -87,7 +87,7 @@ module Calabash
87
87
  begin
88
88
  require 'cucumber'
89
89
  rescue LoadError => _
90
- unless Calabash::Utility.used_bundler?
90
+ unless Object.const_defined?(:Bundler)
91
91
  $stderr.puts "Warning! Could not load cucumber. Make sure it is installed."
92
92
  end
93
93
  end