@@ -49,6 +49,7 @@ void main() {
49
49
MockChromeTab mockChromeTab;
50
50
MockWipConnection mockWipConnection;
51
51
MockWipDebugger mockWipDebugger;
52
+ MockWebServerDevice mockWebServerDevice;
52
53
bool didSkipDwds;
53
54
54
55
setUp (() {
@@ -66,6 +67,7 @@ void main() {
66
67
mockChromeTab = MockChromeTab ();
67
68
mockWipConnection = MockWipConnection ();
68
69
mockWipDebugger = MockWipDebugger ();
70
+ mockWebServerDevice = MockWebServerDevice ();
69
71
when (mockFlutterDevice.device).thenReturn (mockChromeDevice);
70
72
testbed = Testbed (
71
73
setup: () {
@@ -429,6 +431,49 @@ void main() {
429
431
FeatureFlags : () => TestFeatureFlags (isWebIncrementalCompilerEnabled: true ),
430
432
}));
431
433
434
+ test ('Can hot restart after attaching - experimental with web-server device' , () => testbed.run (() async {
435
+ _setupMocks ();
436
+ when (mockFlutterDevice.device).thenReturn (mockWebServerDevice);
437
+ when (mockWebDevFS.update (
438
+ mainPath: anyNamed ('mainPath' ),
439
+ target: anyNamed ('target' ),
440
+ bundle: anyNamed ('bundle' ),
441
+ firstBuildTime: anyNamed ('firstBuildTime' ),
442
+ bundleFirstUpload: anyNamed ('bundleFirstUpload' ),
443
+ generator: anyNamed ('generator' ),
444
+ fullRestart: anyNamed ('fullRestart' ),
445
+ dillOutputPath: anyNamed ('dillOutputPath' ),
446
+ trackWidgetCreation: anyNamed ('trackWidgetCreation' ),
447
+ projectRootPath: anyNamed ('projectRootPath' ),
448
+ pathToReload: anyNamed ('pathToReload' ),
449
+ invalidatedFiles: anyNamed ('invalidatedFiles' ),
450
+ )).thenAnswer ((Invocation invocation) async {
451
+ return UpdateFSReport (success: true )
452
+ ..invalidatedModules = < String > ['example' ];
453
+ });
454
+ final Completer <DebugConnectionInfo > connectionInfoCompleter = Completer <DebugConnectionInfo >();
455
+ unawaited (residentWebRunner.run (
456
+ connectionInfoCompleter: connectionInfoCompleter,
457
+ ));
458
+ await connectionInfoCompleter.future;
459
+ final OperationResult result = await residentWebRunner.restart (fullRestart: true );
460
+
461
+ expect (testLogger.statusText, contains ('Restarted application in' ));
462
+ expect (result.code, 0 );
463
+ verify (mockResidentCompiler.accept ()).called (2 );
464
+ // ensure that analytics are sent.
465
+ verify (Usage .instance.sendEvent ('hot' , 'restart' , parameters: < String , String > {
466
+ 'cd27' : 'web-javascript' ,
467
+ 'cd28' : null ,
468
+ 'cd29' : 'false' ,
469
+ 'cd30' : 'true' ,
470
+ })).called (1 );
471
+ verifyNever (Usage .instance.sendTiming ('hot' , 'web-incremental-restart' , any));
472
+ }, overrides: < Type , Generator > {
473
+ Usage : () => MockFlutterUsage (),
474
+ FeatureFlags : () => TestFeatureFlags (isWebIncrementalCompilerEnabled: true ),
475
+ }));
476
+
432
477
test ('Can hot restart after attaching' , () => testbed.run (() async {
433
478
_setupMocks ();
434
479
final Completer <DebugConnectionInfo > connectionInfoCompleter = Completer <DebugConnectionInfo >();
@@ -460,6 +505,21 @@ void main() {
460
505
Usage : () => MockFlutterUsage (),
461
506
}));
462
507
508
+ test ('Selects Dwds runner in profile mode with incremental compiler enabled' , () => testbed.run (() async {
509
+ final ResidentWebRunner residentWebRunner = DwdsWebRunnerFactory ().createWebRunner (
510
+ mockFlutterDevice,
511
+ flutterProject: FlutterProject .current (),
512
+ debuggingOptions: DebuggingOptions .enabled (BuildInfo .profile),
513
+ ipv6: true ,
514
+ stayResident: true ,
515
+ dartDefines: const < String > [],
516
+ ) as ResidentWebRunner ;
517
+
518
+ expect (residentWebRunner.runtimeType.toString (), '_DwdsResidentWebRunner' );
519
+ }, overrides: < Type , Generator > {
520
+ FeatureFlags : () => TestFeatureFlags (isWebIncrementalCompilerEnabled: true ),
521
+ }));
522
+
463
523
test ('Fails on compilation errors in hot restart' , () => testbed.run (() async {
464
524
_setupMocks ();
465
525
final Completer <DebugConnectionInfo > connectionInfoCompleter = Completer <DebugConnectionInfo >();
@@ -1022,3 +1082,4 @@ class MockChromeTab extends Mock implements ChromeTab {}
1022
1082
class MockWipConnection extends Mock implements WipConnection {}
1023
1083
class MockWipDebugger extends Mock implements WipDebugger {}
1024
1084
class MockLogger extends Mock implements Logger {}
1085
+ class MockWebServerDevice extends Mock implements WebServerDevice {}
0 commit comments