Reduce the chances of bots reporting analytics (#13915)
* First version * Prevent modification of .flutter during analytics test * Pass in directory and override analyzer warning due to conditional import * Review comments
This commit is contained in:
@@ -55,7 +55,7 @@ void main() {
|
||||
expect(count, 0);
|
||||
}, overrides: <Type, Generator>{
|
||||
FlutterVersion: () => new FlutterVersion(const Clock()),
|
||||
Usage: () => new Usage(),
|
||||
Usage: () => new Usage(configDirOverride: temp.path),
|
||||
});
|
||||
|
||||
// Ensure we don't send for the 'flutter config' command.
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
expect(count, 0);
|
||||
}, overrides: <Type, Generator>{
|
||||
FlutterVersion: () => new FlutterVersion(const Clock()),
|
||||
Usage: () => new Usage(),
|
||||
Usage: () => new Usage(configDirOverride: temp.path),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -134,6 +134,11 @@ void main() {
|
||||
});
|
||||
|
||||
group('analytics bots', () {
|
||||
Directory temp;
|
||||
setUp(() {
|
||||
temp = fs.systemTempDirectory.createTempSync('flutter_tools');
|
||||
});
|
||||
|
||||
testUsingContext('don\'t send on bots', () async {
|
||||
int count = 0;
|
||||
flutterUsage.onSend.listen((Map<String, dynamic> data) => count++);
|
||||
@@ -144,6 +149,22 @@ void main() {
|
||||
Usage: () => new Usage(
|
||||
settingsName: 'flutter_bot_test',
|
||||
versionOverride: 'dev/unknown',
|
||||
configDirOverride: temp.path,
|
||||
),
|
||||
});
|
||||
|
||||
testUsingContext('don\'t send on bots even when opted in', () async {
|
||||
int count = 0;
|
||||
flutterUsage.onSend.listen((Map<String, dynamic> data) => count++);
|
||||
flutterUsage.enabled = true;
|
||||
|
||||
await createTestCommandRunner().run(<String>['--version']);
|
||||
expect(count, 0);
|
||||
}, overrides: <Type, Generator>{
|
||||
Usage: () => new Usage(
|
||||
settingsName: 'flutter_bot_test',
|
||||
versionOverride: 'dev/unknown',
|
||||
configDirOverride: temp.path,
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user