calabash-cucumber 0.9.163.pre4 → 0.9.163.pre5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92fe46c72cf7c198d794ddba2a518ecda59757d9
4
- data.tar.gz: d0fc8270c277166fcda42080a6d05adf6b3e1a02
3
+ metadata.gz: e3890c3b5aea8c789a8aa90c226ae528d6e17e78
4
+ data.tar.gz: 21991600f65969e8eb8018a2bb835a110f86bbe9
5
5
  SHA512:
6
- metadata.gz: 7fd73184e610036cebeb6f8a842f258f7cd49b6fd6dbe6edb68e7c5c4f868f4b0c564d868c12523c9301f132e7c92f515ccfc572e5f7bc84b4f206e658f8addf
7
- data.tar.gz: 01361b87b9afebba12e99e53d05c808ed093238ead4f5413249a227af14adf32d631664119f5b12127ea135818c03ec7b78670848a60a959cf4118c0b78fd4e8
6
+ metadata.gz: c46c1d2d0b74cb6f9ff7944563b71e23c1fab55df66b57ad19f7f33694df09e9c738e696ab56846ba6ee21d5d3c8e4f6b58d62c9fb071c7748c5b0c2d272d0f8
7
+ data.tar.gz: 641ae6857ccd75f7bf46e9837ef72fe4594baef5df30733e7a1717e0203c8aa95e4d2ecc0f1e7f14d5f3d13ac9eeaa2cc79795c256954dc1d911c43a806bec06
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency( "geocoder", "~>1.1.8")
27
27
  s.add_dependency( "httpclient","~> 2.3.3")
28
28
  s.add_dependency( "bundler", "~> 1.1")
29
- s.add_dependency( "run_loop", "~> 0.1.0.pre1" )
29
+ s.add_dependency( "run_loop", "~> 0.1.0.pre3" )
30
30
  s.add_dependency( "awesome_print")
31
31
  s.add_dependency( "xamarin-test-cloud", "~> 0.9.25")
32
32
 
@@ -101,15 +101,20 @@ module Calabash
101
101
  known = KEYPLANE_NAMES.values
102
102
 
103
103
  found = false
104
- ["shift", "more"].each do |key|
104
+ keyplane_selection_keys = ["shift", "more"]
105
+ keyplane_selection_keys.each do |key|
105
106
  plane = props["#{key}-alternate"]
106
107
  if (known.member?(plane) and
107
108
  not visited.member?(plane))
108
109
  keyboard_enter_char(key.capitalize, false)
109
110
  found = search_keyplanes_and_enter_char(chr, visited)
110
111
  return true if found
111
- #not found => go back
112
- keyboard_enter_char(key.capitalize, false)
112
+ #not found => try with other keyplane selection key
113
+ keyplane_selection_keys.delete(key)
114
+ other_key = keyplane_selection_keys.last
115
+ keyboard_enter_char(other_key.capitalize, false)
116
+ found = search_keyplanes_and_enter_char(chr, visited)
117
+ return true if found
113
118
  end
114
119
  end
115
120
  return false
@@ -245,8 +245,21 @@ module Calabash
245
245
  end
246
246
 
247
247
  def self.linked_with_calabash?(d)
248
- out = `otool "#{File.expand_path(d)}"/* -o 2> /dev/null | grep CalabashServer`
249
- /CalabashServer/.match(out)
248
+ skipped_formats = [".png", ".jpg", ".jpeg", ".plist", ".nib", ".lproj"]
249
+ dir = File.expand_path(d)
250
+
251
+ # For every file on that .app directory
252
+ Dir.entries(d).each do |file|
253
+ # If this is an asset or any of those skipped formats, skip it.
254
+ next if skipped_formats.include? File.extname(file)
255
+
256
+ # If its not, try to run otool against that file, check whether we are linked against calabash framework.
257
+ out = `otool #{dir}/#{file} -o 2> /dev/null | grep CalabashServer`
258
+ return true if /CalabashServer/.match(out)
259
+ end
260
+
261
+ # Defaulted to false
262
+ false
250
263
  end
251
264
 
252
265
  def self.find_preferred_dir(sim_dirs)
@@ -6,6 +6,8 @@ require 'cfpropertylist'
6
6
 
7
7
  class Calabash::Cucumber::Launcher
8
8
 
9
+ KNOWN_PRIVACY_SETTINGS = {:photos => 'kTCCServicePhotos', :calendar => 'kTCCServiceCalendar', :address_book => 'kTCCServiceAddressBook'}
10
+
9
11
  attr_accessor :run_loop
10
12
  attr_accessor :device
11
13
  attr_accessor :launch_args
@@ -80,13 +82,84 @@ class Calabash::Cucumber::Launcher
80
82
  path ||= Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
81
83
 
82
84
  app = File.basename(path)
83
- bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1`
84
- return if bundle.empty? # Assuming we're already clean
85
+ directories_for_sdk_prefix(sdk).each do |dir|
86
+ bundle = `find "#{dir}/Applications" -type d -depth 2 -name "#{app}" | head -n 1`
87
+ next if bundle.empty? # Assuming we're already clean
88
+ if ENV['DEBUG']=='1'
89
+ puts "Reset app state for #{bundle}"
90
+ end
91
+ sandbox = File.dirname(bundle)
92
+ ['Library', 'Documents', 'tmp'].each do |dir|
93
+ FileUtils.rm_rf(File.join(sandbox, dir))
94
+ end
95
+ end
96
+
97
+
98
+ end
99
+
100
+ def directories_for_sdk_prefix(sdk)
101
+ Dir["#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}*"]
102
+ end
103
+
104
+ # Call as update_privacy_settings('com.my.app', {:photo => {:allow => true}})
105
+ def update_privacy_settings(bundle_id, opts={})
106
+ if ENV['DEBUG']=='1'
107
+ puts "Update privacy settings #{bundle_id}, #{opts}"
108
+ end
109
+ unless File.exist?(`which sqlite3`.strip)
110
+ raise 'Error: Unable to find sqlite3. The binary sqlite3 must be installed and on path.'
111
+ end
112
+ opts.each do |setting_name, setting_options|
113
+
114
+ setting_name = KNOWN_PRIVACY_SETTINGS[setting_name] || setting_name
115
+ allow = setting_options[:allow] == false ? false : true
116
+ sdk = setting_options[:sdk] || SimLauncher::SdkDetector.new().latest_sdk_version
117
+
118
+ dirs = directories_for_sdk_prefix(sdk)
119
+ if ENV['DEBUG']=='1'
120
+ puts "About to update privacy setting #{setting_name} for #{bundle_id}, allow: #{allow} in sdk #{sdk}, #{dirs}"
121
+ end
122
+
123
+ dirs.each do |dir|
124
+ if ENV['DEBUG']=='1'
125
+ puts "Setting access for #{bundle_id} for permission #{setting_name} to allow: #{allow}"
126
+ end
127
+ path_to_tcc_db = tcc_database_for_sdk_dir(dir)
128
+ unless File.exist?(path_to_tcc_db)
129
+ puts "Warning: No TCC.db in location #{path_to_tcc_db}"
130
+ next
131
+ end
132
+ allowed_as_i = allow ? 1 : 0
133
+ if privacy_setting(dir, bundle_id,setting_name).nil?
134
+ sql = %Q['INSERT INTO access (service, client, client_type, allowed, prompt_count) VALUES ("#{setting_name}","#{bundle_id}",0,#{allowed_as_i},1);']
135
+ else
136
+ sql = %Q['UPDATE access SET allowed=#{allowed_as_i} where client="#{bundle_id}" AND service="#{setting_name}";']
137
+ end
138
+
139
+ if ENV['DEBUG']=='1'
140
+ puts "Executing sql #{sql} on #{path_to_tcc_db}"
141
+ end
85
142
 
86
- sandbox = File.dirname(bundle)
87
- ['Library', 'Documents', 'tmp'].each do |dir|
88
- FileUtils.rm_rf(File.join(sandbox, dir))
143
+ unless system(%Q[sqlite3 "#{path_to_tcc_db}" #{sql}]) && privacy_setting(dir,bundle_id,setting_name) == allowed_as_i
144
+ puts "Warning: Error executing sql: #{sql} against #{path_to_tcc_db} (Setting is #{privacy_setting(dir,bundle_id,setting_name)}). Continuing..."
145
+ next
146
+ end
147
+ end
89
148
  end
149
+
150
+ end
151
+
152
+ def tcc_database_for_sdk_dir(dir)
153
+ File.join(dir,'Library', 'TCC', 'TCC.db')
154
+ end
155
+
156
+ def privacy_setting(sdk_dir, bundle_id, setting_name)
157
+ setting_name = KNOWN_PRIVACY_SETTINGS[setting_name] || setting_name
158
+ path_to_tcc_db = tcc_database_for_sdk_dir(sdk_dir)
159
+ sql = %Q['SELECT allowed FROM access WHERE client="#{bundle_id}" and service="#{setting_name}";']
160
+ output = `sqlite3 "#{path_to_tcc_db}" #{sql}`.strip
161
+
162
+ (output == '0' || output == '1') ? output.to_i : nil
90
163
  end
91
164
 
92
165
  def default_launch_args
@@ -127,7 +200,6 @@ class Calabash::Cucumber::Launcher
127
200
  args[:device_target] = 'simulator'
128
201
  end
129
202
 
130
-
131
203
  args
132
204
  end
133
205
 
@@ -196,6 +268,16 @@ class Calabash::Cucumber::Launcher
196
268
 
197
269
  reset_app_jail if args[:reset]
198
270
 
271
+
272
+ if args[:privacy_settings]
273
+ if args[:device_target]=='simulator'
274
+ update_privacy_settings(args[:bundle_id], args[:privacy_settings])
275
+ else
276
+ #Not supported on device
277
+ puts 'Warning: :privacy_settings not supported on device'
278
+ end
279
+ end
280
+
199
281
  if run_with_instruments?(args)
200
282
  self.run_loop = new_run_loop(args)
201
283
  else
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = '0.9.163.pre4'
3
+ VERSION = '0.9.163.pre5'
4
4
  FRAMEWORK_VERSION = '0.9.163.pre3'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.163.pre4
4
+ version: 0.9.163.pre5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-04 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - ~>
158
158
  - !ruby/object:Gem::Version
159
- version: 0.1.0.pre1
159
+ version: 0.1.0.pre3
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
- version: 0.1.0.pre1
166
+ version: 0.1.0.pre3
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: awesome_print
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -358,10 +358,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
358
  version: 1.3.1
359
359
  requirements: []
360
360
  rubyforge_project:
361
- rubygems_version: 2.0.2
361
+ rubygems_version: 2.0.3
362
362
  signing_key:
363
363
  specification_version: 4
364
364
  summary: Client for calabash-ios-server for automated functional testing on iOS
365
365
  test_files:
366
366
  - features/step_definitions/calabash_steps.rb
367
- has_rdoc: