delete references to Usage
in config_test.dart (#162648)
Fixes https://github.com/flutter/flutter/issues/162413. Toward https://github.com/flutter/flutter/issues/150575 <details> <summary> Pre-launch checklist </summary> - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. </details> <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
e7bdde6534
commit
53a21710cf
@ -15,7 +15,6 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/config.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
@ -30,7 +29,6 @@ void main() {
|
||||
late FakeAndroidStudio fakeAndroidStudio;
|
||||
late FakeAndroidSdk fakeAndroidSdk;
|
||||
late FakeFlutterVersion fakeFlutterVersion;
|
||||
late TestUsage testUsage;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
|
||||
setUpAll(() {
|
||||
@ -42,20 +40,12 @@ void main() {
|
||||
fakeAndroidStudio = FakeAndroidStudio();
|
||||
fakeAndroidSdk = FakeAndroidSdk();
|
||||
fakeFlutterVersion = FakeFlutterVersion();
|
||||
testUsage = TestUsage();
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: MemoryFileSystem.test(),
|
||||
fakeFlutterVersion: fakes.FakeFlutterVersion(),
|
||||
);
|
||||
});
|
||||
|
||||
void verifyNoAnalytics() {
|
||||
expect(testUsage.commands, isEmpty);
|
||||
expect(testUsage.events, isEmpty);
|
||||
expect(testUsage.timings, isEmpty);
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
}
|
||||
|
||||
group('config', () {
|
||||
testUsingContext('prints all settings with --list', () async {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
@ -67,7 +57,7 @@ void main() {
|
||||
'${allFeatures.where((Feature e) => e.configSetting != null).map((Feature e) => ' ${e.configSetting}: (Not set)').join('\n')}'
|
||||
'\n\n',
|
||||
);
|
||||
}, overrides: <Type, Generator>{Usage: () => testUsage});
|
||||
});
|
||||
|
||||
testUsingContext('throws error on excess arguments', () {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
@ -82,8 +72,8 @@ void main() {
|
||||
]),
|
||||
throwsToolExit(),
|
||||
);
|
||||
verifyNoAnalytics();
|
||||
}, overrides: <Type, Generator>{Usage: () => testUsage});
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
}, overrides: <Type, Generator>{Analytics: () => fakeAnalytics});
|
||||
|
||||
testUsingContext(
|
||||
'machine flag',
|
||||
@ -99,13 +89,13 @@ void main() {
|
||||
expect(jsonObject['android-sdk'], fakeAndroidSdk.directory.path);
|
||||
expect(jsonObject['jdk-dir'], fakeJava.javaHome);
|
||||
}
|
||||
verifyNoAnalytics();
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidStudio: () => fakeAndroidStudio,
|
||||
AndroidSdk: () => fakeAndroidSdk,
|
||||
Java: () => fakeJava,
|
||||
Usage: () => testUsage,
|
||||
Analytics: () => fakeAnalytics,
|
||||
},
|
||||
);
|
||||
|
||||
@ -116,16 +106,20 @@ void main() {
|
||||
await commandRunner.run(<String>['config', '--build-dir=foo']);
|
||||
|
||||
expect(getBuildDirectory(), 'foo');
|
||||
verifyNoAnalytics();
|
||||
}, overrides: <Type, Generator>{Usage: () => testUsage});
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
}, overrides: <Type, Generator>{Analytics: () => fakeAnalytics});
|
||||
|
||||
testUsingContext('throws error on absolute path to build-dir', () async {
|
||||
testUsingContext(
|
||||
'throws error on absolute path to build-dir',
|
||||
() async {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
|
||||
|
||||
expect(() => commandRunner.run(<String>['config', '--build-dir=/foo']), throwsToolExit());
|
||||
verifyNoAnalytics();
|
||||
}, overrides: <Type, Generator>{Usage: () => testUsage});
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
},
|
||||
overrides: <Type, Generator>{Analytics: () => fakeAnalytics},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'allows setting and removing feature flags',
|
||||
@ -175,12 +169,12 @@ void main() {
|
||||
expect(globals.config.getValue('enable-linux-desktop'), false);
|
||||
expect(globals.config.getValue('enable-windows-desktop'), false);
|
||||
expect(globals.config.getValue('enable-macos-desktop'), false);
|
||||
verifyNoAnalytics();
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidStudio: () => fakeAndroidStudio,
|
||||
AndroidSdk: () => fakeAndroidSdk,
|
||||
Usage: () => testUsage,
|
||||
Analytics: () => fakeAnalytics,
|
||||
},
|
||||
);
|
||||
|
||||
@ -194,7 +188,7 @@ void main() {
|
||||
testLogger.statusText,
|
||||
containsIgnoringWhitespace('You may need to restart any open editors'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{Usage: () => testUsage});
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'displays which config settings are available on stable',
|
||||
@ -217,13 +211,13 @@ void main() {
|
||||
expect(testLogger.statusText, containsIgnoringWhitespace('enable-linux-desktop: true'));
|
||||
expect(testLogger.statusText, containsIgnoringWhitespace('enable-windows-desktop: true'));
|
||||
expect(testLogger.statusText, containsIgnoringWhitespace('enable-macos-desktop: true'));
|
||||
verifyNoAnalytics();
|
||||
expect(fakeAnalytics.sentEvents, isEmpty);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidStudio: () => fakeAndroidStudio,
|
||||
AndroidSdk: () => fakeAndroidSdk,
|
||||
FlutterVersion: () => fakeFlutterVersion,
|
||||
Usage: () => testUsage,
|
||||
Analytics: () => fakeAnalytics,
|
||||
},
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user