Search in sources :

Example 6 with FlutterView

use of io.flutter.view.FlutterView in project flutter-intellij by flutter.

the class FlutterViewTest method testWaitForJxBrowserInstallationWithoutTimeout.

@Test
public void testWaitForJxBrowserInstallationWithoutTimeout() throws TimeoutException {
    when(mockJxBrowserManager.getStatus()).thenReturn(JxBrowserStatus.INSTALLATION_IN_PROGRESS);
    when(mockJxBrowserManager.waitForInstallation(INSTALLATION_WAIT_LIMIT_SECONDS)).thenReturn(JxBrowserStatus.INSTALLATION_FAILED);
    // If waiting for JxBrowser installation completes without timing out, then we should return to event thread.
    final FlutterView flutterView = new FlutterView(mockProject, mockJxBrowserManager, mockUtils, mockInspectorGroupManagerService, mockBusConnection);
    final FlutterView spy = spy(flutterView);
    doNothing().when(spy).handleUpdatedJxBrowserStatusOnEventThread(any(), any(), any(), any());
    spy.waitForJxBrowserInstallation(mockApp, mockInspectorService, mockToolWindow);
    verify(spy, times(1)).handleUpdatedJxBrowserStatusOnEventThread(mockApp, mockInspectorService, mockToolWindow, JxBrowserStatus.INSTALLATION_FAILED);
}
Also used : FlutterView(io.flutter.view.FlutterView) Test(org.junit.Test)

Example 7 with FlutterView

use of io.flutter.view.FlutterView in project flutter-intellij by flutter.

the class FlutterViewTest method testHandleJxBrowserInstallationInProgressWaiting.

@Test
public void testHandleJxBrowserInstallationInProgressWaiting() {
    when(mockJxBrowserManager.getStatus()).thenReturn(JxBrowserStatus.INSTALLATION_IN_PROGRESS);
    // If the JxBrowser installation is in progress and is not finished on the first re-check, we should start a thread to wait for the
    // installation to finish.
    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).startJxBrowserInstallationWaitingThread(any(), any(), any());
    spy.handleJxBrowserInstallationInProgress(mockApp, mockInspectorService, mockToolWindow);
    verify(spy, times(1)).presentOpenDevToolsOptionWithMessage(mockApp, mockInspectorService, mockToolWindow, INSTALLATION_IN_PROGRESS_LABEL);
    verify(spy, times(1)).startJxBrowserInstallationWaitingThread(mockApp, mockInspectorService, mockToolWindow);
}
Also used : FlutterView(io.flutter.view.FlutterView) Test(org.junit.Test)

Example 8 with FlutterView

use of io.flutter.view.FlutterView in project flutter-intellij by flutter.

the class FlutterViewTest method testHandleUpdatedJxBrowserStatusWithSuccess.

@Test
public void testHandleUpdatedJxBrowserStatusWithSuccess() {
    // 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.INSTALLED);
    partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockInspectorService, mockToolWindow, JxBrowserStatus.INSTALLED);
    verify(partialMockFlutterView, times(1)).handleJxBrowserInstalled(mockApp, mockInspectorService, mockToolWindow);
}
Also used : FlutterView(io.flutter.view.FlutterView) Test(org.junit.Test)

Example 9 with FlutterView

use of io.flutter.view.FlutterView in project flutter-intellij by flutter.

the class FlutterViewTest method testHandleUpdatedJxBrowserStatusWithOtherstatus.

@Test
public void testHandleUpdatedJxBrowserStatusWithOtherstatus() {
    // If waiting for JxBrowser installation completes with any other status, then we should recommend opening non-embedded DevTools.
    final FlutterView partialMockFlutterView = mock(FlutterView.class);
    doCallRealMethod().when(partialMockFlutterView).handleUpdatedJxBrowserStatus(mockApp, mockInspectorService, mockToolWindow, JxBrowserStatus.NOT_INSTALLED);
    partialMockFlutterView.handleUpdatedJxBrowserStatus(mockApp, mockInspectorService, mockToolWindow, JxBrowserStatus.NOT_INSTALLED);
    verify(partialMockFlutterView, times(1)).presentOpenDevToolsOptionWithMessage(mockApp, mockInspectorService, mockToolWindow, INSTALLATION_WAIT_FAILED);
}
Also used : FlutterView(io.flutter.view.FlutterView) Test(org.junit.Test)

Aggregations

FlutterView (io.flutter.view.FlutterView)9 Test (org.junit.Test)9 InstallationFailedReason (io.flutter.jxbrowser.InstallationFailedReason)1 JxBrowserUtils (io.flutter.utils.JxBrowserUtils)1 TimeoutException (java.util.concurrent.TimeoutException)1 Ignore (org.junit.Ignore)1