use of org.fest.swing.util.PatternTextMatcher 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();
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class LaunchAndroidApplicationTest method testDebugOnEmulator.
@Ignore("http://b/30795134")
@Test
public void testDebugOnEmulator() throws IOException, ClassNotFoundException, EvaluateException {
guiTest.importSimpleApplication();
createAVD();
IdeFrameFixture ideFrameFixture = guiTest.ideFrame();
ideFrameFixture.debugApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
// Make sure the right app is being used. This also serves as the sync point for the package to get uploaded to the device/emulator.
ideFrameFixture.getDebugToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(LOCAL_PATH_OUTPUT), 120);
ideFrameFixture.getDebugToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(DEBUG_OUTPUT), 120);
ideFrameFixture.getAndroidToolWindow().selectDevicesTab().selectProcess(PROCESS_NAME).clickTerminateApplication();
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class GradleTasksTest method testNotFinishedImmediatelyAndOutputIsShown.
@Test
public void testNotFinishedImmediatelyAndOutputIsShown() throws IOException {
// This test checks two things:
// 1. There was a problem that every time a gradle task was started from IDE corresponding run/debug tool window
// was shown and after that it's state was changed as the task was already finished (though actual execution
// continued). That was because task execution was delegated to a background thread and IDE run configuration
// infrastructure considered the task to be finished because control flow had returned;
// 2. Gradle tasks are executed via our custom gradle task extension. The problem was that corresponding
// run/debug tool window content was not populated by the task output;
openProjectAndAddToGradleConfig("\n" + "\n" + "task('hello') << {\n" + " 10.times {\n" + " logger.lifecycle('output entry ' + it)\n" + " Thread.sleep(1000)\n" + " }\n" + "}");
// Run that long-running task
String taskName = "hello";
runTask(taskName, runContent -> {
for (int i = 0; i < 7; i++) {
runContent.waitForOutput(new PatternTextMatcher(Pattern.compile(".*output entry " + i + ".*", DOTALL)), 2);
assertTrue(runContent.isExecutionInProgress());
}
Wait.seconds(10).expecting("task execution to finish").until(() -> !runContent.isExecutionInProgress());
});
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class GradleTasksTest method runTask.
private void runTask(@NotNull String taskName, @NotNull Consumer<ExecutionToolWindowFixture.ContentFixture> closure) {
GradleToolWindowFixture gradleToolWindow = guiTest.ideFrame().getGradleToolWindow();
gradleToolWindow.runTask(taskName);
// Ensure that task output is shown and updated.
String regex = ".*SimpleApplication \\[" + taskName + "\\].*";
PatternTextMatcher matcher = new PatternTextMatcher(Pattern.compile(regex, DOTALL));
closure.consume(guiTest.ideFrame().getRunToolWindow().findContent(matcher));
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class InstantRunTest method hotSwap.
/**
* Verifies that instant run hot swap works as expected.
* <p>
* This is run to qualify releases. Please involve the test team in substantial changes.
* <p>
* TR ID: C14581583
* <p>
* <pre>
* Test Steps:
* 1. Import SimpleApplication.
* 2. Update the gradle plugin version if necessary for testing purpose.
* 3. Create an AVD with a system image API 21 or above.
* 4. Run on the AVD
* 5. Verify 1.
* 6. Edit a java file.
* 7. Run again.
* 8. Verify 2.
* Verify:
* 1. Make sure the right app is installed and started in Run tool window.
* 2. Make sure the instant run hot swap is applied in Run tool window.
* </pre>
*/
@RunIn(TestGroup.QA)
@Test
public void hotSwap() throws Exception {
IdeFrameFixture ideFrameFixture = guiTest.importSimpleApplication();
updateGradleVersion(guiTest.getProjectPath());
createAVD();
ideFrameFixture.runApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
ideFrameFixture.getEditor().open("app/src/main/java/google/simpleapplication/MyActivity.java").enterText(Strings.repeat("\n", 10));
ideFrameFixture.waitForGradleProjectSyncToFinish().findRunApplicationButton().click();
ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(HOT_SWAP_OUTPUT), 120);
}
Aggregations