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() {
MockFlutterDevice mockFlutterDevice;
MockWebDevFS mockWebDevFS;
MockResidentCompiler mockResidentCompiler;
MockChromeConnection mockChromeConnection;
MockChromeTab mockChromeTab;
MockWipConnection mockWipConnection;
MockWipDebugger mockWipDebugger;
FakeChromeConnection chromeConnection;
FakeChromeTab chromeTab;
MockWebServerDevice mockWebServerDevice;
MockDevice mockDevice;
FakeVmServiceHost fakeVmServiceHost;
......@@ -121,10 +119,8 @@ void main() {
mockFlutterDevice = MockFlutterDevice();
mockWebDevFS = MockWebDevFS();
mockResidentCompiler = MockResidentCompiler();
mockChromeConnection = MockChromeConnection();
mockChromeTab = MockChromeTab();
mockWipConnection = MockWipConnection();
mockWipDebugger = MockWipDebugger();
chromeConnection = FakeChromeConnection();
chromeTab = FakeChromeTab('index.html');
mockWebServerDevice = MockWebServerDevice();
when(mockFlutterDevice.devFS).thenReturn(mockWebDevFS);
when(mockFlutterDevice.device).thenReturn(mockDevice);
......@@ -170,13 +166,7 @@ void main() {
when(mockWebDevFS.sources).thenReturn(<Uri>[]);
when(mockWebDevFS.baseUri).thenReturn(Uri.parse('http://localhost:12345'));
when(mockFlutterDevice.generator).thenReturn(mockResidentCompiler);
when(mockChromeConnection.getTab(any)).thenAnswer((Invocation invocation) async {
return mockChromeTab;
});
when(mockChromeTab.connect()).thenAnswer((Invocation invocation) async {
return mockWipConnection;
});
when(mockWipConnection.debugger).thenReturn(mockWipDebugger);
chromeConnection.tabs.add(chromeTab);
}
testUsingContext('runner with web server device does not support debugging without --start-paused', () {
......@@ -546,7 +536,7 @@ void main() {
]);
_setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, mockChromeConnection, chromiumLauncher: chromiumLauncher);
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.instance = chrome;
when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice(
......@@ -620,7 +610,7 @@ void main() {
]);
_setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, mockChromeConnection, chromiumLauncher: chromiumLauncher);
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.instance = chrome;
when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice(
......@@ -992,9 +982,9 @@ void main() {
...kAttachIsolateExpectations,
]);
_setupMocks();
final MockChromeConnection mockChromeConnection = MockChromeConnection();
final FakeChromeConnection chromeConnection = FakeChromeConnection();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, mockChromeConnection, chromiumLauncher: chromiumLauncher);
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.instance = chrome;
when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice(
......@@ -1007,14 +997,8 @@ void main() {
when(mockWebDevFS.create()).thenAnswer((Invocation invocation) async {
return Uri.parse('http://localhost:8765/app/');
});
final MockChromeTab mockChromeTab = MockChromeTab();
final MockWipConnection mockWipConnection = MockWipConnection();
when(mockChromeConnection.getTab(any)).thenAnswer((Invocation invocation) async {
return mockChromeTab;
});
when(mockChromeTab.connect()).thenAnswer((Invocation invocation) async {
return mockWipConnection;
});
final FakeChromeTab chromeTab = FakeChromeTab('index.html');
chromeConnection.tabs.add(chromeTab);
final ResidentWebRunner runner = ResidentWebRunner(
mockFlutterDevice,
......@@ -1201,11 +1185,36 @@ class MockStatus extends Mock implements Status {}
class MockFlutterDevice extends Mock implements FlutterDevice {}
class MockWebDevFS extends Mock implements WebDevFS {}
class MockResidentCompiler extends Mock implements ResidentCompiler {}
class MockChrome extends Mock implements Chromium {}
class MockChromeConnection extends Mock implements ChromeConnection {}
class MockChromeTab extends Mock implements ChromeTab {}
class MockWipConnection extends Mock implements WipConnection {}
class MockWipDebugger extends Mock implements WipDebugger {}
class FakeChromeConnection extends Fake implements ChromeConnection {
final List<ChromeTab> tabs = <ChromeTab>[];
@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 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