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

[flutter_tools] remove mockito from flutter symbolize test (#75263)

parent 21f89fe0
...@@ -8,12 +8,14 @@ import 'dart:async'; ...@@ -8,12 +8,14 @@ import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/symbolize.dart'; import 'package:flutter_tools/src/commands/symbolize.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart'; import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
...@@ -23,7 +25,6 @@ void main() { ...@@ -23,7 +25,6 @@ void main() {
MemoryFileSystem fileSystem; MemoryFileSystem fileSystem;
FakeStdio stdio; FakeStdio stdio;
SymbolizeCommand command; SymbolizeCommand command;
MockDwarfSymbolizationService mockDwarfSymbolizationService;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
...@@ -32,11 +33,10 @@ void main() { ...@@ -32,11 +33,10 @@ void main() {
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
stdio = FakeStdio(); stdio = FakeStdio();
mockDwarfSymbolizationService = MockDwarfSymbolizationService();
command = SymbolizeCommand( command = SymbolizeCommand(
stdio: stdio, stdio: stdio,
fileSystem: fileSystem, fileSystem: fileSystem,
dwarfSymbolizationService: mockDwarfSymbolizationService, dwarfSymbolizationService: DwarfSymbolizationService.test(),
); );
}); });
...@@ -85,32 +85,23 @@ void main() { ...@@ -85,32 +85,23 @@ void main() {
fileSystem.file('app.debug').writeAsBytesSync(<int>[1, 2, 3]); fileSystem.file('app.debug').writeAsBytesSync(<int>[1, 2, 3]);
fileSystem.file('foo.stack').writeAsStringSync('hello'); fileSystem.file('foo.stack').writeAsStringSync('hello');
when(mockDwarfSymbolizationService.decode(
input: anyNamed('input'),
output: anyNamed('output'),
symbols: anyNamed('symbols'))
).thenAnswer((Invocation invocation) async {
// Data is passed correctly to service
expect((await (invocation.namedArguments[#input] as Stream<List<int>>).toList()).first,
utf8.encode('hello'));
expect(invocation.namedArguments[#symbols] as Uint8List, <int>[1, 2, 3,]);
return;
});
await createTestCommandRunner(command) await createTestCommandRunner(command)
.run(const <String>['symbolize', '--debug-info=app.debug', '--input=foo.stack', '--output=results/foo.result']); .run(const <String>['symbolize', '--debug-info=app.debug', '--input=foo.stack', '--output=results/foo.result']);
expect(fileSystem.file('results/foo.result'), exists);
expect(fileSystem.file('results/foo.result').readAsBytesSync(), <int>[104, 101, 108, 108, 111, 10]); // hello
}); });
testUsingContext('symbolize throws when DwarfSymbolizationService throws', () async { testUsingContext('symbolize throws when DwarfSymbolizationService throws', () async {
command = SymbolizeCommand(
stdio: stdio,
fileSystem: fileSystem,
dwarfSymbolizationService: ThrowingDwarfSymbolizationService(),
);
fileSystem.file('app.debug').writeAsBytesSync(<int>[1, 2, 3]); fileSystem.file('app.debug').writeAsBytesSync(<int>[1, 2, 3]);
fileSystem.file('foo.stack').writeAsStringSync('hello'); fileSystem.file('foo.stack').writeAsStringSync('hello');
when(mockDwarfSymbolizationService.decode(
input: anyNamed('input'),
output: anyNamed('output'),
symbols: anyNamed('symbols'))
).thenThrow(ToolExit('test'));
expect( expect(
createTestCommandRunner(command).run(const <String>[ createTestCommandRunner(command).run(const <String>[
'symbolize', '--debug-info=app.debug', '--input=foo.stack', '--output=results/foo.result']), 'symbolize', '--debug-info=app.debug', '--input=foo.stack', '--output=results/foo.result']),
...@@ -119,4 +110,13 @@ void main() { ...@@ -119,4 +110,13 @@ void main() {
}); });
} }
class MockDwarfSymbolizationService extends Mock implements DwarfSymbolizationService {} class ThrowingDwarfSymbolizationService extends Fake implements DwarfSymbolizationService {
@override
Future<void> decode({
@required Stream<List<int>> input,
@required IOSink output,
@required Uint8List symbols,
}) async {
throwToolExit('test');
}
}
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