|
231 | 231 | end
|
232 | 232 | end
|
233 | 233 |
|
234 |
| - describe 'simulator files' do |
235 |
| - let (:physical) { RunLoop::Device.new('name', |
236 |
| - '7.1.2', |
237 |
| - '30c4b52a41d0f6c64a44bd01ff2966f03105de1e') } |
238 |
| - let (:simulator) { RunLoop::Device.new('iPhone 5s', |
239 |
| - '7.1.2', |
240 |
| - '77DA3AC3-EB3E-4B24-B899-4A20E315C318', 'Shutdown') } |
241 |
| - describe '#simulator_root_dir' do |
242 |
| - it 'is nil if physical device' do |
243 |
| - expect(physical.simulator_root_dir).to be_falsey |
| 234 | + context "simulator files" do |
| 235 | + let(:physical) do |
| 236 | + RunLoop::Device.new("name", "7.1.2", |
| 237 | + "30c4b52a41d0f6c64a44bd01ff2966f03105de1e") |
| 238 | + end |
| 239 | + |
| 240 | + let (:simulator) do |
| 241 | + RunLoop::Device.new("iPhone 5s", "7.1.2", |
| 242 | + "77DA3AC3-EB3E-4B24-B899-4A20E315C318", "Shutdown") |
| 243 | + end |
| 244 | + |
| 245 | + context "#simulator_root_dir" do |
| 246 | + it "returns nil when physical device" do |
| 247 | + expect(physical.simulator_root_dir).to be == nil |
244 | 248 | end
|
245 | 249 |
|
246 |
| - it 'is non nil if a simulator' do |
247 |
| - expect(simulator.simulator_root_dir[/#{simulator.udid}/,0]).to be_truthy |
| 250 | + it "returns path to Library/Developer/CoreSimulator/<UDID>" do |
| 251 | + expect(simulator.simulator_root_dir[/#{simulator.udid}/]).to be_truthy |
248 | 252 | end
|
249 | 253 | end
|
250 | 254 |
|
251 |
| - describe '#simulator_accessibility_plist_path' do |
252 |
| - it 'is nil if physical device' do |
253 |
| - expect(physical.simulator_accessibility_plist_path).to be_falsey |
| 255 | + context "#simulator_log_file_path" do |
| 256 | + it "returns nil when physical device" do |
| 257 | + expect(physical.simulator_log_file_path).to be == nil |
254 | 258 | end
|
255 | 259 |
|
256 |
| - it 'is non nil if a simulator' do |
257 |
| - expect(simulator.simulator_accessibility_plist_path[/#{simulator.udid}/,0]).to be_truthy |
258 |
| - expect(simulator.simulator_accessibility_plist_path[/com.apple.Accessibility.plist/,0]).to be_truthy |
| 260 | + it "returns path to Library/Logs/CoreSimulator/<UDID>/system.log" do |
| 261 | + actual = simulator.simulator_log_file_path |
| 262 | + expect(actual[/#{simulator.udid}/]).to be_truthy |
| 263 | + expect(actual[/system.log/]).to be_truthy |
259 | 264 | end
|
260 | 265 | end
|
261 | 266 |
|
262 |
| - describe "#simulator_preferences_plist_path" do |
263 |
| - it "returns nil if physical device" do |
264 |
| - expect(physical.simulator_preferences_plist_path).to be_falsey |
| 267 | + context "simulator plists" do |
| 268 | + let(:root_dir) do |
| 269 | + File.join(Resources.shared.local_tmp_dir, "CoreSimulator", "Devices", |
| 270 | + simulator.udid) |
265 | 271 | end
|
266 | 272 |
|
267 |
| - context "simulator" do |
268 |
| - let(:root_dir) { File.join(Resources.shared.local_tmp_dir) } |
269 |
| - let(:directory) { File.join(root_dir, "data", "Library", "Preferences") } |
270 |
| - let(:plist) { File.join(directory, "com.apple.Preferences.plist") } |
271 |
| - let(:template) { Resources.shared.plist_with_software_keyboard(true) } |
| 273 | + before do |
| 274 | + FileUtils.rm_rf(root_dir) |
| 275 | + FileUtils.mkdir_p(root_dir) |
| 276 | + end |
272 | 277 |
|
273 |
| - before do |
274 |
| - FileUtils.rm_rf(directory) |
275 |
| - FileUtils.mkdir_p(directory) |
| 278 | + context "#simulator_accessibility_plist_path" do |
| 279 | + it "returns nil when physical device" do |
| 280 | + expect(physical.simulator_accessibility_plist_path).to be == nil |
| 281 | + end |
| 282 | + |
| 283 | + it "returns path to Accessibility.plist when device is a simulator" do |
276 | 284 | expect(simulator).to receive(:simulator_root_dir).and_return(root_dir)
|
| 285 | + |
| 286 | + actual = simulator.simulator_accessibility_plist_path |
| 287 | + |
| 288 | + expect(actual[/com.apple.Accessibility.plist/]).to be_truthy |
277 | 289 | end
|
| 290 | + end |
278 | 291 |
|
279 |
| - it "returns path to plist" do |
280 |
| - FileUtils.cp(template, plist) |
281 |
| - expect(simulator.simulator_preferences_plist_path).to be == plist |
| 292 | + context "#simulator_preferences_plist_path" do |
| 293 | + it "returns nil if physical device" do |
| 294 | + expect(physical.simulator_preferences_plist_path).to be == nil |
282 | 295 | end
|
283 | 296 |
|
284 |
| - it "returns path to plist; creates file if necessary" do |
285 |
| - expect(File.exist?(plist)).to be_falsey |
286 |
| - expect(simulator.simulator_preferences_plist_path).to be == plist |
287 |
| - expect(File.exist?(plist)).to be_truthy |
| 297 | + it "returns path to Preference.plist when device is a simulator" do |
| 298 | + expect(simulator).to receive(:simulator_root_dir).and_return(root_dir) |
| 299 | + |
| 300 | + actual = simulator.simulator_preferences_plist_path |
| 301 | + |
| 302 | + expect(actual[/com.apple.Preferences.plist/]).to be_truthy |
288 | 303 | end
|
289 | 304 | end
|
290 |
| - end |
291 | 305 |
|
292 |
| - describe '#simulator_log_file_path' do |
293 |
| - it 'is nil if physical device' do |
294 |
| - expect(physical.simulator_log_file_path).to be_falsey |
295 |
| - end |
| 306 | + context "#simulator_device_plist" do |
| 307 | + it "returns nil physical device" do |
| 308 | + expect(physical.simulator_device_plist).to be == nil |
| 309 | + end |
296 | 310 |
|
297 |
| - it 'is non nil if a simulator' do |
298 |
| - expect(simulator.simulator_log_file_path[/#{simulator.udid}/,0]).to be_truthy |
299 |
| - expect(simulator.simulator_log_file_path[/system.log/,0]).to be_truthy |
300 |
| - end |
301 |
| - end |
| 311 | + it "returns path to device.plist when device is a simulator" do |
| 312 | + expect(simulator).to receive(:simulator_root_dir).and_return(root_dir) |
302 | 313 |
|
303 |
| - describe '#simulator_device_plist' do |
304 |
| - it 'is nil if a physical device' do |
305 |
| - expect(physical.simulator_device_plist).to be_falsey |
| 314 | + actual = simulator.simulator_device_plist |
| 315 | + expect(actual[/device.plist/]).to be_truthy |
| 316 | + end |
306 | 317 | end
|
307 | 318 |
|
308 |
| - it 'is non-nil for simulators' do |
309 |
| - actual = simulator.simulator_device_plist |
310 |
| - expect(actual[/#{simulator.udid}\/device.plist/, 0]).to be_truthy |
| 319 | + context "#simulator_global_preferences_path" do |
| 320 | + it "returns nil for physical devices" do |
| 321 | + expect(physical.simulator_global_preferences_path).to be == nil |
| 322 | + end |
| 323 | + |
| 324 | + it "returns path to the .GlobalPreferences.plist when simulator" do |
| 325 | + expect(simulator).to receive(:simulator_root_dir).and_return(root_dir) |
| 326 | + |
| 327 | + actual = simulator.simulator_global_preferences_path |
| 328 | + |
| 329 | + expect(actual[/.GlobalPreferences.plist/]).to be_truthy |
| 330 | + end |
311 | 331 | end
|
312 | 332 | end
|
313 | 333 |
|
|
340 | 360 | expect(actual).to be_truthy
|
341 | 361 | end
|
342 | 362 | end
|
343 |
| - |
344 |
| - describe "#simulator_global_preferences_path" do |
345 |
| - it "returns nil for physical devices" do |
346 |
| - expect(physical.simulator_global_preferences_path).to be_falsey |
347 |
| - end |
348 |
| - |
349 |
| - it "raises an error after waiting for the plist to exist" do |
350 |
| - path = File.join(simulator.simulator_root_dir, |
351 |
| - "data/Library/Preferences/.GlobalPreferences.plist") |
352 |
| - expect(File).to receive(:exist?).with(path).at_least(:twice).and_return(false) |
353 |
| - |
354 |
| - expect do |
355 |
| - simulator.simulator_global_preferences_path(0.05) |
356 |
| - end.to raise_error(RuntimeError, |
357 |
| - /Timed out waiting for .GlobalPreferences.plist/) |
358 |
| - end |
359 |
| - |
360 |
| - it "returns the path to the global plist" do |
361 |
| - simulator = Resources.shared.default_simulator |
362 |
| - |
363 |
| - actual = simulator.simulator_global_preferences_path |
364 |
| - |
365 |
| - expect(actual[/.GlobalPreferences.plist/]).to be_truthy |
366 |
| - expect(actual[/#{simulator.udid}/]).to be_truthy |
367 |
| - expect(File.exist?(actual)).to be_truthy |
368 |
| - end |
369 |
| - end |
370 | 363 | end
|
371 | 364 |
|
372 | 365 | describe "#simulator_languages" do
|
|
0 commit comments