style(app): format the lifecycle and settings tests
This commit is contained in:
@@ -56,10 +56,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('only a dropped socket is reopened on foreground', () {
|
||||
expect(
|
||||
shouldReconnectOnForeground(ConnectionKind.disconnected),
|
||||
isTrue,
|
||||
);
|
||||
expect(shouldReconnectOnForeground(ConnectionKind.disconnected), isTrue);
|
||||
// A deliberate Disconnect reaches idle and must stay disconnected.
|
||||
expect(shouldReconnectOnForeground(ConnectionKind.idle), isFalse);
|
||||
// These states already have their own answer; foregrounding does not churn
|
||||
|
||||
@@ -406,53 +406,50 @@ void main() {
|
||||
await client.dispose();
|
||||
});
|
||||
|
||||
test(
|
||||
'a mismatched protocol warns and the warning survives a drop',
|
||||
() async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
final controller = SettingsController(
|
||||
client: client,
|
||||
store: MemorySettingsStore(),
|
||||
);
|
||||
await controller.initialize();
|
||||
controller.updateServerUrl('ws://example.test:8123');
|
||||
final connecting = controller.connect();
|
||||
await settle();
|
||||
factory.last.markReady();
|
||||
await connecting;
|
||||
await settle();
|
||||
expect(controller.protocolWarning, isNull);
|
||||
test('a mismatched protocol warns and the warning survives a drop', () async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
final controller = SettingsController(
|
||||
client: client,
|
||||
store: MemorySettingsStore(),
|
||||
);
|
||||
await controller.initialize();
|
||||
controller.updateServerUrl('ws://example.test:8123');
|
||||
final connecting = controller.connect();
|
||||
await settle();
|
||||
factory.last.markReady();
|
||||
await connecting;
|
||||
await settle();
|
||||
expect(controller.protocolWarning, isNull);
|
||||
|
||||
factory.last.reply(<String, dynamic>{
|
||||
'id': factory.last.decodedOutgoing.single['id'],
|
||||
'type': 'pong',
|
||||
// The server sends an integer, but the comparison is numeric, like the
|
||||
// web page's Number() rule.
|
||||
'protocol': '2',
|
||||
});
|
||||
await settle();
|
||||
expect(
|
||||
controller.protocolWarning,
|
||||
'Protocol mismatch: this page speaks protocol 1, '
|
||||
'the server reports 2.',
|
||||
);
|
||||
factory.last.reply(<String, dynamic>{
|
||||
'id': factory.last.decodedOutgoing.single['id'],
|
||||
'type': 'pong',
|
||||
// The server sends an integer, but the comparison is numeric, like the
|
||||
// web page's Number() rule.
|
||||
'protocol': '2',
|
||||
});
|
||||
await settle();
|
||||
expect(
|
||||
controller.protocolWarning,
|
||||
'Protocol mismatch: this page speaks protocol 1, '
|
||||
'the server reports 2.',
|
||||
);
|
||||
|
||||
factory.last.fail('socket gone');
|
||||
await settle();
|
||||
expect(controller.connection.kind, transport.ConnectionKind.disconnected);
|
||||
expect(
|
||||
controller.protocolWarning,
|
||||
isNotNull,
|
||||
reason: 'a known mismatch stays visible while the socket reconnects',
|
||||
);
|
||||
factory.last.fail('socket gone');
|
||||
await settle();
|
||||
expect(controller.connection.kind, transport.ConnectionKind.disconnected);
|
||||
expect(
|
||||
controller.protocolWarning,
|
||||
isNotNull,
|
||||
reason: 'a known mismatch stays visible while the socket reconnects',
|
||||
);
|
||||
|
||||
// Cancel the client's scheduled retry before the test ends.
|
||||
await client.disconnect();
|
||||
controller.dispose();
|
||||
await client.dispose();
|
||||
},
|
||||
);
|
||||
// Cancel the client's scheduled retry before the test ends.
|
||||
await client.disconnect();
|
||||
controller.dispose();
|
||||
await client.dispose();
|
||||
});
|
||||
|
||||
test('protocolMismatchWarning ignores matching and absent protocols', () {
|
||||
expect(protocolMismatchWarning(null), isNull);
|
||||
|
||||
Reference in New Issue
Block a user