calabash 1.2.1 → 1.9.9.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +39 -0
- data/LICENSE +204 -21
- data/README.md +36 -6
- data/VERSIONING.md +16 -0
- data/bin/calabash +95 -0
- data/lib/calabash.rb +185 -1
- data/lib/calabash/android.rb +64 -0
- data/lib/calabash/android/adb.rb +277 -0
- data/lib/calabash/android/application.rb +110 -0
- data/lib/calabash/android/build.rb +12 -0
- data/lib/calabash/android/build/application.rb +13 -0
- data/lib/calabash/android/build/build_error.rb +11 -0
- data/lib/calabash/android/build/builder.rb +119 -0
- data/lib/calabash/android/build/java_keystore.rb +177 -0
- data/lib/calabash/android/build/resigner.rb +56 -0
- data/lib/calabash/android/build/test_server.rb +27 -0
- data/lib/calabash/android/console_helpers.rb +44 -0
- data/lib/calabash/android/cucumber.rb +3 -0
- data/lib/calabash/android/device.rb +965 -0
- data/lib/calabash/android/environment.rb +470 -0
- data/lib/calabash/android/gestures.rb +369 -0
- data/lib/calabash/android/interactions.rb +45 -0
- data/lib/calabash/android/lib/.irbrc +55 -0
- data/lib/calabash/android/lib/AndroidManifest.xml +51 -0
- data/lib/calabash/android/lib/TestServer.apk +0 -0
- data/lib/calabash/android/lib/calmd5/arm64-v8a/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/arm64-v8a/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi-v7a/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi-v7a/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/mips/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/mips/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/mips64/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/mips64/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/x86/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/x86/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/x86_64/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/x86_64/calmd5-pie +0 -0
- data/lib/calabash/android/lib/screenshot_taker.jar +0 -0
- data/lib/calabash/android/life_cycle.rb +37 -0
- data/lib/calabash/android/orientation.rb +30 -0
- data/lib/calabash/android/physical_buttons.rb +39 -0
- data/lib/calabash/android/screenshot.rb +9 -0
- data/lib/calabash/android/scroll.rb +5 -0
- data/lib/calabash/android/server.rb +10 -0
- data/lib/calabash/android/text.rb +54 -0
- data/lib/calabash/application.rb +74 -0
- data/lib/calabash/cli.rb +12 -0
- data/lib/calabash/cli/build.rb +33 -0
- data/lib/calabash/cli/console.rb +90 -0
- data/lib/calabash/cli/generate.rb +110 -0
- data/lib/calabash/cli/helpers.rb +130 -0
- data/lib/calabash/cli/resign.rb +33 -0
- data/lib/calabash/cli/run.rb +99 -0
- data/lib/calabash/cli/setup_keystore.rb +39 -0
- data/lib/calabash/color.rb +32 -0
- data/lib/calabash/console_helpers.rb +90 -0
- data/lib/calabash/defaults.rb +56 -0
- data/lib/calabash/device.rb +401 -0
- data/lib/calabash/environment.rb +75 -0
- data/lib/calabash/gestures.rb +384 -0
- data/lib/calabash/http.rb +8 -0
- data/lib/calabash/http/error.rb +15 -0
- data/lib/calabash/http/request.rb +42 -0
- data/lib/calabash/http/retriable_client.rb +156 -0
- data/lib/calabash/interactions.rb +105 -0
- data/lib/calabash/ios.rb +37 -0
- data/lib/calabash/ios/application.rb +119 -0
- data/lib/calabash/ios/conditions.rb +79 -0
- data/lib/calabash/ios/console_helpers.rb +72 -0
- data/lib/calabash/ios/device.rb +24 -0
- data/lib/calabash/ios/device/device_implementation.rb +779 -0
- data/lib/calabash/ios/device/gestures_mixin.rb +167 -0
- data/lib/calabash/ios/device/keyboard_mixin.rb +133 -0
- data/lib/calabash/ios/device/physical_device_mixin.rb +266 -0
- data/lib/calabash/ios/device/rotation_mixin.rb +124 -0
- data/lib/calabash/ios/device/routes/backdoor_route_mixin.rb +86 -0
- data/lib/calabash/ios/device/routes/condition_route_mixin.rb +62 -0
- data/lib/calabash/ios/device/routes/error.rb +8 -0
- data/lib/calabash/ios/device/routes/handle_route_mixin.rb +102 -0
- data/lib/calabash/ios/device/routes/map_route_mixin.rb +38 -0
- data/lib/calabash/ios/device/routes/playback_route_mixin.rb +70 -0
- data/lib/calabash/ios/device/routes/response_parser.rb +48 -0
- data/lib/calabash/ios/device/routes/uia_route_mixin.rb +238 -0
- data/lib/calabash/ios/device/runtime_attributes.rb +184 -0
- data/lib/calabash/ios/device/status_bar_mixin.rb +17 -0
- data/lib/calabash/ios/device/text_mixin.rb +19 -0
- data/lib/calabash/ios/device/uia_keyboard_mixin.rb +188 -0
- data/lib/calabash/ios/device/uia_mixin.rb +12 -0
- data/lib/calabash/ios/environment.rb +41 -0
- data/lib/calabash/ios/interactions.rb +10 -0
- data/lib/calabash/ios/lib/.irbrc +55 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_down_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_down_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_left_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_left_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_right_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_right_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_up_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_up_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_down_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_down_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_left_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_left_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_right_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_right_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_up_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_up_iphone.base64 +2 -0
- data/lib/calabash/ios/orientation.rb +117 -0
- data/lib/calabash/ios/scroll.rb +504 -0
- data/lib/calabash/ios/server.rb +73 -0
- data/lib/calabash/ios/text.rb +248 -0
- data/lib/calabash/ios/uia.rb +24 -0
- data/lib/calabash/lib/skeleton/config/cucumber.yml +6 -0
- data/lib/calabash/lib/skeleton/features/sample.feature +5 -0
- data/lib/calabash/lib/skeleton/features/step_definitions/calabash_steps.rb +29 -0
- data/lib/calabash/lib/skeleton/features/support/env.rb +54 -0
- data/lib/calabash/lib/skeleton/features/support/hooks.rb +83 -0
- data/lib/calabash/life_cycle.rb +111 -0
- data/lib/calabash/location.rb +51 -0
- data/lib/calabash/logger.rb +87 -0
- data/lib/calabash/orientation.rb +84 -0
- data/lib/calabash/page.rb +35 -0
- data/lib/calabash/patch.rb +14 -0
- data/lib/calabash/patch/array.rb +16 -0
- data/lib/calabash/patch/run_loop.rb +90 -0
- data/lib/calabash/query.rb +160 -0
- data/lib/calabash/query_result.rb +85 -0
- data/lib/calabash/screenshot.rb +89 -0
- data/lib/calabash/server.rb +16 -0
- data/lib/calabash/text.rb +76 -0
- data/lib/calabash/utility.rb +58 -0
- data/lib/calabash/version.rb +3 -1
- data/lib/calabash/wait.rb +474 -0
- metadata +462 -24
@@ -0,0 +1,51 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
package="#testPackage#"
|
4
|
+
android:versionCode="3"
|
5
|
+
android:versionName="0.3.0">
|
6
|
+
<application android:label="instrumentation_backend">
|
7
|
+
<uses-library android:name="android.test.runner" />
|
8
|
+
<uses-library android:name="com.google.android.maps" android:required="false" />
|
9
|
+
<activity
|
10
|
+
android:name="sh.calaba.instrumentationbackend.WakeUp"
|
11
|
+
android:label="WakeUp"
|
12
|
+
android:exported="true"
|
13
|
+
android:launchMode="singleInstance"
|
14
|
+
android:finishOnTaskLaunch="true"
|
15
|
+
android:stateNotNeeded="true"
|
16
|
+
android:noHistory="false"
|
17
|
+
android:excludeFromRecents="true"/>
|
18
|
+
<activity
|
19
|
+
android:name="sh.calaba.instrumentationbackend.StatusReporterActivity"
|
20
|
+
android:label="StatusReporterActivity"
|
21
|
+
android:exported="true"
|
22
|
+
android:finishOnTaskLaunch="true"
|
23
|
+
android:stateNotNeeded="true"
|
24
|
+
android:noHistory="true"
|
25
|
+
android:excludeFromRecents="true"/>
|
26
|
+
<activity
|
27
|
+
android:name="sh.calaba.instrumentationbackend.ResumeTaskActivity"
|
28
|
+
android:label="ResumeTaskActivity"
|
29
|
+
android:exported="true"
|
30
|
+
android:finishOnTaskLaunch="true"
|
31
|
+
android:stateNotNeeded="true"
|
32
|
+
android:noHistory="true"
|
33
|
+
android:excludeFromRecents="true"/>
|
34
|
+
</application>
|
35
|
+
<uses-sdk android:minSdkVersion="4" />
|
36
|
+
<instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner" />
|
37
|
+
<instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearAppData" />
|
38
|
+
<instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearAppData2" />
|
39
|
+
<instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearPreferences" />
|
40
|
+
<instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.SetPreferences" />
|
41
|
+
<instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.GetPreferences" />
|
42
|
+
|
43
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
44
|
+
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
|
45
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
46
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
47
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
48
|
+
<uses-permission android:name="android.permission.GET_TASKS" />
|
49
|
+
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
50
|
+
|
51
|
+
</manifest>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Android
|
3
|
+
module LifeCycle
|
4
|
+
# Resume an application. If the application is already focused, nothing
|
5
|
+
# will happen.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# go_home
|
9
|
+
# resume_app
|
10
|
+
#
|
11
|
+
# @param [String, Calabash::Application] path_or_application The
|
12
|
+
# application to resume.
|
13
|
+
def resume_app(path_or_application = nil)
|
14
|
+
path_or_application ||= Application.default
|
15
|
+
|
16
|
+
unless path_or_application
|
17
|
+
raise 'No application given, and Application.default is not set'
|
18
|
+
end
|
19
|
+
|
20
|
+
Device.default.resume_app(path_or_application)
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# !@visibility private
|
27
|
+
def _send_current_app_to_background(for_seconds)
|
28
|
+
package = focused_package
|
29
|
+
activity = focused_activity
|
30
|
+
|
31
|
+
go_home
|
32
|
+
sleep(for_seconds)
|
33
|
+
Device.default.resume_activity(package, activity)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Android
|
3
|
+
module Orientation
|
4
|
+
# @!visibility private
|
5
|
+
def _set_orientation_landscape
|
6
|
+
Device.default.perform_action('set_activity_orientation', 'landscape')
|
7
|
+
end
|
8
|
+
|
9
|
+
# @!visibility private
|
10
|
+
def _set_orientation_portrait
|
11
|
+
Device.default.perform_action('set_activity_orientation', 'portrait')
|
12
|
+
end
|
13
|
+
|
14
|
+
# @!visibility private
|
15
|
+
def _portrait?
|
16
|
+
_orientation == 'portrait'
|
17
|
+
end
|
18
|
+
|
19
|
+
# @!visibility private
|
20
|
+
def _landscape?
|
21
|
+
_orientation == 'landscape'
|
22
|
+
end
|
23
|
+
|
24
|
+
# @!visibility private
|
25
|
+
def _orientation
|
26
|
+
Device.default.perform_action('get_activity_orientation')['message']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# @todo: Add not about this class being easily abused
|
2
|
+
module Calabash
|
3
|
+
module Android
|
4
|
+
module PhysicalButtons
|
5
|
+
def press_button(key)
|
6
|
+
Device.default.perform_action('press_key', key)
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def press_back_button
|
11
|
+
press_button('KEYCODE_BACK')
|
12
|
+
end
|
13
|
+
|
14
|
+
def press_menu_button
|
15
|
+
press_button('KEYCODE_MENU')
|
16
|
+
end
|
17
|
+
|
18
|
+
def press_down_button
|
19
|
+
press_button('KEYCODE_DPAD_DOWN')
|
20
|
+
end
|
21
|
+
|
22
|
+
def press_up_button
|
23
|
+
press_button('KEYCODE_DPAD_UP')
|
24
|
+
end
|
25
|
+
|
26
|
+
def press_left_button
|
27
|
+
press_button('KEYCODE_DPAD_LEFT')
|
28
|
+
end
|
29
|
+
|
30
|
+
def press_right_button
|
31
|
+
press_button('KEYCODE_DPAD_RIGHT')
|
32
|
+
end
|
33
|
+
|
34
|
+
def press_enter_button
|
35
|
+
press_button('KEYCODE_ENTER')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Android
|
3
|
+
module Text
|
4
|
+
def dismiss_keyboard
|
5
|
+
Device.default.perform_action('hide_soft_keyboard')
|
6
|
+
end
|
7
|
+
|
8
|
+
# Taps a keyboard action key on the keyboard. Notice that Calabash does
|
9
|
+
# not ensure that this particular action key is actually available on the
|
10
|
+
# current keyboard.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# tap_keyboard_action_key(:normal)
|
14
|
+
# tap_keyboard_action_key(:unspecified)
|
15
|
+
# tap_keyboard_action_key(:none)
|
16
|
+
# tap_keyboard_action_key(:go)
|
17
|
+
# tap_keyboard_action_key(:search)
|
18
|
+
# tap_keyboard_action_key(:send)
|
19
|
+
# tap_keyboard_action_key(:next)
|
20
|
+
# tap_keyboard_action_key(:done)
|
21
|
+
# tap_keyboard_action_key(:previous)
|
22
|
+
#
|
23
|
+
# @see http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html
|
24
|
+
#
|
25
|
+
# @param [Symbol] action_key The key to press.
|
26
|
+
def tap_keyboard_action_key(action_key)
|
27
|
+
Device.default.perform_action('press_user_action_button', action_key.to_s)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!visibility private
|
31
|
+
def _clear_text
|
32
|
+
Device.default.perform_action('clear_text')
|
33
|
+
end
|
34
|
+
|
35
|
+
def _clear_text_in(view)
|
36
|
+
tap(view)
|
37
|
+
sleep 0.5
|
38
|
+
clear_text
|
39
|
+
end
|
40
|
+
|
41
|
+
# @!visibility private
|
42
|
+
def _enter_text_in(view, text)
|
43
|
+
tap(view)
|
44
|
+
sleep 0.5
|
45
|
+
enter_text(text)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @!visibility private
|
49
|
+
def _tap_current_keyboard_action_key
|
50
|
+
Device.default.perform_action('press_user_action_button')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
3
|
+
module Calabash
|
4
|
+
# A representation of the application that is under test.
|
5
|
+
class Application
|
6
|
+
include Calabash::Utility
|
7
|
+
|
8
|
+
@@default = nil
|
9
|
+
|
10
|
+
def self.default
|
11
|
+
@@default
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.default=(value)
|
15
|
+
@@default = value
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :path
|
19
|
+
|
20
|
+
def self.from_path(path)
|
21
|
+
extension = File.extname(path)
|
22
|
+
|
23
|
+
case extension
|
24
|
+
when '.apk'
|
25
|
+
Android::Application.new(path, nil)
|
26
|
+
when '.ipa', '.app'
|
27
|
+
IOS::Application.new(path)
|
28
|
+
else
|
29
|
+
Application.new(path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @raise [RuntimeError] Raises an error if `application_path` does not
|
34
|
+
# exist.
|
35
|
+
def initialize(application_path, options = {})
|
36
|
+
if application_path.nil?
|
37
|
+
raise ArgumentError, "Invalid application path '#{application_path}'."
|
38
|
+
end
|
39
|
+
|
40
|
+
@path = File.expand_path(application_path)
|
41
|
+
@logger = options[:logger] || Calabash::Logger.new
|
42
|
+
@identifier = options[:identifier]
|
43
|
+
ensure_application_path
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
"#<Application #{path}>"
|
48
|
+
end
|
49
|
+
|
50
|
+
def inspect
|
51
|
+
to_s
|
52
|
+
end
|
53
|
+
|
54
|
+
def extract_identifier
|
55
|
+
abstract_method!
|
56
|
+
end
|
57
|
+
|
58
|
+
def identifier
|
59
|
+
@identifier ||= extract_identifier
|
60
|
+
end
|
61
|
+
|
62
|
+
def md5_checksum
|
63
|
+
Digest::MD5.file(path).hexdigest
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def ensure_application_path
|
69
|
+
unless File.exist?(path)
|
70
|
+
raise "The app '#{path}' does not exist."
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/calabash/cli.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calabash
|
2
|
+
# @!visibility private
|
3
|
+
module CLI
|
4
|
+
require 'calabash/cli/build'
|
5
|
+
require 'calabash/cli/console'
|
6
|
+
require 'calabash/cli/generate'
|
7
|
+
require 'calabash/cli/helpers'
|
8
|
+
require 'calabash/cli/resign'
|
9
|
+
require 'calabash/cli/run'
|
10
|
+
require 'calabash/cli/setup_keystore'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Calabash
|
2
|
+
module CLI
|
3
|
+
# @!visibility private
|
4
|
+
module Build
|
5
|
+
def parse_build_arguments!
|
6
|
+
fail('Should only build test-server for Android') unless @platform.nil? || @platform == :android
|
7
|
+
|
8
|
+
application = @arguments.shift
|
9
|
+
|
10
|
+
if application.nil?
|
11
|
+
fail('Must supply application as first parameter to build', :build)
|
12
|
+
elsif !File.exists?(application)
|
13
|
+
fail("File '#{application}' does not exist", :build)
|
14
|
+
else
|
15
|
+
extension = File.extname(application)
|
16
|
+
application_path = File.expand_path(application)
|
17
|
+
|
18
|
+
case extension
|
19
|
+
when '.apk'
|
20
|
+
set_platform!(:android)
|
21
|
+
Calabash::Android::Build::Builder.new(application_path).build
|
22
|
+
when '.ipa', '.app'
|
23
|
+
set_platform!(:ios)
|
24
|
+
fail('Should only build test-server for Android')
|
25
|
+
else
|
26
|
+
fail('Application must be an apk', :build)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Calabash
|
2
|
+
# @!visibility private
|
3
|
+
module CLI
|
4
|
+
# @!visibility private
|
5
|
+
module Console
|
6
|
+
def parse_console_arguments!
|
7
|
+
application = @arguments.shift
|
8
|
+
|
9
|
+
if application.nil?
|
10
|
+
Logger.info("No application specified. Using default application specified by env variable CAL_APP")
|
11
|
+
application = Environment::APP_PATH
|
12
|
+
Logger.debug("New application: '#{application}'")
|
13
|
+
|
14
|
+
fail("No application given and env variable CAL_APP is not set.", :console) if application.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
if File.exists?(application)
|
18
|
+
extension = File.extname(application)
|
19
|
+
application_path = File.expand_path(application)
|
20
|
+
|
21
|
+
case extension
|
22
|
+
when '.apk'
|
23
|
+
set_platform!(:android)
|
24
|
+
|
25
|
+
# Create the test server if it does not exist
|
26
|
+
test_server = Android::Build::TestServer.new(application_path)
|
27
|
+
|
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
|
31
|
+
end
|
32
|
+
|
33
|
+
enter_console(application_path)
|
34
|
+
when '.ipa'
|
35
|
+
set_platform!(:ios)
|
36
|
+
enter_console(application_path)
|
37
|
+
when '.app'
|
38
|
+
set_platform!(:ios)
|
39
|
+
enter_console(application_path)
|
40
|
+
else
|
41
|
+
fail('Application must be either an .apk, .ipa or .app', :console)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
fail("File '#{application}' does not exist", :console)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def enter_console(application_path)
|
49
|
+
irbrc_path = Environment::IRBRC
|
50
|
+
|
51
|
+
console_environment = {}
|
52
|
+
console_environment['CAL_DEBUG'] = Environment::DEBUG ? '1' : '0'
|
53
|
+
|
54
|
+
if @options[:verbose]
|
55
|
+
console_environment['CAL_DEBUG'] = '1'
|
56
|
+
end
|
57
|
+
|
58
|
+
if @platform == :android
|
59
|
+
irbrc_path ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'android', 'lib', '.irbrc'))
|
60
|
+
|
61
|
+
console_environment['CAL_APP'] = application_path
|
62
|
+
|
63
|
+
if Environment::TEST_SERVER_PATH
|
64
|
+
console_environment['CAL_TEST_SERVER'] = Environment::TEST_SERVER_PATH
|
65
|
+
else
|
66
|
+
test_server = Android::Build::TestServer.new(application_path)
|
67
|
+
|
68
|
+
raise 'Cannot locate test-server' unless test_server.exists?
|
69
|
+
|
70
|
+
console_environment['CAL_TEST_SERVER'] = test_server.path
|
71
|
+
end
|
72
|
+
elsif @platform == :ios
|
73
|
+
irbrc_path ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'ios', 'lib', '.irbrc'))
|
74
|
+
|
75
|
+
console_environment['CAL_APP'] = application_path
|
76
|
+
else
|
77
|
+
raise "Invalid platform '#{@platform}'"
|
78
|
+
end
|
79
|
+
|
80
|
+
console_environment['IRBRC'] = irbrc_path
|
81
|
+
|
82
|
+
Logger.info 'Running irb...'
|
83
|
+
Logger.debug "From file: '#{irbrc_path}'"
|
84
|
+
Logger.debug "With ENV: '#{console_environment}'"
|
85
|
+
|
86
|
+
exec(console_environment, RbConfig.ruby, '-S', 'irb')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|