use of io.flutter.view.FlutterView in project flutter-intellij by flutter.
the class FlutterViewTest method testHandleUpdatedJxBrowserStatusWithFailure.
@Test
public void testHandleUpdatedJxBrowserStatusWithFailure() {
// If waiting for JxBrowser installation completes with failure, then we should redirect to the function that handles failure.
final FlutterView partialMockFlutterView = mock(FlutterView.class);
doCallRealMethod().when(partialMockFlutterView).handleUpdatedJxBrowserStatus(mockApp, mockInspectorService, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED);
partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockInspectorService, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED);
verify(partialMockFlutterView, times(1)).handleJxBrowserInstallationFailed(mockApp, mockInspectorService, mockToolWindow);
}
use of io.flutter.view.FlutterView in project flutter-intellij by flutter.
the class FlutterViewTest method testHandleJxBrowserInstallationInProgressWithSuccessfulInstall.
@Test
public void testHandleJxBrowserInstallationInProgressWithSuccessfulInstall() {
when(mockJxBrowserManager.getStatus()).thenReturn(JxBrowserStatus.INSTALLED);
// If the JxBrowser installation is initially in progress, we should show a message about the installation.
// If the installation quickly finishes (on the first re-check), then we should call the function to handle successful installation.
final FlutterView flutterView = new FlutterView(mockProject, mockJxBrowserManager, mockUtils, mockInspectorGroupManagerService, mockBusConnection);
final FlutterView spy = spy(flutterView);
doNothing().when(spy).presentOpenDevToolsOptionWithMessage(any(), any(), any(), any());
doNothing().when(spy).handleJxBrowserInstalled(any(), any(), any());
spy.handleJxBrowserInstallationInProgress(mockApp, mockInspectorService, mockToolWindow);
verify(spy, times(1)).presentOpenDevToolsOptionWithMessage(mockApp, mockInspectorService, mockToolWindow, INSTALLATION_IN_PROGRESS_LABEL);
verify(spy, times(1)).handleJxBrowserInstalled(mockApp, mockInspectorService, mockToolWindow);
}
use of io.flutter.view.FlutterView in project flutter-intellij by flutter.
the class FlutterViewTest method testWaitForJxBrowserInstallationWithTimeout.
@Ignore
@Test
public void testWaitForJxBrowserInstallationWithTimeout() throws TimeoutException {
when(mockJxBrowserManager.getStatus()).thenReturn(JxBrowserStatus.INSTALLATION_IN_PROGRESS);
when(mockJxBrowserManager.waitForInstallation(INSTALLATION_WAIT_LIMIT_SECONDS)).thenThrow(new TimeoutException());
// If the JxBrowser installation doesn't complete on time, we should show a timed out message.
final FlutterView flutterView = new FlutterView(mockProject, mockJxBrowserManager, mockUtils, mockInspectorGroupManagerService, mockBusConnection);
final FlutterView spy = spy(flutterView);
doNothing().when(spy).presentOpenDevToolsOptionWithMessage(any(), any(), any(), any());
spy.waitForJxBrowserInstallation(mockApp, mockInspectorService, mockToolWindow);
verify(spy, times(1)).presentOpenDevToolsOptionWithMessage(mockApp, mockInspectorService, mockToolWindow, INSTALLATION_TIMED_OUT_LABEL);
}
use of io.flutter.view.FlutterView in project flutter-intellij by flutter.
the class FlutterViewTest method testHandleJxBrowserInstallationFailed.
@Test
public void testHandleJxBrowserInstallationFailed() {
final JxBrowserUtils mockJxBrowserUtils = mock(JxBrowserUtils.class);
when(mockJxBrowserUtils.licenseIsSet()).thenReturn(true);
when(mockJxBrowserManager.getLatestFailureReason()).thenReturn(new InstallationFailedReason(FailureType.FILE_DOWNLOAD_FAILED));
// If JxBrowser failed to install, we should show a failure message that allows the user to manually retry.
final FlutterView flutterView = new FlutterView(mockProject, mockJxBrowserManager, mockJxBrowserUtils, mockInspectorGroupManagerService, mockBusConnection);
final FlutterView spy = spy(flutterView);
doNothing().when(spy).presentClickableLabel(eq(mockToolWindow), anyList());
spy.handleJxBrowserInstallationFailed(mockApp, mockInspectorService, mockToolWindow);
verify(spy, times(1)).presentClickableLabel(eq(mockToolWindow), anyList());
}
use of io.flutter.view.FlutterView in project flutter-intellij by flutter.
the class FlutterViewTest method testHandleJxBrowserInstalled.
@Test
public void testHandleJxBrowserInstalled() {
// If JxBrowser has been installed, we should use the DevTools instance to open the embedded browser.
final FlutterView partialMockFlutterView = mock(FlutterView.class);
doCallRealMethod().when(partialMockFlutterView).handleJxBrowserInstalled(mockApp, mockInspectorService, mockToolWindow);
partialMockFlutterView.handleJxBrowserInstalled(mockApp, mockInspectorService, mockToolWindow);
verify(partialMockFlutterView, times(1)).openInspectorWithDevTools(mockApp, mockInspectorService, mockToolWindow, true);
verify(partialMockFlutterView, times(1)).setUpToolWindowListener(mockApp, mockInspectorService, mockToolWindow, true);
}
Aggregations