Search in sources :

Example 1 with NewModuleDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.NewModuleDialogFixture in project android by JetBrains.

the class DeveloperServicesTest method createGoogleCloudModule.

/**
   * Common code for the Google Cloud Module tests.
   *
   * @param moduleSubtype The value to choose from the "Module Type" drop down.
   * @param sourceFileName The basename of the generated Java file.
   * @param checkForOwnerDomainAndOwnerName true if the test should check for ownerDomain and ownerName Api parameters.
   */
private void createGoogleCloudModule(@NotNull String moduleSubtype, @NotNull String sourceFileName, boolean checkForOwnerDomainAndOwnerName) throws Exception {
    final String moduleName = "backend";
    final String packageName = "com.google.sampleapp.backend";
    final String domainName = "backend.sampleapp.google.com";
    String filePath = String.format("%s/src/main/java/%s/%s", moduleName, packageName.replace(".", "/"), sourceFileName);
    ProjectViewFixture.PaneFixture pane = guiTest.importSimpleApplication().openFromMenu(NewModuleDialogFixture::find, "File", "New", "New Module...").chooseModuleType("Google Cloud Module").clickNextToStep("New Google Cloud Module").chooseModuleSubtype(moduleSubtype).setModuleName(moduleName).setPackageName("com.google.sampleapp.backend").chooseClientModule("app (google.simpleapplication)").clickFinish().waitForGradleProjectSyncToFinish().getProjectView().selectAndroidPane();
    assertThat(pane.hasModuleRootNode(moduleName)).isTrue();
    String fileContents = guiTest.ideFrame().getEditor().open(filePath).getCurrentFileContents();
    assertThat(fileContents).contains("package " + packageName + ";");
    if (checkForOwnerDomainAndOwnerName) {
        assertThat(fileContents).contains("ownerDomain = \"" + domainName + "\"");
        assertThat(fileContents).contains("ownerName = \"" + domainName + "\"");
    }
    ExecutionToolWindowFixture runToolWindow = guiTest.ideFrame().runNonAndroidApp(moduleName).getRunToolWindow();
    runToolWindow.findContent(moduleName).waitForOutput(new PatternTextMatcher(Pattern.compile(".*Dev App Server is now running.*", DOTALL)), 120);
    assertThat(NetUtils.canConnectToRemoteSocket(NetUtils.getLocalHostString(), 8080)).isTrue();
    runToolWindow.findContent(moduleName).stop();
}
Also used : NewModuleDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.NewModuleDialogFixture) ProjectViewFixture(com.android.tools.idea.tests.gui.framework.fixture.ProjectViewFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher) ExecutionToolWindowFixture(com.android.tools.idea.tests.gui.framework.fixture.ExecutionToolWindowFixture)

Aggregations

ExecutionToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.ExecutionToolWindowFixture)1 NewModuleDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.NewModuleDialogFixture)1 ProjectViewFixture (com.android.tools.idea.tests.gui.framework.fixture.ProjectViewFixture)1 PatternTextMatcher (org.fest.swing.util.PatternTextMatcher)1