Unverified Commit 9218f09d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove some mocks from web resident runner tests (#82522)

parent 496acdf5
...@@ -100,10 +100,8 @@ void main() { ...@@ -100,10 +100,8 @@ void main() {
MockFlutterDevice mockFlutterDevice; MockFlutterDevice mockFlutterDevice;
MockWebDevFS mockWebDevFS; MockWebDevFS mockWebDevFS;
MockResidentCompiler mockResidentCompiler; MockResidentCompiler mockResidentCompiler;
MockChromeConnection mockChromeConnection; FakeChromeConnection chromeConnection;
MockChromeTab mockChromeTab; FakeChromeTab chromeTab;
MockWipConnection mockWipConnection;
MockWipDebugger mockWipDebugger;
MockWebServerDevice mockWebServerDevice; MockWebServerDevice mockWebServerDevice;
MockDevice mockDevice; MockDevice mockDevice;
FakeVmServiceHost fakeVmServiceHost; FakeVmServiceHost fakeVmServiceHost;
...@@ -121,10 +119,8 @@ void main() { ...@@ -121,10 +119,8 @@ void main() {
mockFlutterDevice = MockFlutterDevice(); mockFlutterDevice = MockFlutterDevice();
mockWebDevFS = MockWebDevFS(); mockWebDevFS = MockWebDevFS();
mockResidentCompiler = MockResidentCompiler(); mockResidentCompiler = MockResidentCompiler();
mockChromeConnection = MockChromeConnection(); chromeConnection = FakeChromeConnection();
mockChromeTab = MockChromeTab(); chromeTab = FakeChromeTab('index.html');
mockWipConnection = MockWipConnection();
mockWipDebugger = MockWipDebugger();
mockWebServerDevice = MockWebServerDevice(); mockWebServerDevice = MockWebServerDevice();
when(mockFlutterDevice.devFS).thenReturn(mockWebDevFS); when(mockFlutterDevice.devFS).thenReturn(mockWebDevFS);
when(mockFlutterDevice.device).thenReturn(mockDevice); when(mockFlutterDevice.device).thenReturn(mockDevice);
...@@ -170,13 +166,7 @@ void main() { ...@@ -170,13 +166,7 @@ void main() {
when(mockWebDevFS.sources).thenReturn(<Uri>[]); when(mockWebDevFS.sources).thenReturn(<Uri>[]);
when(mockWebDevFS.baseUri).thenReturn(Uri.parse('http://localhost:12345')); when(mockWebDevFS.baseUri).thenReturn(Uri.parse('http://localhost:12345'));
when(mockFlutterDevice.generator).thenReturn(mockResidentCompiler); when(mockFlutterDevice.generator).thenReturn(mockResidentCompiler);
when(mockChromeConnection.getTab(any)).thenAnswer((Invocation invocation) async { chromeConnection.tabs.add(chromeTab);
return mockChromeTab;
});
when(mockChromeTab.connect()).thenAnswer((Invocation invocation) async {
return mockWipConnection;
});
when(mockWipConnection.debugger).thenReturn(mockWipDebugger);
} }
testUsingContext('runner with web server device does not support debugging without --start-paused', () { testUsingContext('runner with web server device does not support debugging without --start-paused', () {
...@@ -546,7 +536,7 @@ void main() { ...@@ -546,7 +536,7 @@ void main() {
]); ]);
_setupMocks(); _setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, mockChromeConnection, chromiumLauncher: chromiumLauncher); final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.instance = chrome; chromiumLauncher.instance = chrome;
when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice( when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice(
...@@ -620,7 +610,7 @@ void main() { ...@@ -620,7 +610,7 @@ void main() {
]); ]);
_setupMocks(); _setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, mockChromeConnection, chromiumLauncher: chromiumLauncher); final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.instance = chrome; chromiumLauncher.instance = chrome;
when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice( when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice(
...@@ -992,9 +982,9 @@ void main() { ...@@ -992,9 +982,9 @@ void main() {
...kAttachIsolateExpectations, ...kAttachIsolateExpectations,
]); ]);
_setupMocks(); _setupMocks();
final MockChromeConnection mockChromeConnection = MockChromeConnection(); final FakeChromeConnection chromeConnection = FakeChromeConnection();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, mockChromeConnection, chromiumLauncher: chromiumLauncher); final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.instance = chrome; chromiumLauncher.instance = chrome;
when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice( when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice(
...@@ -1007,14 +997,8 @@ void main() { ...@@ -1007,14 +997,8 @@ void main() {
when(mockWebDevFS.create()).thenAnswer((Invocation invocation) async { when(mockWebDevFS.create()).thenAnswer((Invocation invocation) async {
return Uri.parse('http://localhost:8765/app/'); return Uri.parse('http://localhost:8765/app/');
}); });
final MockChromeTab mockChromeTab = MockChromeTab(); final FakeChromeTab chromeTab = FakeChromeTab('index.html');
final MockWipConnection mockWipConnection = MockWipConnection(); chromeConnection.tabs.add(chromeTab);
when(mockChromeConnection.getTab(any)).thenAnswer((Invocation invocation) async {
return mockChromeTab;
});
when(mockChromeTab.connect()).thenAnswer((Invocation invocation) async {
return mockWipConnection;
});
final ResidentWebRunner runner = ResidentWebRunner( final ResidentWebRunner runner = ResidentWebRunner(
mockFlutterDevice, mockFlutterDevice,
...@@ -1201,11 +1185,36 @@ class MockStatus extends Mock implements Status {} ...@@ -1201,11 +1185,36 @@ class MockStatus extends Mock implements Status {}
class MockFlutterDevice extends Mock implements FlutterDevice {} class MockFlutterDevice extends Mock implements FlutterDevice {}
class MockWebDevFS extends Mock implements WebDevFS {} class MockWebDevFS extends Mock implements WebDevFS {}
class MockResidentCompiler extends Mock implements ResidentCompiler {} class MockResidentCompiler extends Mock implements ResidentCompiler {}
class MockChrome extends Mock implements Chromium {}
class MockChromeConnection extends Mock implements ChromeConnection {} class FakeChromeConnection extends Fake implements ChromeConnection {
class MockChromeTab extends Mock implements ChromeTab {} final List<ChromeTab> tabs = <ChromeTab>[];
class MockWipConnection extends Mock implements WipConnection {}
class MockWipDebugger extends Mock implements WipDebugger {} @override
Future<ChromeTab> getTab(bool Function(ChromeTab tab) accept, {Duration retryFor}) async {
return tabs.firstWhere(accept);
}
}
class FakeChromeTab extends Fake implements ChromeTab {
FakeChromeTab(this.url);
@override
final String url;
final FakeWipConnection connection = FakeWipConnection();
@override
Future<WipConnection> connect() async {
return connection;
}
}
class FakeWipConnection extends Fake implements WipConnection {
@override
final WipDebugger debugger = FakeWipDebugger();
}
class FakeWipDebugger extends Fake implements WipDebugger {}
class MockWebServerDevice extends Mock implements WebServerDevice {} class MockWebServerDevice extends Mock implements WebServerDevice {}
class MockDevice extends Mock implements Device {} class MockDevice extends Mock implements Device {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment