use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class FlavorsExecutionTest method runBuildFlavors.
/***
* To verify that the selected app flavor activity can be launched using build variants
* <p>This is run to qualify releases. Please involve the test team in substantial changes.
* <p>TR ID: C14578811
* <pre>
* Test Steps:
* 1. Create a new project
* 2. Open Project Structure Dialog
* 3. Select app module, add two new flavors (Flavor1 and Flavor2)
* 4. Switch to Project View
* 5. Select app
* 6. Add launcher activities under Flavor1 and Flavor2 and name them F1_Main_Activity and F2_Main_Activity
* 7. Open Build variants window and select flavor1Debug
* 8. Deploy the project on an AVD (Verify 1)
* 9. Select flavor2Debug from Build variants
* 10. Deploy the project on an AVD (Verify 2)
* Verification:
* 1. Verify in Android Run tool window for the launch of F1_Main_Activity
* 2. Verify in Android Run tool window for the launch of F2_Main_Activity
* </pre>
*/
@Ignore("http://b/30795134")
@RunIn(TestGroup.QA)
@Test
public void runBuildFlavors() throws Exception {
guiTest.ideFrame().openFromMenu(ProjectStructureDialogFixture::find, "File", "Project Structure...").selectConfigurable("app").selectFlavorsTab().clickAddButton().setFlavorName("flavor1").clickAddButton().setFlavorName("flavor2").clickOk();
guiTest.ideFrame().getProjectView().selectProjectPane().selectByPath("SimpleApplication", "app");
guiTest.ideFrame().openFromMenu(NewActivityWizardFixture::find, "File", "New", "Activity", "Basic Activity").getConfigureActivityStep().enterTextFieldValue(ConfigureBasicActivityStepFixture.ActivityTextField.NAME, FIRST_ACTIVITY_NAME).enterTextFieldValue(ConfigureBasicActivityStepFixture.ActivityTextField.LAYOUT, "activity_f1_main").selectLauncherActivity().setTargetSourceSet("flavor1").clickFinish().waitForGradleProjectSyncToFinish();
guiTest.ideFrame().getProjectView().selectProjectPane().selectByPath("SimpleApplication", "app");
guiTest.ideFrame().openFromMenu(NewActivityWizardFixture::find, "File", "New", "Activity", "Basic Activity").getConfigureActivityStep().enterTextFieldValue(ConfigureBasicActivityStepFixture.ActivityTextField.NAME, SECOND_ACTIVITY_NAME).enterTextFieldValue(ConfigureBasicActivityStepFixture.ActivityTextField.LAYOUT, "activity_f2_main").selectLauncherActivity().setTargetSourceSet("flavor2").clickFinish().waitForGradleProjectSyncToFinish();
guiTest.ideFrame().getBuildVariantsWindow().selectVariantForModule("app", "flavor1Debug");
guiTest.ideFrame().runApp("app").selectDevice(AVD_NAME).clickOk();
guiTest.ideFrame().getRunToolWindow().findContent("app").waitForOutput(new PatternTextMatcher(Pattern.compile(ACTIVITY_OUTPUT_PATTERN.replace("Main_Activity", FIRST_ACTIVITY_NAME))), 120);
guiTest.ideFrame().getAndroidToolWindow().selectDevicesTab().selectProcess(PROCESS_NAME).clickTerminateApplication();
guiTest.ideFrame().getBuildVariantsWindow().selectVariantForModule("app", "flavor2Debug");
guiTest.ideFrame().runApp("app").selectDevice(AVD_NAME).clickOk();
guiTest.ideFrame().getRunToolWindow().findContent("app").waitForOutput(new PatternTextMatcher(Pattern.compile(ACTIVITY_OUTPUT_PATTERN.replace("Main_Activity", SECOND_ACTIVITY_NAME))), 120);
guiTest.ideFrame().getAndroidToolWindow().selectDevicesTab().selectProcess(PROCESS_NAME).clickTerminateApplication();
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class InstantRunTest method changeManifest.
/**
* Verifies that instant run works as expected when AndroidManifest is changed.
* <p>
* This is run to qualify releases. Please involve the test team in substantial changes.
* <p>
* TR ID: C14581585
* <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 AndroidManifest.
* 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 is applied in EventLog tool window.
* </pre>
*/
@RunIn(TestGroup.QA)
@Test
public void changeManifest() 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/AndroidManifest.xml", EditorFixture.Tab.EDITOR).moveBetween("", "<application").enterText("<uses-permission android:name=\"android.permission.INTERNET\" /\n");
ideFrameFixture.waitForGradleProjectSyncToFinish().findRunApplicationButton().click();
ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
Wait.seconds(1).expecting("The notification is showing").until(() -> {
try {
Notification notification = Iterables.getLast(EventLog.getLogModel(ideFrameFixture.getProject()).getNotifications());
assertThat(notification.getContent()).matches(INSTANT_RUN_NOTIFICATION_REGEX);
return true;
} catch (Exception e) {
System.out.println(e.getClass().toString());
return false;
}
});
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class InstantRunTest method coldSwap.
/**
* Verifies that instant run cold swap works as expected.
* <p>
* This is run to qualify releases. Please involve the test team in substantial changes.
* <p>
* TR ID: C14581584
* <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 resource xml 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 cold swap is applied in Run tool window.
* </pre>
*/
@RunIn(TestGroup.QA)
@Test
public void coldSwap() 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/res/layout/activity_my.xml", EditorFixture.Tab.DESIGN).getLayoutEditor(false).dragComponentToSurface("Widgets", "TextView").waitForRenderToFinish();
ideFrameFixture.waitForGradleProjectSyncToFinish().findRunApplicationButton().click();
ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(COLD_SWAP_OUTPUT), 120);
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class BasicNativeDebuggerTest method testMultiBreakAndResume.
@Test
public void testMultiBreakAndResume() throws IOException, ClassNotFoundException {
guiTest.importProjectAndWaitForProjectSyncToFinish("BasicJniApp");
createAVD();
final IdeFrameFixture projectFrame = guiTest.ideFrame();
// Setup breakpoints
final String[] breakPoints = { "return sum;", "return product;", "return quotient;", "return (*env)->NewStringUTF(env, message);" };
openAndToggleBreakPoints("app/src/main/jni/multifunction-jni.c", breakPoints);
// Setup the expected patterns to match the variable values displayed in Debug windows's 'Variables' tab.
final Map<String, String[]> breakpointToExpectedPatterns = new HashMap<>();
breakpointToExpectedPatterns.put(breakPoints[0], new String[] { variableToSearchPattern("x1", "int", "1"), variableToSearchPattern("x2", "int", "2"), variableToSearchPattern("x3", "int", "3"), variableToSearchPattern("x4", "int", "4"), variableToSearchPattern("x5", "int", "5"), variableToSearchPattern("x6", "int", "6"), variableToSearchPattern("x7", "int", "7"), variableToSearchPattern("x8", "int", "8"), variableToSearchPattern("x9", "int", "9"), variableToSearchPattern("x10", "int", "10"), variableToSearchPattern("sum", "int", "55") });
breakpointToExpectedPatterns.put(breakPoints[1], new String[] { variableToSearchPattern("x1", "int", "1"), variableToSearchPattern("x2", "int", "2"), variableToSearchPattern("x3", "int", "3"), variableToSearchPattern("x4", "int", "4"), variableToSearchPattern("x5", "int", "5"), variableToSearchPattern("x6", "int", "6"), variableToSearchPattern("x7", "int", "7"), variableToSearchPattern("x8", "int", "8"), variableToSearchPattern("x9", "int", "9"), variableToSearchPattern("x10", "int", "10"), variableToSearchPattern("product", "int", "3628800") });
breakpointToExpectedPatterns.put(breakPoints[2], new String[] { variableToSearchPattern("x1", "int", "1024"), variableToSearchPattern("x2", "int", "2"), variableToSearchPattern("quotient", "int", "512") });
breakpointToExpectedPatterns.put(breakPoints[3], new String[] { variableToSearchPattern("sum_of_10_ints", "int", "55"), variableToSearchPattern("product_of_10_ints", "int", "3628800"), variableToSearchPattern("quotient", "int", "512") });
projectFrame.debugApp(DEBUG_CONFIG_NAME).selectDevice(AVD_NAME).clickOk();
// Wait for "Debugger attached to process.*" to be printed on the app-native debug console.
DebugToolWindowFixture debugToolWindowFixture = new DebugToolWindowFixture(projectFrame);
{
final ExecutionToolWindowFixture.ContentFixture contentFixture = debugToolWindowFixture.findContent(DEBUG_CONFIG_NAME);
contentFixture.waitForOutput(new PatternTextMatcher(Pattern.compile(".*Debugger attached to process.*", Pattern.DOTALL)), 50);
}
// breakpointToExpectedPatterns.
for (int i = 0; i < breakPoints.length; ++i) {
if (i > 0) {
resumeProgram();
}
final String[] expectedPatterns = breakpointToExpectedPatterns.get(breakPoints[i]);
Wait.seconds(1).expecting("the debugger tree to appear").until(() -> verifyVariablesAtBreakpoint(expectedPatterns, DEBUG_CONFIG_NAME));
}
{
// We cannot reuse the context fixture we got above, as its windows could have been repurposed for other things.
final ExecutionToolWindowFixture.ContentFixture contentFixture = debugToolWindowFixture.findContent(DEBUG_CONFIG_NAME);
contentFixture.stop();
contentFixture.waitForExecutionToFinish();
}
}
use of org.fest.swing.util.PatternTextMatcher in project android by JetBrains.
the class LaunchAndroidApplicationTest method testRunOnEmulator.
@RunIn(TestGroup.QA)
@Ignore("https://android-jenkins.corp.google.com/builders/studio-sanity_master-dev/builds/2122")
@Test
public void testRunOnEmulator() throws IOException, ClassNotFoundException {
guiTest.importSimpleApplication();
createAVD();
IdeFrameFixture ideFrameFixture = guiTest.ideFrame();
ideFrameFixture.runApp(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.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(LOCAL_PATH_OUTPUT), 120);
ideFrameFixture.getRunToolWindow().findContent(APP_NAME).waitForOutput(new PatternTextMatcher(RUN_OUTPUT), 120);
ideFrameFixture.getAndroidToolWindow().selectDevicesTab().selectProcess(PROCESS_NAME).clickTerminateApplication();
}
Aggregations