calabash-android 0.5.9.pre2.intenthook1 → 0.5.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2226c9b34c84a1b0422800524649f84ffefc6283
4
- data.tar.gz: 5115917d4f83acdf0a2c3a7cf06edd3209020c2a
3
+ metadata.gz: 3765a162f326008fc737619e6d8f149c0fe8a4fd
4
+ data.tar.gz: f2fce1b20c9c6e69a85e328a74eb886afbd397bd
5
5
  SHA512:
6
- metadata.gz: 6b667d23282054ba0f798c67565bc45741b280ac15c336712b4df38fc526dcae74b872a11ff9e7bfc18f171183741e7680bfb5d3838f5b00b6ddaa71e4153c8e
7
- data.tar.gz: c52e63f05e04e0d32cff45d8988b2e74598065f97c1011d1517bf508c43bfe1a5502250962fe6e770537c91c3c03e00c3d0e180ce041f98d86a7cb7a7bdf4128
6
+ metadata.gz: 990a188d46509fec9345ee313cfc9d182b6f0fcaaf8e586cf2c6fea96c0a3ada74363837bbe81f6bc7423bda37d852080eb7e4d533e9a579d047f42cc3d883c2
7
+ data.tar.gz: 1be5b0c4f6aaf841b522623e9899c115fe28c8ebae9ea7f47a8ba764f9be4da755b64e637884198ada3903f061b427b3078292be0312269d21b1673ab6955261
@@ -1,3 +1,12 @@
1
+ 0.5.9
2
+ Fix crosswalk queries giving wrong coordinates.
3
+
4
+ Fix client rescuing `Exceptions`
5
+
6
+ Support signing with DSA certificates
7
+
8
+ Support indexes in css/xpath queries.
9
+
1
10
  0.5.8
2
11
  Handle `embed` if Calabash Android was 'included' instead of added
3
12
  to the Cucumber World
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ def build
15
15
  "package",
16
16
  "-debug",
17
17
  "-Dtools.dir=\"#{Env.tools_dir}\"",
18
- "-Dandroid.api.level=21",
18
+ "-Dandroid.api.level=19",
19
19
  "-Dversion=#{Calabash::Android::VERSION}",
20
20
  ]
21
21
  Dir.chdir(@test_server_dir) do
@@ -58,7 +58,7 @@ def calabash_build(app)
58
58
  keystore.sign_apk("#{workspace_dir}/TestServer.apk", test_server_file_name)
59
59
  begin
60
60
 
61
- rescue Exception => e
61
+ rescue => e
62
62
  log e
63
63
  raise "Could not sign test server"
64
64
  end
@@ -14,9 +14,6 @@ require 'calabash-android/touch_helpers'
14
14
  require 'calabash-android/wait_helpers'
15
15
  require 'calabash-android/version'
16
16
  require 'calabash-android/env'
17
- require 'calabash-android/android_intent'
18
- require 'calabash-android/android_component'
19
- require 'calabash-android/intent_hook'
20
17
  require 'retriable'
21
18
  require 'cucumber'
22
19
  require 'date'
@@ -59,14 +56,11 @@ module Calabash module Android
59
56
  end
60
57
 
61
58
  def default_device
62
- unless @default_device
63
- @default_device = Device.new(self, ENV["ADB_DEVICE_ARG"], ENV["TEST_SERVER_PORT"], ENV["APP_PATH"], ENV["TEST_APP_PATH"])
64
- end
65
- @default_device
59
+ @@default_device ||= Device.new(self, ENV["ADB_DEVICE_ARG"], ENV["TEST_SERVER_PORT"], ENV["APP_PATH"], ENV["TEST_APP_PATH"])
66
60
  end
67
61
 
68
62
  def set_default_device(device)
69
- @default_device = device
63
+ @@default_device = device
70
64
  end
71
65
 
72
66
  def performAction(action, *arguments)
@@ -281,17 +275,15 @@ module Calabash module Android
281
275
  class Device
282
276
  attr_reader :app_path, :test_server_path, :serial, :server_port, :test_server_port
283
277
 
284
- def initialize(cucumber_world, serial, server_port, app_path,
285
- test_server_path, test_server_port = 7102)
278
+ def initialize(cucumber_world, serial, server_port, app_path, test_server_path, test_server_port = 7102)
279
+
286
280
  @cucumber_world = cucumber_world
287
281
  @serial = serial || default_serial
288
282
  @server_port = server_port || default_server_port
289
283
  @app_path = app_path
290
284
  @test_server_path = test_server_path
291
285
  @test_server_port = test_server_port
292
- end
293
286
 
294
- def forward_port
295
287
  forward_cmd = "#{adb_command} forward tcp:#{@server_port} tcp:#{@test_server_port}"
296
288
  log forward_cmd
297
289
  log `#{forward_cmd}`
@@ -370,7 +362,7 @@ module Calabash module Android
370
362
  Timeout.timeout(300) do
371
363
  begin
372
364
  result = http("/", params, {:read_timeout => 350})
373
- rescue Exception => e
365
+ rescue => e
374
366
  log "Error communicating with test server: #{e}"
375
367
  raise e
376
368
  end
@@ -383,7 +375,7 @@ module Calabash module Android
383
375
  result
384
376
  end
385
377
  rescue Timeout::Error
386
- raise Exception, "Step timed out"
378
+ raise "Step timed out"
387
379
  end
388
380
 
389
381
  def http(path, data = {}, options = {})
@@ -405,25 +397,6 @@ module Calabash module Android
405
397
  end
406
398
  end
407
399
 
408
- def http_put(path, data = {}, options = {})
409
- begin
410
-
411
- configure_http(@http, options)
412
- make_http_request(
413
- :method => :put,
414
- :body => data,
415
- :uri => url_for(path),
416
- :header => {"Content-Type" => "application/octet-stream"})
417
-
418
- rescue HTTPClient::TimeoutError,
419
- HTTPClient::KeepAliveDisconnected,
420
- Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
421
- Errno::ETIMEDOUT => e
422
- log "It looks like your app is no longer running. \nIt could be because of a crash or because your test script shut it down."
423
- raise e
424
- end
425
- end
426
-
427
400
  def set_http(http)
428
401
  @http = http
429
402
  end
@@ -448,18 +421,18 @@ module Calabash module Android
448
421
  @http = init_request(options)
449
422
  end
450
423
  header = options[:header] || {}
451
- header["Content-Type"] ||= "application/json;charset=utf-8"
424
+ header["Content-Type"] = "application/json;charset=utf-8"
425
+ options[:header] = header
426
+
452
427
 
453
428
  response = if options[:method] == :post
454
429
  @http.post(options[:uri], options)
455
- elsif options[:method] == :put
456
- @http.put(options[:uri], options)
457
430
  else
458
431
  @http.get(options[:uri], options)
459
432
  end
460
433
  raise Errno::ECONNREFUSED if response.status_code == 502
461
434
  response.body
462
- rescue Exception => e
435
+ rescue => e
463
436
  if @http
464
437
  @http.reset_all
465
438
  @http=nil
@@ -617,8 +590,6 @@ module Calabash module Android
617
590
  wake_up
618
591
  end
619
592
 
620
- forward_port
621
-
622
593
  env_options = options
623
594
 
624
595
  env_options[:target_package] ||= package_name(@app_path)
@@ -659,7 +630,7 @@ module Calabash module Android
659
630
  log "Instrumentation backend is ready!"
660
631
  end
661
632
  end
662
- rescue Exception => e
633
+ rescue => e
663
634
 
664
635
  msg = "Unable to make connection to Calabash Test Server at http://127.0.0.1:#{@server_port}/\n"
665
636
  msg << "Please check the logcat output for more info about what happened\n"
@@ -714,7 +685,7 @@ module Calabash module Android
714
685
  def set_gps_coordinates_from_location(location)
715
686
  require 'geocoder'
716
687
  results = Geocoder.search(location)
717
- raise Exception, "Got no results for #{location}" if results.empty?
688
+ raise "Got no results for #{location}" if results.empty?
718
689
 
719
690
  best_result = results.first
720
691
  set_gps_coordinates(best_result.latitude, best_result.longitude)
@@ -838,13 +809,13 @@ module Calabash module Android
838
809
  ni
839
810
  end
840
811
 
841
- def screenshot_and_raise(msg, options = nil)
812
+ def screenshot_and_raise(e, options = nil)
842
813
  if options
843
814
  screenshot_embed options
844
815
  else
845
816
  screenshot_embed
846
817
  end
847
- raise(msg)
818
+ raise e
848
819
  end
849
820
 
850
821
  def hide_soft_keyboard
@@ -874,10 +845,6 @@ module Calabash module Android
874
845
  default_device.http(path, data, options)
875
846
  end
876
847
 
877
- def http_put(path, data = {}, options = {})
878
- default_device.http_put(path, data, options)
879
- end
880
-
881
848
  def html(q)
882
849
  query(q).map {|e| e['html']}
883
850
  end
@@ -1212,54 +1179,6 @@ module Calabash module Android
1212
1179
  result['result']
1213
1180
  end
1214
1181
 
1215
- def last_broadcast_intent
1216
- result = JSON.parse(http("/last-broadcast-intent"))
1217
-
1218
- unless result['outcome'] == 'SUCCESS'
1219
- raise "/last-broadcast-intent failed because: #{result['reason']}\n#{result['detail']}"
1220
- end
1221
-
1222
- json = JSON.parse(result['result'])
1223
-
1224
- if json.nil?
1225
- nil
1226
- else
1227
- AndroidIntent.from_json(json)
1228
- end
1229
- end
1230
-
1231
- def add_file(path_or_file)
1232
- file = File.new(path_or_file)
1233
-
1234
- http_put('/add-file', File.binread(file))
1235
- end
1236
-
1237
- def add_intent_hook(intent_hook)
1238
- result = JSON.parse(http('/intent-hook', intent_hook))
1239
-
1240
- if result['outcome'] && result['outcome'] != 'SUCCESS'
1241
- raise "/intent-hook failed because: #{result['reason']}\n#{result['detail']}"
1242
- end
1243
- end
1244
-
1245
- def fake_camera_with_image(path_or_file, usage_count=1)
1246
- file = File.new(path_or_file)
1247
-
1248
- extension = File.extname(path_or_file)
1249
-
1250
- if extension != '.jpg' && extension != '.jpeg'
1251
- raise ArgumentError, "Supplied image file must be a .jpg or .jpeg, not '#{extension}'"
1252
- end
1253
-
1254
- file_on_device = add_file(file)
1255
-
1256
- intent = Calabash::Android::AndroidIntent.with_action('android.media.action.IMAGE_CAPTURE')
1257
- filter = Calabash::Android::IntentHook::Filter.new(intent)
1258
- reaction = Calabash::Android::IntentHook::Reaction.take_picture(file_on_device)
1259
-
1260
- add_intent_hook(Calabash::Android::IntentHook.new(reaction, filter, usage_count))
1261
- end
1262
-
1263
1182
  def map(query, method_name, *method_args)
1264
1183
  operation_map = {
1265
1184
  :method_name => method_name,
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.5.9.pre2.intenthook1"
3
+ VERSION = "0.5.9"
4
4
  end
5
5
  end
@@ -48,7 +48,7 @@ module Calabash
48
48
  else
49
49
  raise wait_error(msg)
50
50
  end
51
- rescue Exception => e
51
+ rescue => e
52
52
  handle_error_with_options(e, nil, screenshot_on_error)
53
53
  end
54
54
  end
@@ -116,14 +116,13 @@ module Calabash
116
116
  end
117
117
 
118
118
  def handle_error_with_options(ex, timeout_message, screenshot_on_error)
119
- msg = (timeout_message || ex)
120
- if ex
121
- msg = "#{msg} (#{ex.class})"
122
- end
119
+ error_class = (ex && ex.class) || RuntimeError
120
+ error = error_class.new(timeout_message || ex.message)
121
+
123
122
  if screenshot_on_error
124
- screenshot_and_raise msg
123
+ screenshot_and_raise error
125
124
  else
126
- raise msg
125
+ raise error
127
126
  end
128
127
  end
129
128
 
@@ -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
@@ -17,18 +15,8 @@
17
15
  android:stateNotNeeded="true"
18
16
  android:noHistory="false"
19
17
  android:excludeFromRecents="true"/>
20
- <activity
21
- android:name="sh.calaba.instrumentationbackend.FakeCameraActivity"
22
- android:label="FakeCameraActivity"
23
- android:exported="true"
24
- android:finishOnTaskLaunch="true"
25
- android:stateNotNeeded="true"
26
- android:noHistory="true"
27
- android:excludeFromRecents="true"
28
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
29
18
  </application>
30
- <uses-sdk android:minSdkVersion="4"
31
- android:targetSdkVersion="21"/>
19
+ <uses-sdk android:minSdkVersion="4" />
32
20
  <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner" />
33
21
  <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearAppData" />
34
22
  <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.ClearPreferences" />
@@ -40,6 +28,5 @@
40
28
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
41
29
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
42
30
  <uses-permission android:name="android.permission.INTERNET" />
43
- <uses-permission android:name="android.permission.CAMERA" />
44
31
 
45
32
  </manifest>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9.pre2.intenthook1
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Maturana Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -210,8 +210,6 @@ files:
210
210
  - irbrc
211
211
  - lib/calabash-android.rb
212
212
  - lib/calabash-android/abase.rb
213
- - lib/calabash-android/android_component.rb
214
- - lib/calabash-android/android_intent.rb
215
213
  - lib/calabash-android/calabash_steps.rb
216
214
  - lib/calabash-android/canned_steps.md
217
215
  - lib/calabash-android/color_helper.rb
@@ -222,7 +220,6 @@ files:
222
220
  - lib/calabash-android/environment_helpers.rb
223
221
  - lib/calabash-android/gestures.rb
224
222
  - lib/calabash-android/helpers.rb
225
- - lib/calabash-android/intent_hook.rb
226
223
  - lib/calabash-android/java_keystore.rb
227
224
  - lib/calabash-android/lib/AXMLPrinter2.jar
228
225
  - lib/calabash-android/lib/manifest_extractor.jar
@@ -269,9 +266,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
266
  version: '0'
270
267
  required_rubygems_version: !ruby/object:Gem::Requirement
271
268
  requirements:
272
- - - '>'
269
+ - - '>='
273
270
  - !ruby/object:Gem::Version
274
- version: 1.3.1
271
+ version: '0'
275
272
  requirements: []
276
273
  rubyforge_project:
277
274
  rubygems_version: 2.0.2
@@ -1,23 +0,0 @@
1
- module Calabash
2
- module Android
3
- class AndroidComponent
4
- attr_reader :package_name, :class_name
5
-
6
- def initialize(package_name, class_name)
7
- @package_name = package_name
8
- @class_name = class_name
9
- end
10
-
11
- def self.from_json(json)
12
- self.new(json['packageName'], json['className'])
13
- end
14
-
15
- def to_json(*a)
16
- {
17
- 'className' => class_name,
18
- 'packageName' => package_name
19
- }.to_json
20
- end
21
- end
22
- end
23
- end
@@ -1,60 +0,0 @@
1
- module Calabash
2
- module Android
3
- class AndroidIntent
4
- attr_reader :action, :data, :flags, :package, :type, :component, :extras
5
- attr_reader :clip_data, :intent_index
6
-
7
- def self.with_action(action)
8
- android_intent = AndroidIntent.new
9
-
10
- android_intent.instance_eval do
11
- @action = action
12
- end
13
-
14
- android_intent
15
- end
16
-
17
- def self.from_json(json)
18
- android_intent = AndroidIntent.new
19
-
20
- intent_json = json['intent']
21
- index = json['index']
22
-
23
- android_intent.instance_eval do
24
- unless intent_json.nil?
25
- @action = intent_json['action']
26
- @data = intent_json['data'] && URI.parse(intent_json['data'])
27
- @flags = intent_json['flags']
28
- @package = intent_json['package']
29
- @type = intent_json['type']
30
- @component =
31
- intent_json['component'] && AndroidComponent.from_json(intent_json['component'])
32
- @clip_data = intent_json['clipData']
33
-
34
- @extras = intent_json['extras']
35
- end
36
-
37
- @intent_index = index
38
- end
39
-
40
- android_intent
41
- end
42
-
43
- def to_json(*a)
44
- {
45
- 'index' => intent_index,
46
- 'intent' => {
47
- 'action' => action,
48
- 'data' => data,
49
- 'flags' => flags,
50
- 'package' => package,
51
- 'type' => type,
52
- 'component' => component,
53
- 'clipData' => clip_data,
54
- 'extras' => extras
55
- }
56
- }.to_json
57
- end
58
- end
59
- end
60
- end
@@ -1,106 +0,0 @@
1
- module Calabash
2
- module Android
3
- class IntentHook
4
- USAGE_COUNT_INFINITE = -1
5
-
6
- attr_reader :reaction, :filter, :usage_count
7
-
8
- def initialize(reaction, filter, usage_count=USAGE_COUNT_INFINITE)
9
- @reaction = reaction
10
- @filter = filter
11
- @usage_count = usage_count.to_i
12
- end
13
-
14
- def to_json(*a)
15
- {
16
- 'usageCount' => usage_count,
17
- 'type' => reaction.type.to_s,
18
- 'data' => reaction.data_as_hash,
19
- 'intentFilterData' => filter
20
- }.to_json
21
- end
22
-
23
- class Filter
24
- attr_reader :intent
25
-
26
- def initialize(intent)
27
- @intent = intent
28
- end
29
-
30
- def to_json(*a)
31
- {
32
- 'action' => intent.action,
33
- 'component' => intent.component
34
- }.to_json
35
- end
36
- end
37
-
38
- class Reaction
39
- attr_reader :type, :data
40
-
41
- def data_as_hash
42
- @data_hash_method.call
43
- end
44
-
45
- def self.do_nothing
46
- reaction = Reaction.new
47
-
48
- reaction.instance_eval do
49
- @type = :'do-nothing'
50
- end
51
-
52
- reaction
53
- end
54
-
55
- def self.take_picture(path_on_device)
56
- reaction = Reaction.new
57
- data = {image_file: path_on_device}
58
-
59
- reaction.instance_eval do
60
- @type = :'take-picture'
61
- @data = data
62
- @data_hash_method = lambda do
63
- {
64
- 'imageFile' => @data[:image_file],
65
- }
66
- end
67
- end
68
-
69
- reaction
70
- end
71
-
72
- def self.instrumentation(data)
73
- param_data = data.dup
74
-
75
- if param_data[:test_server_port].nil? ||
76
- param_data[:target_package].nil?
77
- raise 'Must provide :test_server_port and :target_package'
78
- end
79
-
80
- param_data[:class] ||= 'sh.calaba.instrumentationbackend.InstrumentationBackend'
81
-
82
- param_data[:component] ||=
83
- AndroidComponent.new("#{param_data[:target_package]}.test",
84
- 'sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner')
85
-
86
- reaction = Reaction.new
87
-
88
- reaction.instance_eval do
89
- @type = :instrumentation
90
- @data = param_data
91
- @data_hash_method = lambda do
92
- {
93
- 'testServerPort' => @data[:test_server_port],
94
- 'targetPackage' => @data[:target_package],
95
- 'class' => @data[:class],
96
- 'mainActivity' => @data[:main_activity],
97
- }
98
- end
99
- end
100
-
101
- reaction
102
- end
103
- end
104
- end
105
- end
106
- end