Improve device destruction code [8/n]

Summary: Some cleanup in device destruction code. This diff wraps up the stack that decouples device management from the UI. Next steps are client management, and system management (file access / command execution)

Reviewed By: passy

Differential Revision: D31084036

fbshipit-source-id: 93efee7dba2193589d3c08c51128ce03de5eff7f
This commit is contained in:
Michel Weststrate
2021-09-27 02:11:40 -07:00
committed by Facebook GitHub Bot
parent dce92b16db
commit 987755bb09
4 changed files with 30 additions and 15 deletions

View File

@@ -14,7 +14,6 @@ import {
createState,
DevicePluginClient,
PluginClient,
sleep,
} from 'flipper-plugin';
import {handleClientConnected} from '../dispatcher/flipperServer';
import {TestDevice} from '../test-utils/TestDevice';
@@ -106,6 +105,13 @@ test('New device with same serial removes & cleans the old one', async () => {
'MockAndroidDevice',
'Android',
);
expect(() => {
store.dispatch({
type: 'REGISTER_DEVICE',
payload: device2,
});
}).toThrow('still connected');
device.destroy();
store.dispatch({
type: 'REGISTER_DEVICE',
payload: device2,
@@ -115,7 +121,6 @@ test('New device with same serial removes & cleans the old one', async () => {
store.getState().connections.enabledDevicePlugins,
);
await sleep(100);
expect(device.isArchived).toBe(false);
expect(device.connected.get()).toBe(false);
expect(instance.instanceApi.destroy).toBeCalledTimes(1);