Preserve device state after disconnect
Summary: This diff stack introduces support for keeping devices and clients around after they have disconnected. This is a pretty important debugging improvement, that will allow inspecting a device / app after it crashed for example. This feature existed partially before, but only supported Android, and only support plugins with persisted state; as it replace the current device with an archived version of the same device. In practice this didn't work really well, as most plugins would not be available, and all non-persisted state would be lost. This diff makes sure we can keep devices around after disconnecting, the next one will keep the clients around as well. And explain some code choices in more detail. Note that `Device.isArchived` was an overloaded term before, and even more now (both representing imported and disconnected devices), will address that in a later diff. https://github.com/facebook/flipper/issues/1460 https://github.com/facebook/flipper/issues/812 https://github.com/facebook/flipper/issues/1487 Changelog: iOS and Android devices will preserve their state after being disconnected Reviewed By: nikoant Differential Revision: D26224310 fbshipit-source-id: 7dfc93c2a109a51c2880ec212a00463bc8d32041
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7361ecc080
commit
c43049d881
@@ -21,7 +21,7 @@ import {FlipperPlugin, FlipperDevicePlugin} from '../../plugin';
|
||||
import {Notification} from '../../plugin';
|
||||
import {default as Client, ClientExport} from '../../Client';
|
||||
import {State as PluginsState} from '../../reducers/plugins';
|
||||
import {renderMockFlipperWithPlugin} from '../../test-utils/createMockFlipperWithPlugin';
|
||||
import {createMockFlipperWithPlugin} from '../../test-utils/createMockFlipperWithPlugin';
|
||||
import {
|
||||
TestUtils,
|
||||
_SandyPluginDefinition,
|
||||
@@ -1116,7 +1116,7 @@ const sandyTestPlugin = new _SandyPluginDefinition(
|
||||
);
|
||||
|
||||
test('Sandy plugins are exported properly', async () => {
|
||||
const {client, sendMessage, store} = await renderMockFlipperWithPlugin(
|
||||
const {client, sendMessage, store} = await createMockFlipperWithPlugin(
|
||||
sandyTestPlugin,
|
||||
);
|
||||
|
||||
@@ -1145,7 +1145,7 @@ test('Sandy plugins are exported properly', async () => {
|
||||
});
|
||||
|
||||
test('Sandy plugins with custom export are exported properly', async () => {
|
||||
const {client, sendMessage, store} = await renderMockFlipperWithPlugin(
|
||||
const {client, sendMessage, store} = await createMockFlipperWithPlugin(
|
||||
sandyTestPlugin,
|
||||
);
|
||||
|
||||
@@ -1218,7 +1218,7 @@ test('Sandy plugins are imported properly', async () => {
|
||||
},
|
||||
};
|
||||
|
||||
const {client, store} = await renderMockFlipperWithPlugin(sandyTestPlugin);
|
||||
const {client, store} = await createMockFlipperWithPlugin(sandyTestPlugin);
|
||||
|
||||
await importDataToStore('unittest.json', JSON.stringify(data), store);
|
||||
|
||||
@@ -1312,7 +1312,7 @@ test('Sandy device plugins are exported / imported properly', async () => {
|
||||
},
|
||||
};
|
||||
|
||||
const {device, store} = await renderMockFlipperWithPlugin(
|
||||
const {device, store} = await createMockFlipperWithPlugin(
|
||||
sandyDeviceTestPlugin,
|
||||
);
|
||||
|
||||
@@ -1350,7 +1350,7 @@ test('Sandy device plugins are exported / imported properly', async () => {
|
||||
});
|
||||
|
||||
test('Sandy device plugins with custom export are export properly', async () => {
|
||||
const {device, store} = await renderMockFlipperWithPlugin(
|
||||
const {device, store} = await createMockFlipperWithPlugin(
|
||||
sandyDeviceTestPlugin,
|
||||
);
|
||||
|
||||
@@ -1384,7 +1384,7 @@ test('Sandy plugin with custom import', async () => {
|
||||
},
|
||||
);
|
||||
|
||||
const {store} = await renderMockFlipperWithPlugin(plugin);
|
||||
const {store} = await createMockFlipperWithPlugin(plugin);
|
||||
|
||||
const data = {
|
||||
clients: [
|
||||
@@ -1484,7 +1484,7 @@ test('Sandy device plugin with custom import', async () => {
|
||||
},
|
||||
};
|
||||
|
||||
const {store} = await renderMockFlipperWithPlugin(plugin);
|
||||
const {store} = await createMockFlipperWithPlugin(plugin);
|
||||
|
||||
await importDataToStore('unittest.json', JSON.stringify(data), store);
|
||||
|
||||
@@ -1503,7 +1503,7 @@ test('Sandy device plugin with custom import', async () => {
|
||||
});
|
||||
|
||||
test('Sandy plugins with complex data are imported / exported correctly', async () => {
|
||||
const deviceplugin = new _SandyPluginDefinition(
|
||||
const plugin = new _SandyPluginDefinition(
|
||||
TestUtils.createMockPluginDetails(),
|
||||
{
|
||||
plugin() {
|
||||
@@ -1522,7 +1522,7 @@ test('Sandy plugins with complex data are imported / exported correctly', async
|
||||
},
|
||||
);
|
||||
|
||||
const {store} = await renderMockFlipperWithPlugin(deviceplugin);
|
||||
const {store} = await createMockFlipperWithPlugin(plugin);
|
||||
|
||||
const data = await exportStore(store);
|
||||
expect(Object.values(data.exportStoreData.pluginStates2)).toMatchObject([
|
||||
@@ -1551,7 +1551,7 @@ test('Sandy plugins with complex data are imported / exported correctly', async
|
||||
await importDataToStore('unittest.json', data.serializedString, store);
|
||||
const api = store
|
||||
.getState()
|
||||
.connections.clients[1].sandyPluginStates.get(deviceplugin.id)?.instanceApi;
|
||||
.connections.clients[1].sandyPluginStates.get(plugin.id)?.instanceApi;
|
||||
expect(api.m.get()).toMatchInlineSnapshot(`
|
||||
Map {
|
||||
"a" => 1,
|
||||
@@ -1590,7 +1590,7 @@ test('Sandy device plugins with complex data are imported / exported correctly'
|
||||
},
|
||||
);
|
||||
|
||||
const {store} = await renderMockFlipperWithPlugin(deviceplugin);
|
||||
const {store} = await createMockFlipperWithPlugin(deviceplugin);
|
||||
|
||||
const data = await exportStore(store);
|
||||
expect(data.exportStoreData.device?.pluginStates).toMatchObject({
|
||||
|
||||
Reference in New Issue
Block a user