forked from firka/flutter
Reland: More verification on flutter build web, add tests and cleanup (#34173)
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/context_runner.dart';
|
||||
import 'package:flutter_tools/src/usage.dart';
|
||||
|
||||
import 'context.dart';
|
||||
|
||||
@@ -24,6 +25,7 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem(), // Keeps tests fast by avoid actual file system.
|
||||
Logger: () => BufferLogger(), // Allows reading logs and prevents stdout.
|
||||
OutputPreferences: () => OutputPreferences(showColor: false), // configures BufferLogger to avoid color codes.
|
||||
Usage: () => NoOpUsage(), // prevent addition of analytics from burdening test mocks
|
||||
};
|
||||
|
||||
/// Manages interaction with the tool injection and runner system.
|
||||
@@ -60,7 +62,7 @@ class Testbed {
|
||||
/// `overrides` provides more overrides in addition to the test defaults.
|
||||
/// `setup` may be provided to apply mocks within the tool managed zone,
|
||||
/// including any specified overrides.
|
||||
Testbed({Future<void> Function() setup, Map<Type, Generator> overrides})
|
||||
Testbed({FutureOr<void> Function() setup, Map<Type, Generator> overrides})
|
||||
: _setup = setup,
|
||||
_overrides = overrides;
|
||||
|
||||
@@ -101,3 +103,41 @@ class Testbed {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// A no-op implementation of [Usage] for testing.
|
||||
class NoOpUsage implements Usage {
|
||||
@override
|
||||
bool enabled = false;
|
||||
|
||||
@override
|
||||
bool suppressAnalytics = true;
|
||||
|
||||
@override
|
||||
String get clientId => 'test';
|
||||
|
||||
@override
|
||||
Future<void> ensureAnalyticsSent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isFirstRun => false;
|
||||
|
||||
@override
|
||||
Stream<Map<String, Object>> get onSend => const Stream<Object>.empty();
|
||||
|
||||
@override
|
||||
void printWelcome() {}
|
||||
|
||||
@override
|
||||
void sendCommand(String command, {Map<String, String> parameters}) {}
|
||||
|
||||
@override
|
||||
void sendEvent(String category, String parameter, {Map<String, String> parameters}) {}
|
||||
|
||||
@override
|
||||
void sendException(dynamic exception, StackTrace trace) {}
|
||||
|
||||
@override
|
||||
void sendTiming(String category, String variableName, Duration duration, {String label}) {}
|
||||
}
|
||||
Reference in New Issue
Block a user