Separate device in server and client version [2/n]

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
This commit is contained in:
Michel Weststrate
2021-09-22 09:01:29 -07:00
committed by Facebook GitHub Bot
parent 845d0755f1
commit 2d838efd4d
58 changed files with 869 additions and 396 deletions

View File

@@ -7,7 +7,7 @@
* @format
*/
import {BaseDevice} from 'flipper';
import {TestDevice} from 'flipper';
import {Crash, CrashLog} from '../index';
import {TestUtils} from 'flipper-plugin';
import {getPluginKey} from 'flipper';
@@ -121,7 +121,7 @@ test('test the parsing of the Android crash log with os being iOS', () => {
expect(crash.name).toEqual('Cannot figure out the cause');
});
test('test the getter of pluginKey with proper input', () => {
const device = new BaseDevice('serial', 'emulator', 'test device', 'iOS');
const device = new TestDevice('serial', 'emulator', 'test device', 'iOS');
const pluginKey = getPluginKey(null, device, 'CrashReporter');
expect(pluginKey).toEqual('serial#CrashReporter');
});
@@ -134,7 +134,7 @@ test('test the getter of pluginKey with defined selected app', () => {
expect(pluginKey).toEqual('selectedApp#CrashReporter');
});
test('test the getter of pluginKey with defined selected app and defined base device', () => {
const device = new BaseDevice('serial', 'emulator', 'test device', 'iOS');
const device = new TestDevice('serial', 'emulator', 'test device', 'iOS');
const pluginKey = getPluginKey('selectedApp', device, 'CrashReporter');
expect(pluginKey).toEqual('selectedApp#CrashReporter');
});
@@ -216,7 +216,7 @@ test('test parsing of path when a regex is not present', () => {
});
test('test shouldShowCrashNotification function for all correct inputs', () => {
const device = new BaseDevice(
const device = new TestDevice(
'TH1S-15DEV1CE-1D',
'emulator',
'test device',
@@ -231,7 +231,7 @@ test('test shouldShowCrashNotification function for all correct inputs', () => {
expect(shouldShowNotification).toEqual(true);
});
test('test shouldShowiOSCrashNotification function for all correct inputs but incorrect id', () => {
const device = new BaseDevice(
const device = new TestDevice(
'TH1S-15DEV1CE-1D',
'emulator',
'test device',