Summary:
This stack takes care of handling care of moving all device interactions over the (possible) async channel FlipperServer. The FlipperServer interface (see previous diff) allows listening to specific server events using `on`, and emit commands to be executed by the server by using `exec` (e.g. `exec('take-screenshot', serial) => Promise<buffer>`).
FlipperServerImpl implements this interface on the server side.
The device implementations are split as follows
```
server / backend process:
ServerDevice
- iOSDevice
- AndroidDevice
- MetroDevice
- DummyDevice
- Mac/Windows Device
frontend / ui:
BaseDevice: a normal connected, device, implements device apis as they already existed
- ArchivedDevice (note that this doesn't have a server counterpart)
- TestDevice (for unit tests, with stubbed backend communication)
```
All features of devices are for simplicity unified (since the deviations are small), where specific device types might not implement certain features like taking screenshots or running shell commands.
To avoid making this diff unnecessarily big, some open Todo's will be addressed later in this stack, and it shouldn't be landed alone.
Reviewed By: timur-valiev
Differential Revision: D30909346
fbshipit-source-id: cce0bee94fdd5db59bebe3577a6084219a038719
39 lines
764 B
TypeScript
39 lines
764 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {DeviceOS, DeviceType} from 'flipper-plugin';
|
|
import {DeviceSpec} from 'flipper-plugin-lib';
|
|
import BaseDevice from '../devices/BaseDevice';
|
|
|
|
export class TestDevice extends BaseDevice {
|
|
constructor(
|
|
serial: string,
|
|
deviceType: DeviceType,
|
|
title: string,
|
|
os: DeviceOS,
|
|
specs?: DeviceSpec[],
|
|
) {
|
|
super(
|
|
{
|
|
on: jest.fn(),
|
|
off: jest.fn(),
|
|
exec: jest.fn(),
|
|
close: jest.fn(),
|
|
},
|
|
{
|
|
serial,
|
|
deviceType,
|
|
title,
|
|
os,
|
|
specs,
|
|
},
|
|
);
|
|
}
|
|
}
|