@@ -17,7 +17,9 @@ import 'package:flutter_tools/src/commands/build.dart';
17
17
import 'package:flutter_tools/src/commands/build_ios.dart' ;
18
18
import 'package:flutter_tools/src/ios/code_signing.dart' ;
19
19
import 'package:flutter_tools/src/ios/mac.dart' ;
20
+ import 'package:flutter_tools/src/ios/plist_parser.dart' ;
20
21
import 'package:flutter_tools/src/ios/xcodeproj.dart' ;
22
+ import 'package:flutter_tools/src/project.dart' ;
21
23
import 'package:flutter_tools/src/reporting/reporting.dart' ;
22
24
import 'package:test/fake.dart' ;
23
25
@@ -438,6 +440,133 @@ void main() {
438
440
Usage : () => usage,
439
441
XcodeProjectInterpreter : () => FakeXcodeProjectInterpreterWithBuildSettings (),
440
442
});
443
+
444
+ group ('Analytics for impeller plist setting' , () {
445
+ const String plistContents = '''
446
+ <?xml version="1.0" encoding="UTF-8"?>
447
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
448
+ <plist version="1.0">
449
+ <dict>
450
+ <key>FLTEnableImpeller</key>
451
+ <false/>
452
+ </dict>
453
+ </plist>
454
+ ''' ;
455
+ const FakeCommand plutilCommand = FakeCommand (
456
+ command: < String > [
457
+ '/usr/bin/plutil' , '-convert' , 'xml1' , '-o' , '-' , '/ios/Runner/Info.plist' ,
458
+ ],
459
+ stdout: plistContents,
460
+ );
461
+
462
+ testUsingContext ('Sends an analytics event when Impeller is enabled' , () async {
463
+ final BuildCommand command = BuildCommand (
464
+ androidSdk: FakeAndroidSdk (),
465
+ buildSystem: TestBuildSystem .all (BuildResult (success: true )),
466
+ fileSystem: MemoryFileSystem .test (),
467
+ logger: BufferLogger .test (),
468
+ osUtils: FakeOperatingSystemUtils (),
469
+ );
470
+ createMinimalMockProjectFiles ();
471
+
472
+ await createTestCommandRunner (command).run (
473
+ const < String > ['build' , 'ios' , '--no-pub' ]
474
+ );
475
+
476
+ expect (usage.events, contains (
477
+ const TestUsageEvent (
478
+ 'build' , 'ios' ,
479
+ label: 'plist-impeller-enabled' ,
480
+ parameters: CustomDimensions (),
481
+ ),
482
+ ));
483
+ }, overrides: < Type , Generator > {
484
+ FileSystem : () => fileSystem,
485
+ ProcessManager : () => FakeProcessManager .list (< FakeCommand > [
486
+ xattrCommand,
487
+ setUpFakeXcodeBuildHandler (onRun: () {
488
+ fileSystem.directory ('build/ios/Release-iphoneos/Runner.app' )
489
+ .createSync (recursive: true );
490
+ }),
491
+ setUpRsyncCommand (onRun: () =>
492
+ fileSystem.file ('build/ios/iphoneos/Runner.app/Frameworks/App.framework/App' )
493
+ ..createSync (recursive: true )
494
+ ..writeAsBytesSync (List <int >.generate (10000 , (int index) => 0 ))),
495
+ ]),
496
+ Platform : () => macosPlatform,
497
+ FileSystemUtils : () => FileSystemUtils (
498
+ fileSystem: fileSystem,
499
+ platform: macosPlatform,
500
+ ),
501
+ Usage : () => usage,
502
+ XcodeProjectInterpreter : () => FakeXcodeProjectInterpreterWithBuildSettings (),
503
+ });
504
+
505
+ testUsingContext ('Sends an analytics event when Impeller is disabled' , () async {
506
+ final BuildCommand command = BuildCommand (
507
+ androidSdk: FakeAndroidSdk (),
508
+ buildSystem: TestBuildSystem .all (BuildResult (success: true )),
509
+ fileSystem: fileSystem,
510
+ logger: BufferLogger .test (),
511
+ osUtils: FakeOperatingSystemUtils (),
512
+ );
513
+ createMinimalMockProjectFiles ();
514
+
515
+ fileSystem.file (
516
+ fileSystem.path.join ('usr' , 'bin' , 'plutil' ),
517
+ ).createSync (recursive: true );
518
+
519
+ final File infoPlist = fileSystem.file (fileSystem.path.join (
520
+ 'ios' , 'Runner' , 'Info.plist' ,
521
+ ))..createSync (recursive: true );
522
+
523
+ infoPlist.writeAsStringSync (plistContents);
524
+
525
+ await createTestCommandRunner (command).run (
526
+ const < String > ['build' , 'ios' , '--no-pub' ]
527
+ );
528
+
529
+ expect (usage.events, contains (
530
+ const TestUsageEvent (
531
+ 'build' , 'ios' ,
532
+ label: 'plist-impeller-disabled' ,
533
+ parameters: CustomDimensions (),
534
+ ),
535
+ ));
536
+ }, overrides: < Type , Generator > {
537
+ FileSystem : () => fileSystem,
538
+ ProcessManager : () => FakeProcessManager .list (< FakeCommand > [
539
+ xattrCommand,
540
+ setUpFakeXcodeBuildHandler (onRun: () {
541
+ fileSystem.directory ('build/ios/Release-iphoneos/Runner.app' )
542
+ .createSync (recursive: true );
543
+ }),
544
+ setUpRsyncCommand (onRun: () =>
545
+ fileSystem.file ('build/ios/iphoneos/Runner.app/Frameworks/App.framework/App' )
546
+ ..createSync (recursive: true )
547
+ ..writeAsBytesSync (List <int >.generate (10000 , (int index) => 0 ))),
548
+ ]),
549
+ Platform : () => macosPlatform,
550
+ FileSystemUtils : () => FileSystemUtils (
551
+ fileSystem: fileSystem,
552
+ platform: macosPlatform,
553
+ ),
554
+ Usage : () => usage,
555
+ XcodeProjectInterpreter : () => FakeXcodeProjectInterpreterWithBuildSettings (),
556
+ FlutterProjectFactory : () => FlutterProjectFactory (
557
+ fileSystem: fileSystem,
558
+ logger: BufferLogger .test (),
559
+ ),
560
+ PlistParser : () => PlistParser (
561
+ fileSystem: fileSystem,
562
+ logger: BufferLogger .test (),
563
+ processManager: FakeProcessManager .list (< FakeCommand > [
564
+ plutilCommand, plutilCommand, plutilCommand,
565
+ ]),
566
+ ),
567
+ });
568
+ });
569
+
441
570
group ('xcresults device' , () {
442
571
testUsingContext ('Trace error if xcresult is empty.' , () async {
443
572
final BuildCommand command = BuildCommand (
0 commit comments