diff --git a/src/chrome/DevicesButton.js b/src/chrome/DevicesButton.js index 4a3209ed8..5b4c37bd4 100644 --- a/src/chrome/DevicesButton.js +++ b/src/chrome/DevicesButton.js @@ -70,14 +70,31 @@ class DevicesButton extends Component { label: 'Running devices', enabled: false, }, - ...devices.map((device: BaseDevice) => ({ - click: () => selectDevice(device), - checked: device === selectedDevice, - label: `${device.deviceType === 'physical' ? '📱 ' : ''}${ - device.title - }`, - type: 'checkbox', - })), + ...devices.map((device: BaseDevice) => { + let label = ''; + switch (device.deviceType) { + case 'emulator': + label = ''; + break; + case 'physical': + label = '📱 '; + break; + case 'archivedEmulator': + label = '📦 '; + break; + case 'archivedPhysical': + label = '📦 '; + break; + default: + label = ''; + } + return { + click: () => selectDevice(device), + checked: device === selectedDevice, + label: `${label}${device.title}`, + type: 'checkbox', + }; + }), ); } if (androidEmulators.length > 0) { @@ -91,7 +108,6 @@ class DevicesButton extends Component { label: name, click: () => this.launchEmulator(name), })); - if (emulators.length > 0) { dropdown.push( {type: 'separator'}, @@ -116,5 +132,8 @@ export default connect( androidEmulators, selectedDevice, }), - {selectDevice, preferDevice}, + { + selectDevice, + preferDevice, + }, )(DevicesButton); diff --git a/src/devices/ArchivedDevice.js b/src/devices/ArchivedDevice.js index 88155f4f5..1ae4bd47e 100644 --- a/src/devices/ArchivedDevice.js +++ b/src/devices/ArchivedDevice.js @@ -20,7 +20,13 @@ export default class ArchivedDevice extends BaseDevice { os: OS, logEntries: Array, ) { - super(serial, deviceType, title); + let archivedDeviceType = deviceType; + if (archivedDeviceType === 'emulator') { + archivedDeviceType = 'archivedEmulator'; + } else if (archivedDeviceType === 'physical') { + archivedDeviceType = 'archivedPhysical'; + } + super(serial, archivedDeviceType, title); this.os = os; this.logs = logEntries; } diff --git a/src/devices/BaseDevice.js b/src/devices/BaseDevice.js index f3ccbb1e3..0307d19ac 100644 --- a/src/devices/BaseDevice.js +++ b/src/devices/BaseDevice.js @@ -34,7 +34,11 @@ export type DeviceShell = { export type DeviceLogListener = (entry: DeviceLogEntry) => void; -export type DeviceType = 'emulator' | 'physical'; +export type DeviceType = + | 'emulator' + | 'physical' + | 'archivedEmulator' + | 'archivedPhysical'; export type DeviceExport = {| os: string, diff --git a/src/fb-stubs/iOSContainerUtility.js b/src/fb-stubs/iOSContainerUtility.js index 832ff9c7c..82b334f2d 100644 --- a/src/fb-stubs/iOSContainerUtility.js +++ b/src/fb-stubs/iOSContainerUtility.js @@ -5,13 +5,14 @@ * @format */ import {promisify} from 'util'; +import type {DeviceType} from '../devices/BaseDevice'; const exec = promisify(require('child_process').exec); const errorMessage = 'Physical iOS devices not yet supported'; export type DeviceTarget = { udid: string, - type: 'physical' | 'emulator', + type: DeviceType, name: string, }; diff --git a/src/utils/__tests__/exportData.electron.js b/src/utils/__tests__/exportData.electron.js index f6e9a9e90..869a36688 100644 --- a/src/utils/__tests__/exportData.electron.js +++ b/src/utils/__tests__/exportData.electron.js @@ -73,8 +73,8 @@ test('test generateClientIndentifierWithSalt helper function', () => { ); const identifier = generateClientIdentifier(device, 'app'); const saltIdentifier = generateClientIdentifierWithSalt(identifier, 'salt'); - expect(saltIdentifier).toEqual('app#iOS#emulator#salt-serial'); - expect(identifier).toEqual('app#iOS#emulator#serial'); + expect(saltIdentifier).toEqual('app#iOS#archivedEmulator#salt-serial'); + expect(identifier).toEqual('app#iOS#archivedEmulator#serial'); }); test('test generateClientFromClientWithSalt helper function', () => { @@ -88,20 +88,20 @@ test('test generateClientFromClientWithSalt helper function', () => { const client = generateClientFromDevice(device, 'app'); const saltedClient = generateClientFromClientWithSalt(client, 'salt'); expect(saltedClient).toEqual({ - id: 'app#iOS#emulator#salt-serial', + id: 'app#iOS#archivedEmulator#salt-serial', query: { app: 'app', os: 'iOS', - device: 'emulator', + device: 'archivedEmulator', device_id: 'salt-serial', }, }); expect(client).toEqual({ - id: 'app#iOS#emulator#serial', + id: 'app#iOS#archivedEmulator#serial', query: { app: 'app', os: 'iOS', - device: 'emulator', + device: 'archivedEmulator', device_id: 'serial', }, }); @@ -117,11 +117,11 @@ test('test generateClientFromDevice helper function', () => { ); const client = generateClientFromDevice(device, 'app'); expect(client).toEqual({ - id: 'app#iOS#emulator#serial', + id: 'app#iOS#archivedEmulator#serial', query: { app: 'app', os: 'iOS', - device: 'emulator', + device: 'archivedEmulator', device_id: 'serial', }, }); @@ -136,7 +136,7 @@ test('test generateClientIdentifier helper function', () => { [], ); const identifier = generateClientIdentifier(device, 'app'); - expect(identifier).toEqual('app#iOS#emulator#serial'); + expect(identifier).toEqual('app#iOS#archivedEmulator#serial'); }); test('test generateNotifications helper function', () => { @@ -171,7 +171,7 @@ test('test processStore function for an iOS device connected', () => { //$FlowFixMe Flow doesn't that its a test and the assertion for null is already done const {serial, deviceType, title, os} = device; expect(serial).toEqual('salt-serial'); - expect(deviceType).toEqual('emulator'); + expect(deviceType).toEqual('archivedEmulator'); expect(title).toEqual('TestiPhone'); expect(os).toEqual('iOS'); //$FlowFixMe Flow doesn't that its a test and the assertion for null is already done