simctl 1.6.7 → 1.6.8

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
  SHA256:
3
- metadata.gz: f9e9a83d7edd52e86d76568513d830437266845ea90eb8ecea4a709ad0deea6d
4
- data.tar.gz: 7f0b6f86ad29a264d7a95950ab63789a454673328c127ad3b8595f02ff46c911
3
+ metadata.gz: e3fa7188b00a37eb0401b6ca306d139fc781eebe63423bec0668177b8ba240bd
4
+ data.tar.gz: d5228eb5e09fc2e374808d634387d8bd1137ae6ad4d1802ac9d99fe2560de4de
5
5
  SHA512:
6
- metadata.gz: a21a7c730e4e166b4c3e607015d204296167d0534c2dbf06becc2dc7a2895fc1be80c789f2e3424be2a8569d1524b572d37f7827aa53660d9657bb2cd9477997
7
- data.tar.gz: b55a02c3f3666316a1382358f7a83be30675c45aa08dd3e38da27ec01da00a6835d3f5e2eb1c6110c5772143601ffc7c73afa8e3bb3b8512f90965256230ce86
6
+ metadata.gz: e64ac086748ecf6d73da5594e2c4946984c7346f2e64d390c26451389b494a8477c00bb9bd37a2e9fbbdaf744ab8dec8ebe9ee6db28570bd707f633bfc18d60f
7
+ data.tar.gz: 1d5b51b55f031240b96649a7042b5d16d9120e9ca8c6731d04bb44f5f361dd208d79c8c4dcb21f507cff43cac4eecdfdabc8a15dee59fe937ce938ebbca17b32
@@ -8,10 +8,10 @@ matrix:
8
8
  osx_image: xcode10.3
9
9
  env: CUSTOM_DEVICE_SET_PATH=false
10
10
  - os: osx
11
- osx_image: xcode11.2
11
+ osx_image: xcode11.3
12
12
  env: CUSTOM_DEVICE_SET_PATH=true
13
13
  - os: osx
14
- osx_image: xcode11.2
14
+ osx_image: xcode11.3
15
15
  env: CUSTOM_DEVICE_SET_PATH=false
16
16
  before_script:
17
17
  - export LANG=en_US.UTF-8
@@ -1,3 +1,11 @@
1
+ # 1.6.8
2
+
3
+ * Add `upgrade` command
4
+ * Add `status_bar_clear` command (requires Xcode 11.4 or newer)
5
+ * Add `status_bar_override` command (requires Xcode 11.4 or newer)
6
+ * Add `privacy` command (requires Xcode 11.4 or newer)
7
+ * Add `push` command (requires Xcode 11.4 or newer)
8
+
1
9
  # 1.6.7
2
10
 
3
11
  * Turn off sliding hint on keyboard
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simctl (1.6.7)
4
+ simctl (1.6.8)
5
5
  CFPropertyList
6
6
  naturally
7
7
 
@@ -18,6 +18,9 @@ GEM
18
18
  tins (~> 1.6)
19
19
  diff-lcs (1.3)
20
20
  docile (1.3.2)
21
+ io-console (0.5.5)
22
+ irb (1.2.1)
23
+ reline (>= 0.0.1)
21
24
  json (2.2.0)
22
25
  naturally (2.2.0)
23
26
  parallel (1.17.0)
@@ -27,6 +30,8 @@ GEM
27
30
  rainbow (2.2.2)
28
31
  rake
29
32
  rake (12.3.3)
33
+ reline (0.1.2)
34
+ io-console (~> 0.5)
30
35
  rspec (3.8.0)
31
36
  rspec-core (~> 3.8.0)
32
37
  rspec-expectations (~> 3.8.0)
@@ -64,6 +69,7 @@ PLATFORMS
64
69
 
65
70
  DEPENDENCIES
66
71
  coveralls
72
+ irb
67
73
  rake
68
74
  rspec
69
75
  rubocop (= 0.49.1)
@@ -6,14 +6,18 @@ require 'simctl/command/install'
6
6
  require 'simctl/command/io'
7
7
  require 'simctl/command/kill'
8
8
  require 'simctl/command/launch'
9
+ require 'simctl/command/privacy'
9
10
  require 'simctl/command/terminate'
10
11
  require 'simctl/command/list'
11
12
  require 'simctl/command/openurl'
13
+ require 'simctl/command/push'
12
14
  require 'simctl/command/rename'
13
15
  require 'simctl/command/reset'
14
16
  require 'simctl/command/shutdown'
15
17
  require 'simctl/command/spawn'
18
+ require 'simctl/command/status_bar'
16
19
  require 'simctl/command/uninstall'
20
+ require 'simctl/command/upgrade'
17
21
  require 'simctl/command/warmup'
18
22
  require 'simctl/executor'
19
23
  require 'shellwords'
@@ -30,14 +34,18 @@ module SimCtl
30
34
  include SimCtl::Command::Install
31
35
  include SimCtl::Command::Kill
32
36
  include SimCtl::Command::Launch
33
- include SimCtl::Command::Terminate
34
37
  include SimCtl::Command::List
35
38
  include SimCtl::Command::OpenUrl
39
+ include SimCtl::Command::Privacy
40
+ include SimCtl::Command::Push
36
41
  include SimCtl::Command::Rename
37
42
  include SimCtl::Command::Reset
38
43
  include SimCtl::Command::Shutdown
39
44
  include SimCtl::Command::Spawn
45
+ include SimCtl::Command::StatusBar
46
+ include SimCtl::Command::Terminate
40
47
  include SimCtl::Command::Uninstall
48
+ include SimCtl::Command::Upgrade
41
49
  include SimCtl::Command::Warmup
42
50
 
43
51
  def device_set_path=(device_set_path)
@@ -0,0 +1,21 @@
1
+ module SimCtl
2
+ class Command
3
+ module Privacy
4
+ # Change privacy settings
5
+ #
6
+ # @param device [SimCtl::Device] the device
7
+ # @param action [String] grant, revoke, reset
8
+ # @param service [String] all, calendar, contacts-limited, contacts, location,
9
+ # location-always, photos-add, photos, media-library, microphone,
10
+ # motion, reminders, siri
11
+ # @param bundle [String] bundle identifier
12
+ # @return [void]
13
+ def privacy(device, action, service, bundle)
14
+ unless Xcode::Version.gte? '11.4'
15
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
16
+ end
17
+ Executor.execute(command_for('privacy', device.udid, action, service, bundle))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+ require 'tempfile'
4
+
5
+ module SimCtl
6
+ class Command
7
+ module Push
8
+ # Send some push notification
9
+ #
10
+ # @param device [SimCtl::Device] the device
11
+ # @param bundle [String] bundle identifier
12
+ # @param payload the JSON payload. This can be a JSON [String], some [Hash] or
13
+ # just a [String] path to a local file containing a JSON payload
14
+ # @return [void]
15
+ def push(device, bundle, payload)
16
+ unless Xcode::Version.gte? '11.4'
17
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
18
+ end
19
+
20
+ file = Tempfile.new('push')
21
+
22
+ if payload.is_a?(Hash)
23
+ JSON.dump payload, file
24
+ file.close
25
+ elsif payload.is_a?(String) && File.exist?(payload)
26
+ file.close
27
+ FileUtils.cp payload, file.path
28
+ else
29
+ file.write payload
30
+ file.close
31
+ end
32
+
33
+ Executor.execute(command_for('push', device.udid, bundle, file.path))
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,52 @@
1
+ require 'ostruct'
2
+
3
+ module SimCtl
4
+ class Command
5
+ module StatusBar
6
+ # Clear all status bar overrides
7
+ #
8
+ # @param device [SimCtl::Device] the device
9
+ # @return [void]
10
+ def status_bar_clear(device)
11
+ unless Xcode::Version.gte? '11.4'
12
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
13
+ end
14
+ Executor.execute(command_for('status_bar', device.udid, 'clear'))
15
+ end
16
+
17
+ # Set some status bar overrides
18
+ #
19
+ # Refer to `xcrun simctl status_bar` for available options.
20
+ #
21
+ # Example:
22
+ #
23
+ # SimCtl.status_bar_override device, {
24
+ # time: '9:41',
25
+ # dataNetwork: 'lte+',
26
+ # wifiMode: 'active',
27
+ # cellularMode: 'active',
28
+ # batteryState: 'charging',
29
+ # batteryLevel: 50
30
+ # }
31
+ #
32
+ # @param device [SimCtl::Device] the device
33
+ # @param overrides [SimCtl::StatusBarOverrides] or [Hash] the overrides to apply
34
+ # @return [void]
35
+ def status_bar_override(device, overrides)
36
+ unless Xcode::Version.gte? '11.4'
37
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
38
+ end
39
+ overrides = SimCtl::StatusBarOverrides.new overrides unless overrides.is_a?(SimCtl::StatusBarOverrides)
40
+ Executor.execute(command_for('status_bar', device.udid, 'override', *overrides.to_args))
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ module SimCtl
47
+ class StatusBarOverrides < OpenStruct
48
+ def to_args
49
+ to_h.map { |k, v| ["--#{k}", v] }.flatten
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ module SimCtl
2
+ class Command
3
+ module Upgrade
4
+ # Upgrade a device to a newer runtime
5
+ #
6
+ # @param device [SimCtl::Device] the device the upgrade should be performed for
7
+ # @param runtime [SimCtl::Runtime] the runtime the device should be upgrade to
8
+ # @return [void]
9
+ def upgrade(device, runtime)
10
+ Executor.execute(command_for('upgrade', device.udid, runtime.identifier))
11
+ end
12
+ end
13
+ end
14
+ end
@@ -4,6 +4,7 @@ require 'simctl/device_launchctl'
4
4
  require 'simctl/device_path'
5
5
  require 'simctl/device_settings'
6
6
  require 'simctl/object'
7
+ require 'simctl/status_bar'
7
8
  require 'timeout'
8
9
 
9
10
  module SimCtl
@@ -125,6 +126,18 @@ module SimCtl
125
126
  @path ||= DevicePath.new(self)
126
127
  end
127
128
 
129
+ # Change privacy settings
130
+ #
131
+ # @param action [String] grant, revoke, reset
132
+ # @param service [String] all, calendar, contacts-limited, contacts, location,
133
+ # location-always, photos-add, photos, media-library, microphone,
134
+ # motion, reminders, siri
135
+ # @param bundle [String] bundle identifier
136
+ # @return [void]
137
+ def privacy(action, service, bundle)
138
+ SimCtl.privacy(self, action, service, bundle)
139
+ end
140
+
128
141
  # Returns true/false if the device is ready
129
142
  # Uses [SimCtl::DeviceLaunchctl] to look for certain services being running.
130
143
  #
@@ -162,7 +175,7 @@ module SimCtl
162
175
  SimCtl.reset_device name, devicetype, runtime
163
176
  end
164
177
 
165
- # Resets the runtime
178
+ # Returns the runtime object
166
179
  #
167
180
  # @return [SimCtl::Runtime]
168
181
  def runtime
@@ -210,6 +223,13 @@ module SimCtl
210
223
  @state.downcase.to_sym
211
224
  end
212
225
 
226
+ # Returns the status bar object
227
+ #
228
+ # @return [SimCtl::StatusBar]
229
+ def status_bar
230
+ @status_bar ||= SimCtl::StatusBar.new(self)
231
+ end
232
+
213
233
  # Reloads the device until the given block returns true
214
234
  #
215
235
  # @return [void]
@@ -0,0 +1,26 @@
1
+ module SimCtl
2
+ class StatusBar
3
+ def initialize(device)
4
+ @device = device
5
+ end
6
+
7
+ # Clear all status bar overrides
8
+ #
9
+ # @return [void]
10
+ def clear
11
+ SimCtl.status_bar_clear(device)
12
+ end
13
+
14
+ # Set some status bar overrides
15
+ #
16
+ # @param overrides [SimCtl::StatusBarOverrides] or [Hash] the overrides to apply
17
+ # @return [void]
18
+ def override(overrides)
19
+ SimCtl.status_bar_override(device, overrides)
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :device
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module SimCtl
2
- VERSION = '1.6.7'.freeze
2
+ VERSION = '1.6.8'.freeze
3
3
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
  s.add_development_dependency 'coveralls'
23
+ s.add_development_dependency 'irb'
23
24
  s.add_development_dependency 'rake'
24
25
  s.add_development_dependency 'rspec'
25
26
  s.add_development_dependency 'rubocop', '=0.49.1'
@@ -169,6 +169,41 @@ RSpec.describe SimCtl, order: :defined do
169
169
  end
170
170
  end
171
171
 
172
+ describe 'overriding status bar values' do
173
+ if SimCtl::Xcode::Version.gte?('11.4')
174
+ it 'overrides the status bar values' do
175
+ @device.status_bar.override SimCtl::StatusBarOverrides.new(
176
+ time: '10:45',
177
+ dataNetwork: 'lte+',
178
+ wifiMode: 'active',
179
+ cellularMode: 'active',
180
+ batteryState: 'charging',
181
+ batteryLevel: 50
182
+ )
183
+ end
184
+
185
+ it 'overrides the status bar values with a hash' do
186
+ @device.status_bar.override(
187
+ time: '10:45',
188
+ dataNetwork: 'lte+',
189
+ wifiMode: 'active',
190
+ cellularMode: 'active',
191
+ batteryState: 'charging',
192
+ batteryLevel: 50
193
+ )
194
+ end
195
+
196
+ it 'clears the status bar' do
197
+ @device.status_bar.clear
198
+ end
199
+ else
200
+ it 'raises exception' do
201
+ expect { @device.status_bar.clear }.to raise_error SimCtl::UnsupportedCommandError
202
+ expect { @device.status_bar.override(time: '10:45') }.to raise_error SimCtl::UnsupportedCommandError
203
+ end
204
+ end
205
+ end
206
+
172
207
  describe 'launching a system app' do
173
208
  it 'launches Safari' do
174
209
  @device.launch_app('com.apple.mobilesafari')
@@ -224,6 +259,18 @@ RSpec.describe SimCtl, order: :defined do
224
259
  end
225
260
  end
226
261
 
262
+ describe 'changing privacy settings' do
263
+ if SimCtl::Xcode::Version.gte?('11.4')
264
+ it 'resets all privacy settings' do
265
+ @device.privacy('reset', 'all', 'com.github.plu.simctl.SampleApp')
266
+ end
267
+ else
268
+ it 'raises exception' do
269
+ expect { @device.privacy('reset', 'all', 'com.github.plu.simctl.SampleApp') }.to raise_error SimCtl::UnsupportedCommandError
270
+ end
271
+ end
272
+ end
273
+
227
274
  describe 'uninstall an app' do
228
275
  it 'uninstalls SampleApp' do
229
276
  @device.uninstall('com.github.plu.simctl.SampleApp')
@@ -77,7 +77,11 @@ RSpec.describe SimCtl do
77
77
  end
78
78
 
79
79
  it 'finds the latest runtime' do
80
- if SimCtl::Xcode::Version.gte?('11.2')
80
+ if SimCtl::Xcode::Version.gte?('11.4')
81
+ expect(SimCtl::Runtime.latest(:ios).version).to be == '13.4'
82
+ elsif SimCtl::Xcode::Version.gte?('11.3')
83
+ expect(SimCtl::Runtime.latest(:ios).version).to be == '13.3'
84
+ elsif SimCtl::Xcode::Version.gte?('11.2')
81
85
  expect(SimCtl::Runtime.latest(:ios).version).to be == '13.2.2'
82
86
  elsif SimCtl::Xcode::Version.gte?('10.3')
83
87
  expect(SimCtl::Runtime.latest(:ios).version).to be == '12.4'
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SimCtl do
4
+ describe '#upgrade' do
5
+ it 'upgrades a device to a newer runtime' do
6
+ old_runtime = SimCtl.runtime(name: 'iOS 12.1')
7
+ new_runtime = SimCtl.runtime(name: 'iOS 12.4')
8
+ device = SimCtl.reset_device 'iPhone 7', SimCtl.devicetype(name: 'iPhone 7'), old_runtime
9
+ expect(device.runtime.version).to be == old_runtime.version
10
+ SimCtl.upgrade device, new_runtime
11
+ device.wait { |d| d.runtime.version == new_runtime.version }
12
+ device.delete
13
+ end
14
+ end
15
+ end
@@ -2,20 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe SimCtl do
4
4
  describe '#warmup' do
5
- if SimCtl.device_set_path.nil?
6
- it 'warms up and returns a device for given strings' do
7
- expect(SimCtl.warmup('iPhone 6', 'iOS 12.1')).to be_kind_of SimCtl::Device
8
- end
5
+ it 'warms up and returns a device for given strings' do
6
+ SimCtl.reset_device 'iPhone 6', SimCtl.devicetype(name: 'iPhone 6'), SimCtl.runtime(name: 'iOS 12.1')
7
+ expect(SimCtl.warmup('iPhone 6', 'iOS 12.1')).to be_kind_of SimCtl::Device
8
+ end
9
9
 
10
- it 'warms up and returns a device for given objects' do
11
- devicetype = SimCtl.devicetype(name: 'iPhone 6')
12
- runtime = SimCtl::Runtime.latest(:ios)
13
- expect(SimCtl.warmup(devicetype, runtime)).to be_kind_of SimCtl::Device
14
- end
15
- else
16
- it 'raises exception' do
17
- expect { SimCtl.warmup('iPhone 6', 'iOS 12.1') }.to raise_error SimCtl::DeviceNotFound
18
- end
10
+ it 'warms up and returns a device for given objects' do
11
+ devicetype = SimCtl.devicetype(name: 'iPhone 8')
12
+ runtime = SimCtl::Runtime.latest(:ios)
13
+ SimCtl.reset_device 'iPhone 8', devicetype, runtime
14
+ expect(SimCtl.warmup(devicetype, runtime)).to be_kind_of SimCtl::Device
19
15
  end
20
16
  end
21
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7
4
+ version: 1.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Plunien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: irb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -139,12 +153,16 @@ files:
139
153
  - lib/simctl/command/launch.rb
140
154
  - lib/simctl/command/list.rb
141
155
  - lib/simctl/command/openurl.rb
156
+ - lib/simctl/command/privacy.rb
157
+ - lib/simctl/command/push.rb
142
158
  - lib/simctl/command/rename.rb
143
159
  - lib/simctl/command/reset.rb
144
160
  - lib/simctl/command/shutdown.rb
145
161
  - lib/simctl/command/spawn.rb
162
+ - lib/simctl/command/status_bar.rb
146
163
  - lib/simctl/command/terminate.rb
147
164
  - lib/simctl/command/uninstall.rb
165
+ - lib/simctl/command/upgrade.rb
148
166
  - lib/simctl/command/warmup.rb
149
167
  - lib/simctl/device.rb
150
168
  - lib/simctl/device_launchctl.rb
@@ -155,6 +173,7 @@ files:
155
173
  - lib/simctl/list.rb
156
174
  - lib/simctl/object.rb
157
175
  - lib/simctl/runtime.rb
176
+ - lib/simctl/status_bar.rb
158
177
  - lib/simctl/version.rb
159
178
  - lib/simctl/xcode/path.rb
160
179
  - lib/simctl/xcode/version.rb
@@ -170,6 +189,7 @@ files:
170
189
  - spec/simctl/executor_spec.rb
171
190
  - spec/simctl/list_spec.rb
172
191
  - spec/simctl/readme_spec.rb
192
+ - spec/simctl/upgrade_spec.rb
173
193
  - spec/simctl/warmup_spec.rb
174
194
  - spec/spec_helper.rb
175
195
  homepage: https://github.com/plu/simctl
@@ -207,5 +227,6 @@ test_files:
207
227
  - spec/simctl/executor_spec.rb
208
228
  - spec/simctl/list_spec.rb
209
229
  - spec/simctl/readme_spec.rb
230
+ - spec/simctl/upgrade_spec.rb
210
231
  - spec/simctl/warmup_spec.rb
211
232
  - spec/spec_helper.rb