Unverified Commit 2cd205bb authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] cleanup fuchsia tests (#59997)

Cleanup fuchsia tests that failed under tester.
parent eaf9ff73
...@@ -432,19 +432,18 @@ void main() { ...@@ -432,19 +432,18 @@ void main() {
}); });
group('screenshot', () { group('screenshot', () {
MockProcessManager mockProcessManager; testUsingContext('is supported on posix platforms', () {
setUp(() {
mockProcessManager = MockProcessManager();
});
test('is supported on posix platforms', () {
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester'); final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
expect(device.supportsScreenshot, true); expect(device.supportsScreenshot, true);
}, testOn: 'posix'); }, overrides: <Type, Generator>{
Platform: () => FakePlatform(
operatingSystem: 'linux',
),
});
testUsingContext('is not supported on Windows', () { testUsingContext('is not supported on Windows', () {
final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester'); final FuchsiaDevice device = FuchsiaDevice('id', name: 'tester');
expect(device.supportsScreenshot, false); expect(device.supportsScreenshot, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => FakePlatform( Platform: () => FakePlatform(
...@@ -458,12 +457,12 @@ void main() { ...@@ -458,12 +457,12 @@ void main() {
() => device.takeScreenshot(globals.fs.file('file.invalid')), () => device.takeScreenshot(globals.fs.file('file.invalid')),
throwsA(equals('file.invalid must be a .ppm file')), throwsA(equals('file.invalid must be a .ppm file')),
); );
}, testOn: 'posix'); });
testUsingContext('takeScreenshot throws if screencap failed', () async { testUsingContext('takeScreenshot throws if screencap failed', () async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester'); final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -480,19 +479,20 @@ void main() { ...@@ -480,19 +479,20 @@ void main() {
throwsA(equals('Could not take a screenshot on device tester:\n<error-message>')), throwsA(equals('Could not take a screenshot on device tester:\n<error-message>')),
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager, ProcessManager: () => MockProcessManager(),
FileSystem: () => MemoryFileSystem.test(),
Platform: () => FakePlatform( Platform: () => FakePlatform(
environment: <String, String>{ environment: <String, String>{
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
operatingSystem: 'linux', operatingSystem: 'linux',
), ),
}, testOn: 'posix'); });
testUsingContext('takeScreenshot throws if scp failed', () async { testUsingContext('takeScreenshot throws if scp failed', () async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester'); final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -504,7 +504,7 @@ void main() { ...@@ -504,7 +504,7 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 0, '', '')); )).thenAnswer((_) async => ProcessResult(0, 0, '', ''));
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'scp', 'scp',
'-F', '-F',
...@@ -516,7 +516,7 @@ void main() { ...@@ -516,7 +516,7 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 1, '', '<error-message>')); )).thenAnswer((_) async => ProcessResult(0, 1, '', '<error-message>'));
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -533,19 +533,20 @@ void main() { ...@@ -533,19 +533,20 @@ void main() {
throwsA(equals('Failed to copy screenshot from device:\n<error-message>')), throwsA(equals('Failed to copy screenshot from device:\n<error-message>')),
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager, ProcessManager: () => MockProcessManager(),
FileSystem: () => MemoryFileSystem.test(),
Platform: () => FakePlatform( Platform: () => FakePlatform(
environment: <String, String>{ environment: <String, String>{
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
operatingSystem: 'linux', operatingSystem: 'linux',
), ),
}, testOn: 'posix'); });
testUsingContext("takeScreenshot prints error if can't delete file from device", () async { testUsingContext("takeScreenshot prints error if can't delete file from device", () async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester'); final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -557,7 +558,7 @@ void main() { ...@@ -557,7 +558,7 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 0, '', '')); )).thenAnswer((_) async => ProcessResult(0, 0, '', ''));
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'scp', 'scp',
'-F', '-F',
...@@ -569,7 +570,7 @@ void main() { ...@@ -569,7 +570,7 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 0, '', '')); )).thenAnswer((_) async => ProcessResult(0, 0, '', ''));
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -591,7 +592,8 @@ void main() { ...@@ -591,7 +592,8 @@ void main() {
contains('Failed to delete screenshot.ppm from the device:\n<error-message>'), contains('Failed to delete screenshot.ppm from the device:\n<error-message>'),
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager, ProcessManager: () => MockProcessManager(),
FileSystem: () => MemoryFileSystem.test(),
Platform: () => FakePlatform( Platform: () => FakePlatform(
environment: <String, String>{ environment: <String, String>{
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
...@@ -603,7 +605,7 @@ void main() { ...@@ -603,7 +605,7 @@ void main() {
testUsingContext('takeScreenshot returns', () async { testUsingContext('takeScreenshot returns', () async {
final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester'); final FuchsiaDevice device = FuchsiaDevice('0.0.0.0', name: 'tester');
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -615,7 +617,7 @@ void main() { ...@@ -615,7 +617,7 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 0, '', '')); )).thenAnswer((_) async => ProcessResult(0, 0, '', ''));
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'scp', 'scp',
'-F', '-F',
...@@ -627,7 +629,7 @@ void main() { ...@@ -627,7 +629,7 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 0, '', '')); )).thenAnswer((_) async => ProcessResult(0, 0, '', ''));
when(mockProcessManager.run( when(globals.processManager.run(
const <String>[ const <String>[
'ssh', 'ssh',
'-F', '-F',
...@@ -639,20 +641,18 @@ void main() { ...@@ -639,20 +641,18 @@ void main() {
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenAnswer((_) async => ProcessResult(0, 0, '', '')); )).thenAnswer((_) async => ProcessResult(0, 0, '', ''));
try { expect(() async => await device.takeScreenshot(globals.fs.file('file.ppm')),
await device.takeScreenshot(globals.fs.file('file.ppm')); returnsNormally);
} on Exception catch (e) {
fail('Unexpected exception: $e');
}
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager, ProcessManager: () => MockProcessManager(),
FileSystem: () => MemoryFileSystem.test(),
Platform: () => FakePlatform( Platform: () => FakePlatform(
environment: <String, String>{ environment: <String, String>{
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
operatingSystem: 'linux', operatingSystem: 'linux',
), ),
}, testOn: 'posix'); });
}); });
group('portForwarder', () { group('portForwarder', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment