Optionally invert oversized images (#61209)

* Optionally invert oversized images
This commit is contained in:
Dan Field
2020-07-13 14:03:23 -07:00
committed by GitHub
parent 8048c0332d
commit eadc35f62b
14 changed files with 361 additions and 51 deletions

View File

@@ -50,6 +50,10 @@ void _testMessageLength({
expectedWidth += ansiMetaCharactersLength;
}
expect(
commandHelp.I.toString().length,
lessThanOrEqualTo(expectedWidth),
);
expect(commandHelp.L.toString().length, lessThanOrEqualTo(expectedWidth));
expect(commandHelp.P.toString().length, lessThanOrEqualTo(expectedWidth));
expect(commandHelp.R.toString().length, lessThanOrEqualTo(expectedWidth));

View File

@@ -858,6 +858,7 @@ void main() {
commandHelp.S,
commandHelp.U,
commandHelp.i,
commandHelp.I,
commandHelp.p,
commandHelp.o,
commandHelp.z,
@@ -1284,6 +1285,36 @@ void main() {
expect(fakeVmServiceHost.hasRemainingExpectations, false);
}));
testUsingContext('ResidentRunner debugToggleInvertOversizedImages calls flutter device', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
await residentRunner.debugToggleInvertOversizedImages();
verify(mockFlutterDevice.toggleInvertOversizedImages()).called(1);
}));
testUsingContext('FlutterDevice.toggleInvertOversizedImages invokes correct VM service request', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,
const FakeVmServiceRequest(
method: 'ext.flutter.invertOversizedImages',
args: <String, Object>{
'isolateId': '1',
},
jsonResponse: <String, Object>{
'value': 'false'
},
),
]);
final FlutterDevice device = FlutterDevice(
mockDevice,
buildInfo: BuildInfo.debug,
);
device.vmService = fakeVmServiceHost.vmService;
await device.toggleInvertOversizedImages();
expect(fakeVmServiceHost.hasRemainingExpectations, false);
}));
testUsingContext('ResidentRunner debugToggleDebugCheckElevationsEnabled calls flutter device', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
await residentRunner.debugToggleDebugCheckElevationsEnabled();

View File

@@ -1179,6 +1179,47 @@ void main() {
Platform: () => FakePlatform(operatingSystem: 'linux', environment: <String, String>{}),
});
testUsingContext('debugToggleInvertOversizedImagesOverride', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
...kAttachExpectations,
const FakeVmServiceRequest(
method: 'ext.flutter.invertOversizedImages',
args: <String, Object>{
'isolateId': null,
},
jsonResponse: <String, Object>{
'enabled': 'false'
},
),
const FakeVmServiceRequest(
method: 'ext.flutter.invertOversizedImages',
args: <String, Object>{
'isolateId': null,
'enabled': 'true',
},
jsonResponse: <String, Object>{
'enabled': 'true'
},
)
]);
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
));
await connectionInfoCompleter.future;
await residentWebRunner.debugToggleInvertOversizedImages();
expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Pub: () => MockPub(),
Platform: () => FakePlatform(operatingSystem: 'linux', environment: <String, String>{}),
});
testUsingContext('debugToggleWidgetInspector', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[

View File

@@ -122,21 +122,39 @@ void main() {
verify(mockResidentRunner.toggleCanvaskit()).called(1);
});
testUsingContext('i, I - debugToggleWidgetInspector with service protocol', () async {
testUsingContext('i - debugToggleWidgetInspector with service protocol', () async {
await terminalHandler.processTerminalInput('i');
await terminalHandler.processTerminalInput('I');
verify(mockResidentRunner.debugToggleWidgetInspector()).called(2);
verify(mockResidentRunner.debugToggleWidgetInspector()).called(1);
});
testUsingContext('i, I - debugToggleWidgetInspector without service protocol', () async {
testUsingContext('i - debugToggleWidgetInspector without service protocol', () async {
when(mockResidentRunner.supportsServiceProtocol).thenReturn(false);
await terminalHandler.processTerminalInput('i');
await terminalHandler.processTerminalInput('I');
verifyNever(mockResidentRunner.debugToggleWidgetInspector());
});
testUsingContext('I - debugToggleInvertOversizedImages with service protocol/debug', () async {
when(mockResidentRunner.isRunningDebug).thenReturn(true);
await terminalHandler.processTerminalInput('I');
verify(mockResidentRunner.debugToggleInvertOversizedImages()).called(1);
});
testUsingContext('I - debugToggleInvertOversizedImages with service protocol/ndebug', () async {
when(mockResidentRunner.isRunningDebug).thenReturn(false);
await terminalHandler.processTerminalInput('I');
verifyNever(mockResidentRunner.debugToggleInvertOversizedImages());
});
testUsingContext('I - debugToggleInvertOversizedImages without service protocol', () async {
when(mockResidentRunner.supportsServiceProtocol).thenReturn(false);
await terminalHandler.processTerminalInput('I');
});
testUsingContext('l - list flutter views', () async {
final MockFlutterDevice mockFlutterDevice = MockFlutterDevice();
when(mockResidentRunner.isRunningDebug).thenReturn(true);