Add to app measurement (#33458)
diff --git a/packages/flutter_tools/test/commands/packages_test.dart b/packages/flutter_tools/test/commands/packages_test.dart index 94dfbae..e3b6119 100644 --- a/packages/flutter_tools/test/commands/packages_test.dart +++ b/packages/flutter_tools/test/commands/packages_test.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/packages.dart'; +import 'package:flutter_tools/src/usage.dart'; import 'package:process/process.dart'; import '../src/common.dart'; @@ -57,7 +58,7 @@ return projectPath; } - Future<void> runCommandIn(String projectPath, String verb, { List<String> args }) async { + Future<PackagesCommand> runCommandIn(String projectPath, String verb, { List<String> args }) async { final PackagesCommand command = PackagesCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); @@ -67,6 +68,7 @@ commandArgs.add(projectPath); await runner.run(commandArgs); + return command; } void expectExists(String projectPath, String relPath) { @@ -217,6 +219,39 @@ expectZeroPluginsInjected(projectPath); }, timeout: allowForCreateFlutterProject); + testUsingContext('set the number of plugins as usage value', () async { + final String projectPath = await createProject(tempDir, + arguments: <String>['--no-pub', '--template=module']); + removeGeneratedFiles(projectPath); + + final PackagesCommand command = await runCommandIn(projectPath, 'get'); + final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand; + + expect(await getCommand.usageValues, containsPair(kCommandPackagesNumberPlugins, '0')); + }, timeout: allowForCreateFlutterProject); + + testUsingContext('indicate that the project is not a module in usage value', () async { + final String projectPath = await createProject(tempDir, + arguments: <String>['--no-pub']); + removeGeneratedFiles(projectPath); + + final PackagesCommand command = await runCommandIn(projectPath, 'get'); + final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand; + + expect(await getCommand.usageValues, containsPair(kCommandPackagesProjectModule, 'false')); + }, timeout: allowForCreateFlutterProject); + + testUsingContext('indicate that the project is a module in usage value', () async { + final String projectPath = await createProject(tempDir, + arguments: <String>['--no-pub', '--template=module']); + removeGeneratedFiles(projectPath); + + final PackagesCommand command = await runCommandIn(projectPath, 'get'); + final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand; + + expect(await getCommand.usageValues, containsPair(kCommandPackagesProjectModule, 'true')); + }, timeout: allowForCreateFlutterProject); + testUsingContext('upgrade fetches packages', () async { final String projectPath = await createProject(tempDir, arguments: <String>['--no-pub', '--template=module']);