From 53a21710cf9d10618e0b22ce4c6993655b599d7b Mon Sep 17 00:00:00 2001 From: Andrew Kolos Date: Tue, 4 Feb 2025 10:32:06 -0800 Subject: [PATCH] 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
Pre-launch checklist - [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.
[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 --- .../commands.shard/hermetic/config_test.dart | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart index 85029f9c05..18745650d5 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart @@ -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: {Usage: () => testUsage}); + }); testUsingContext('throws error on excess arguments', () { final ConfigCommand configCommand = ConfigCommand(); @@ -82,8 +72,8 @@ void main() { ]), throwsToolExit(), ); - verifyNoAnalytics(); - }, overrides: {Usage: () => testUsage}); + expect(fakeAnalytics.sentEvents, isEmpty); + }, overrides: {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: { AndroidStudio: () => fakeAndroidStudio, AndroidSdk: () => fakeAndroidSdk, Java: () => fakeJava, - Usage: () => testUsage, + Analytics: () => fakeAnalytics, }, ); @@ -116,16 +106,20 @@ void main() { await commandRunner.run(['config', '--build-dir=foo']); expect(getBuildDirectory(), 'foo'); - verifyNoAnalytics(); - }, overrides: {Usage: () => testUsage}); + expect(fakeAnalytics.sentEvents, isEmpty); + }, overrides: {Analytics: () => fakeAnalytics}); - testUsingContext('throws error on absolute path to build-dir', () async { - final ConfigCommand configCommand = ConfigCommand(); - final CommandRunner commandRunner = createTestCommandRunner(configCommand); + testUsingContext( + 'throws error on absolute path to build-dir', + () async { + final ConfigCommand configCommand = ConfigCommand(); + final CommandRunner commandRunner = createTestCommandRunner(configCommand); - expect(() => commandRunner.run(['config', '--build-dir=/foo']), throwsToolExit()); - verifyNoAnalytics(); - }, overrides: {Usage: () => testUsage}); + expect(() => commandRunner.run(['config', '--build-dir=/foo']), throwsToolExit()); + expect(fakeAnalytics.sentEvents, isEmpty); + }, + overrides: {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: { 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: {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: { AndroidStudio: () => fakeAndroidStudio, AndroidSdk: () => fakeAndroidSdk, FlutterVersion: () => fakeFlutterVersion, - Usage: () => testUsage, + Analytics: () => fakeAnalytics, }, );