Unified analytics events migration for BuildEvent (#137562)
Related to tracker issue: - https://github.com/flutter/flutter/issues/128251
This commit is contained in:
@@ -24,10 +24,12 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../general.shard/ios/xcresult_test_data.dart';
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/fakes.dart';
|
||||
import '../../src/test_build_system.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
@@ -70,6 +72,7 @@ final Platform notMacosPlatform = FakePlatform(
|
||||
void main() {
|
||||
late FileSystem fileSystem;
|
||||
late TestUsage usage;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
late BufferLogger logger;
|
||||
late FakeProcessManager processManager;
|
||||
late ProcessUtils processUtils;
|
||||
@@ -83,6 +86,10 @@ void main() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
artifacts = Artifacts.test(fileSystem: fileSystem);
|
||||
usage = TestUsage();
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fileSystem,
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
);
|
||||
logger = BufferLogger.test();
|
||||
processManager = FakeProcessManager.empty();
|
||||
processUtils = ProcessUtils(
|
||||
@@ -587,6 +594,13 @@ void main() {
|
||||
parameters:CustomDimensions(),
|
||||
),
|
||||
));
|
||||
|
||||
expect(fakeAnalytics.sentEvents, contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'plist-impeller-enabled',
|
||||
buildType: 'ios',
|
||||
),
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
@@ -607,6 +621,7 @@ void main() {
|
||||
),
|
||||
Usage: () => usage,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
Analytics: () => fakeAnalytics,
|
||||
});
|
||||
|
||||
testUsingContext('Sends an analytics event when Impeller is disabled', () async {
|
||||
@@ -642,6 +657,13 @@ void main() {
|
||||
parameters:CustomDimensions(),
|
||||
),
|
||||
));
|
||||
|
||||
expect(fakeAnalytics.sentEvents, contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'plist-impeller-disabled',
|
||||
buildType: 'ios',
|
||||
),
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
@@ -673,6 +695,7 @@ void main() {
|
||||
plutilCommand, plutilCommand, plutilCommand,
|
||||
]),
|
||||
),
|
||||
Analytics: () => fakeAnalytics,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@@ -33,6 +34,7 @@ void main() {
|
||||
group('gradle build', () {
|
||||
late BufferLogger logger;
|
||||
late TestUsage testUsage;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
late FileSystem fileSystem;
|
||||
late FakeProcessManager processManager;
|
||||
|
||||
@@ -42,6 +44,11 @@ void main() {
|
||||
testUsage = TestUsage();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
Cache.flutterRoot = '';
|
||||
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fileSystem,
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
);
|
||||
});
|
||||
|
||||
testUsingContext('Can immediately tool exit on recognized exit code/stderr', () async {
|
||||
@@ -52,6 +59,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -133,6 +141,15 @@ void main() {
|
||||
parameters: CustomDimensions(),
|
||||
),
|
||||
));
|
||||
expect(testUsage.events, hasLength(2));
|
||||
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
unorderedEquals(<Event>[
|
||||
Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(label: 'gradle-random-event-label-failure', buildType: 'gradle'),
|
||||
]),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidStudio: () => FakeAndroidStudio(),
|
||||
});
|
||||
@@ -145,6 +162,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -213,6 +231,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -307,6 +326,15 @@ void main() {
|
||||
parameters: CustomDimensions(),
|
||||
),
|
||||
));
|
||||
expect(testUsage.events, hasLength(4));
|
||||
|
||||
expect(fakeAnalytics.sentEvents, hasLength(4));
|
||||
expect(fakeAnalytics.sentEvents, contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-random-event-label-failure',
|
||||
buildType: 'gradle',
|
||||
),
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidStudio: () => FakeAndroidStudio(),
|
||||
});
|
||||
@@ -319,6 +347,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -400,6 +429,16 @@ void main() {
|
||||
parameters: CustomDimensions(),
|
||||
),
|
||||
));
|
||||
expect(testUsage.events, hasLength(2));
|
||||
|
||||
expect(fakeAnalytics.sentEvents, hasLength(2));
|
||||
expect(fakeAnalytics.sentEvents, contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-random-event-label-failure',
|
||||
buildType: 'gradle',
|
||||
),
|
||||
));
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidStudio: () => FakeAndroidStudio(),
|
||||
});
|
||||
@@ -412,6 +451,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -477,6 +517,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -581,6 +622,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(
|
||||
environment: <String, String>{
|
||||
@@ -683,6 +725,7 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -811,6 +854,7 @@ android {
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -846,6 +890,7 @@ BuildVariant: paidProfile
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -877,6 +922,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -904,6 +950,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -970,6 +1017,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1029,6 +1077,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1089,6 +1138,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1169,6 +1219,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm64', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1249,6 +1300,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x86', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1329,6 +1381,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x64', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1410,6 +1463,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1471,6 +1525,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1560,6 +1615,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_arm64', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1649,6 +1705,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x86', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
@@ -1738,6 +1795,7 @@ Gradle Crashed
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.testLocalEngine(localEngine: 'out/android_x64', localEngineHost: 'out/host_release'),
|
||||
usage: testUsage,
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
|
||||
@@ -9,14 +9,21 @@ import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/fakes.dart';
|
||||
|
||||
void main() {
|
||||
late FileSystem fileSystem;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fileSystem,
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('Finds app bundle when flavor contains multiple dimensions in release mode', () {
|
||||
@@ -26,6 +33,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'fooBar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -39,6 +47,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'foo_bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -52,6 +61,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -65,6 +75,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'foo', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -78,6 +89,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'fooA', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -91,6 +103,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, null, treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -104,6 +117,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'fooBar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -117,6 +131,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'foo_bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -130,6 +145,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -143,6 +159,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'foo', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -156,6 +173,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'fooA', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -169,6 +187,7 @@ void main() {
|
||||
BuildInfo.debug,
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -182,6 +201,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, 'fooBar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -195,6 +215,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, 'foo_bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -208,6 +229,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, 'foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -221,6 +243,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, 'foo', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -234,6 +257,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, 'fooA', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -247,6 +271,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, null, treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -260,6 +285,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, null, treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -273,6 +299,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, null, treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -286,6 +313,7 @@ void main() {
|
||||
BuildInfo.debug,
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -299,6 +327,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'foo_bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -312,6 +341,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -325,6 +355,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.profile, 'foo_bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -338,6 +369,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -352,6 +384,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.release, 'Foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -366,6 +399,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'Foo_Bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
TestUsage(),
|
||||
fakeAnalytics,
|
||||
);
|
||||
|
||||
expect(bundle, isNotNull);
|
||||
@@ -382,6 +416,7 @@ void main() {
|
||||
const BuildInfo(BuildMode.debug, 'foo_bar', treeShakeIcons: false),
|
||||
BufferLogger.test(),
|
||||
testUsage,
|
||||
fakeAnalytics,
|
||||
);
|
||||
},
|
||||
throwsToolExit(
|
||||
@@ -400,6 +435,17 @@ void main() {
|
||||
}),
|
||||
),
|
||||
));
|
||||
expect(fakeAnalytics.sentEvents, hasLength(1));
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-expected-file-not-found',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: 7.5, fileExtension: .aab',
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/ios/xcresult.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/fake_process_manager.dart';
|
||||
@@ -133,12 +134,19 @@ void main() {
|
||||
group('Diagnose Xcode build failure', () {
|
||||
late Map<String, String> buildSettings;
|
||||
late TestUsage testUsage;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
|
||||
setUp(() {
|
||||
buildSettings = <String, String>{
|
||||
'PRODUCT_BUNDLE_IDENTIFIER': 'test.app',
|
||||
};
|
||||
testUsage = TestUsage();
|
||||
|
||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fs,
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('Sends analytics when bitcode fails', () async {
|
||||
@@ -154,7 +162,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger);
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger, fakeAnalytics);
|
||||
expect(testUsage.events, contains(
|
||||
TestUsageEvent(
|
||||
'build',
|
||||
@@ -166,6 +174,15 @@ void main() {
|
||||
),
|
||||
),
|
||||
));
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(Event.flutterBuildInfo(
|
||||
label: 'xcode-bitcode-failure',
|
||||
buildType: 'ios',
|
||||
command: '[xcrun, cc, blah]',
|
||||
settings: '{PRODUCT_BUNDLE_IDENTIFIER: test.app}'
|
||||
)),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('fallback to stdout: No provisioning profile shows message', () async {
|
||||
@@ -238,7 +255,7 @@ Error launching application on iPhone.''',
|
||||
),
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger);
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger, fakeAnalytics);
|
||||
expect(
|
||||
logger.errorText,
|
||||
contains(noProvisioningProfileInstruction),
|
||||
@@ -276,7 +293,7 @@ Error launching application on iPhone.''',
|
||||
),
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger);
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger, fakeAnalytics);
|
||||
expect(
|
||||
logger.errorText,
|
||||
contains(missingPlatformInstructions('iOS 17.0')),
|
||||
@@ -316,7 +333,7 @@ Could not build the precompiled application for the device.''',
|
||||
),
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger);
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger, fakeAnalytics);
|
||||
expect(
|
||||
logger.errorText,
|
||||
contains('Building a deployable iOS app requires a selected Development Team with a \nProvisioning Profile.'),
|
||||
@@ -359,7 +376,7 @@ Could not build the precompiled application for the device.''',
|
||||
])
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger);
|
||||
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger, fakeAnalytics);
|
||||
expect(logger.errorText, contains('Error (Xcode): Target aot_assembly_release failed'));
|
||||
expect(logger.errorText, isNot(contains('Building a deployable iOS app requires a selected Development Team')));
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/ios/xcode_build_settings.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@@ -72,6 +73,7 @@ void main() {
|
||||
platform: platform,
|
||||
processManager: fakeProcessManager,
|
||||
usage: TestUsage(),
|
||||
analytics: NoOpAnalytics(),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -184,6 +186,7 @@ void main() {
|
||||
platform: platform,
|
||||
processManager: fakeProcessManager,
|
||||
usage: TestUsage(),
|
||||
analytics: NoOpAnalytics(),
|
||||
);
|
||||
fileSystem.file(xcodebuild).deleteSync();
|
||||
|
||||
@@ -510,6 +513,7 @@ void main() {
|
||||
platform: platform,
|
||||
processManager: fakeProcessManager,
|
||||
usage: TestUsage(),
|
||||
analytics: NoOpAnalytics(),
|
||||
);
|
||||
|
||||
expect(await xcodeProjectInterpreter.getInfo(workingDirectory), isNotNull);
|
||||
@@ -536,6 +540,7 @@ void main() {
|
||||
platform: platform,
|
||||
processManager: fakeProcessManager,
|
||||
usage: TestUsage(),
|
||||
analytics: NoOpAnalytics(),
|
||||
);
|
||||
|
||||
expect(() => xcodeProjectInterpreter.getInfo(workingDirectory), throwsToolExit(message: stderr));
|
||||
@@ -562,6 +567,7 @@ void main() {
|
||||
platform: platform,
|
||||
processManager: fakeProcessManager,
|
||||
usage: TestUsage(),
|
||||
analytics: NoOpAnalytics(),
|
||||
);
|
||||
|
||||
expect(() => xcodeProjectInterpreter.getInfo(workingDirectory), throwsToolExit(message: stderr));
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/web.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:flutter_tools/src/web/compile.dart';
|
||||
import 'package:flutter_tools/src/web/file_generators/flutter_service_worker_js.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@@ -21,8 +21,9 @@ import '../../src/test_build_system.dart';
|
||||
void main() {
|
||||
late MemoryFileSystem fileSystem;
|
||||
late TestUsage testUsage;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
late BufferLogger logger;
|
||||
late FlutterVersion flutterVersion;
|
||||
late FakeFlutterVersion flutterVersion;
|
||||
late FlutterProject flutterProject;
|
||||
|
||||
setUp(() {
|
||||
@@ -30,6 +31,10 @@ void main() {
|
||||
testUsage = TestUsage();
|
||||
logger = BufferLogger.test();
|
||||
flutterVersion = FakeFlutterVersion(frameworkVersion: '1.0.0', engineRevision: '9.8.7');
|
||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: fileSystem,
|
||||
fakeFlutterVersion: flutterVersion,
|
||||
);
|
||||
|
||||
flutterProject = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
fileSystem.file('.packages').createSync();
|
||||
@@ -65,6 +70,7 @@ void main() {
|
||||
usage: testUsage,
|
||||
flutterVersion: flutterVersion,
|
||||
fileSystem: fileSystem,
|
||||
analytics: fakeAnalytics,
|
||||
);
|
||||
await webBuilder.buildWeb(
|
||||
flutterProject,
|
||||
@@ -103,6 +109,17 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
unorderedEquals(<Event>[
|
||||
Event.flutterBuildInfo(
|
||||
label: 'web-compile',
|
||||
buildType: 'web',
|
||||
settings: 'RunWasmOpt: none; WasmOmitTypeChecks: false; wasm-compile: true; web-renderer: auto;',
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
// Sends timing event.
|
||||
final TestTimingEvent timingEvent = testUsage.timings.single;
|
||||
expect(timingEvent.category, 'build');
|
||||
@@ -128,6 +145,7 @@ void main() {
|
||||
usage: testUsage,
|
||||
flutterVersion: flutterVersion,
|
||||
fileSystem: fileSystem,
|
||||
analytics: fakeAnalytics,
|
||||
);
|
||||
await expectLater(
|
||||
() async => webBuilder.buildWeb(
|
||||
|
||||
Reference in New Issue
Block a user