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';
import 'dart:typed_data';
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/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/symbolize.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/context.dart';
......@@ -23,7 +25,6 @@ void main() {
MemoryFileSystem fileSystem;
FakeStdio stdio;
SymbolizeCommand command;
MockDwarfSymbolizationService mockDwarfSymbolizationService;
setUpAll(() {
Cache.disableLocking();
......@@ -32,11 +33,10 @@ void main() {
setUp(() {
fileSystem = MemoryFileSystem.test();
stdio = FakeStdio();
mockDwarfSymbolizationService = MockDwarfSymbolizationService();
command = SymbolizeCommand(
stdio: stdio,
fileSystem: fileSystem,
dwarfSymbolizationService: mockDwarfSymbolizationService,
dwarfSymbolizationService: DwarfSymbolizationService.test(),
);
});
......@@ -85,32 +85,23 @@ void main() {
fileSystem.file('app.debug').writeAsBytesSync(<int>[1, 2, 3]);
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)
.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 {
command = SymbolizeCommand(
stdio: stdio,
fileSystem: fileSystem,
dwarfSymbolizationService: ThrowingDwarfSymbolizationService(),
);
fileSystem.file('app.debug').writeAsBytesSync(<int>[1, 2, 3]);
fileSystem.file('foo.stack').writeAsStringSync('hello');
when(mockDwarfSymbolizationService.decode(
input: anyNamed('input'),
output: anyNamed('output'),
symbols: anyNamed('symbols'))
).thenThrow(ToolExit('test'));
expect(
createTestCommandRunner(command).run(const <String>[
'symbolize', '--debug-info=app.debug', '--input=foo.stack', '--output=results/foo.result']),
......@@ -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