Commit d88e692
authored
fix test
Fixes flutter#154857.
Does so by:
* adding `await chromiumLauncher.connect(chrome, false);` before the `close` call to make sure we enter[ the block ](https://github.com/flutter/flutter/blob/9cd2fc90af406a5ae798a6e099f3fca3eebd0da0/packages/flutter_tools/lib/src/web/chrome.dart#L521-L535)that actually tries to close chromium
* adding an `onGetTab` callback to `FakeChromeConnectionWithTab`, which the test now uses to throw a StateError upon `getTab` getting called.
## How I verified this change
1. Change `Chromium.close` from using the safer `getChromeTabGuarded` function to using the previous method of calling `ChromeConnection.getTab` directly. Do so by applying this diff:
```diff
diff --git a/packages/flutter_tools/lib/src/web/chrome.dart b/packages/flutter_tools/lib/src/web/chrome.dart
index c9a5fda..81bc246ff9 100644
--- a/packages/flutter_tools/lib/src/web/chrome.dart
+++ b/packages/flutter_tools/lib/src/web/chrome.dart
@@ -520,7 +520,7 @@ class Chromium {
Duration sigtermDelay = Duration.zero;
if (_hasValidChromeConnection) {
try {
- final ChromeTab? tab = await getChromeTabGuarded(chromeConnection,
+ final ChromeTab? tab = await chromeConnection.getTab(
(_) => true, retryFor: const Duration(seconds: 1));
if (tab != null) {
final WipConnection wipConnection = await tab.connect();
```
2. Then, run the test, which should correctly fail:
```
dart test test/web.shard/chrome_test.dart --name="chrome.close can recover if getTab throws a StateError"`
```
3. Revert the change from step 1 and run again. The test should now pass.chrome.close can recover if getTab throws a StateError (flutter#154889)1 parent 24d0b1d commit d88e692
1 file changed
+19
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
800 | 800 | | |
801 | 801 | | |
802 | 802 | | |
803 | | - | |
804 | | - | |
805 | | - | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
| |||
813 | 814 | | |
814 | 815 | | |
815 | 816 | | |
816 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
817 | 825 | | |
818 | 826 | | |
819 | 827 | | |
| |||
944 | 952 | | |
945 | 953 | | |
946 | 954 | | |
947 | | - | |
948 | | - | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
949 | 960 | | |
950 | 961 | | |
| 962 | + | |
951 | 963 | | |
952 | 964 | | |
953 | 965 | | |
954 | 966 | | |
| 967 | + | |
955 | 968 | | |
956 | 969 | | |
957 | 970 | | |
| |||
0 commit comments