@@ -1317,6 +1317,59 @@ flutter:
1317
1317
ProcessManager : () => processManager,
1318
1318
});
1319
1319
1320
+ testUsingContext ('Turns HttpException from ChromeTab::connect into ToolExit' , () async {
1321
+ final BufferLogger logger = BufferLogger .test ();
1322
+ final ResidentRunner residentWebRunner = setUpResidentRunner (
1323
+ flutterDevice,
1324
+ logger: logger,
1325
+ );
1326
+ fakeVmServiceHost = FakeVmServiceHost (requests: < VmServiceExpectation > []);
1327
+ setupMocks ();
1328
+ final FakeChromeConnection chromeConnection = FakeChromeConnection ();
1329
+ final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher ();
1330
+ final FakeProcess process = FakeProcess ();
1331
+ final Chromium chrome = Chromium (
1332
+ 1 ,
1333
+ chromeConnection,
1334
+ chromiumLauncher: chromiumLauncher,
1335
+ process: process,
1336
+ logger: logger,
1337
+ );
1338
+ chromiumLauncher.setInstance (chrome);
1339
+
1340
+ flutterDevice.device = GoogleChromeDevice (
1341
+ fileSystem: fileSystem,
1342
+ chromiumLauncher: chromiumLauncher,
1343
+ logger: logger,
1344
+ platform: FakePlatform (),
1345
+ processManager: FakeProcessManager .any (),
1346
+ );
1347
+ webDevFS.baseUri = Uri .parse ('http://localhost:8765/app/' );
1348
+
1349
+ final FakeChromeTab chromeTab = FakeChromeTab (
1350
+ 'index.html' ,
1351
+ connectException: HttpException (
1352
+ 'Connection closed before full header was received' ,
1353
+ uri: Uri (
1354
+ path: 'http://localhost:50094/devtools/page/3036A94908353E86E183B6A40F54104B' ,
1355
+ ),
1356
+ ),
1357
+ );
1358
+ chromeConnection.tabs.add (chromeTab);
1359
+
1360
+ await expectLater (
1361
+ residentWebRunner.run,
1362
+ throwsToolExit (
1363
+ message: 'Failed to establish connection with the application instance in Chrome.' ,
1364
+ ),
1365
+ );
1366
+ expect (logger.errorText, contains ('HttpException' ));
1367
+ expect (fakeVmServiceHost.hasRemainingExpectations, isFalse);
1368
+ }, overrides: < Type , Generator > {
1369
+ FileSystem : () => fileSystem,
1370
+ ProcessManager : () => processManager,
1371
+ });
1372
+
1320
1373
testUsingContext ('Successfully turns AppConnectionException into ToolExit' ,
1321
1374
() async {
1322
1375
final ResidentRunner residentWebRunner = setUpResidentRunner (flutterDevice);
@@ -1596,14 +1649,21 @@ class FakeChromeConnection extends Fake implements ChromeConnection {
1596
1649
}
1597
1650
1598
1651
class FakeChromeTab extends Fake implements ChromeTab {
1599
- FakeChromeTab (this .url);
1652
+ FakeChromeTab (this .url, {
1653
+ Exception ? connectException,
1654
+ }): _connectException = connectException;
1600
1655
1601
1656
@override
1602
1657
final String url;
1658
+
1659
+ final Exception ? _connectException;
1603
1660
final FakeWipConnection connection = FakeWipConnection ();
1604
1661
1605
1662
@override
1606
1663
Future <WipConnection > connect ({Function ? onError}) async {
1664
+ if (_connectException != null ) {
1665
+ throw _connectException;
1666
+ }
1607
1667
return connection;
1608
1668
}
1609
1669
}
0 commit comments