Search in sources :

Example 11 with IdeFrameFixture

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

the class NlPreviewTest method testConfigurationMatching.

@Test
public void testConfigurationMatching() throws Exception {
    guiTest.importProjectAndWaitForProjectSyncToFinish("LayoutTest");
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    EditorFixture editor = ideFrame.getEditor();
    editor.open("app/src/main/res/layout/layout2.xml", EditorFixture.Tab.EDITOR);
    NlPreviewFixture preview = editor.getLayoutPreview(true);
    NlConfigurationToolbarFixture toolbar = preview.getConfigToolbar();
    toolbar.chooseDevice("Nexus 5");
    preview.waitForRenderToFinish();
    toolbar.requireDevice("Nexus 5");
    assertThat(editor.getCurrentFile().getParent().getName()).isEqualTo("layout");
    toolbar.requireOrientation("Portrait");
    toolbar.chooseDevice("Nexus 7");
    preview.waitForRenderToFinish();
    toolbar.requireDevice("Nexus 7 2013");
    assertThat(editor.getCurrentFile().getParent().getName()).isEqualTo("layout-sw600dp");
    toolbar.chooseDevice("Nexus 10");
    preview.waitForRenderToFinish();
    toolbar.requireDevice("Nexus 10");
    assertThat(editor.getCurrentFile().getParent().getName()).isEqualTo("layout-sw600dp");
    // Default orientation for Nexus 10
    toolbar.requireOrientation("Landscape");
    editor.open("app/src/main/res/layout/activity_my.xml", EditorFixture.Tab.EDITOR);
    preview.waitForRenderToFinish();
    // Since we switched to it most recently
    toolbar.requireDevice("Nexus 10");
    toolbar.requireOrientation("Portrait");
    toolbar.chooseDevice("Nexus 7");
    preview.waitForRenderToFinish();
    toolbar.chooseDevice("Nexus 4");
    preview.waitForRenderToFinish();
    editor.open("app/src/main/res/layout-sw600dp/layout2.xml", EditorFixture.Tab.EDITOR);
    preview.waitForRenderToFinish();
    assertThat(editor.getCurrentFile().getParent().getName()).isEqualTo("layout-sw600dp");
    // because it's the most recently configured sw600-dp compatible device
    toolbar.requireDevice("Nexus 7 2013");
    editor.open("app/src/main/res/layout/layout2.xml", EditorFixture.Tab.EDITOR);
    preview.waitForRenderToFinish();
    // because it's the most recently configured small screen compatible device
    toolbar.requireDevice("Nexus 4");
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) Test(org.junit.Test)

Example 12 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture 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();
    }
}
Also used : HashMap(com.intellij.util.containers.HashMap) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) DebugToolWindowFixture(com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher)

Example 13 with IdeFrameFixture

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

the class DeveloperServicesTest method toggleDevServicesDependencies.

/**
   * Verifies that Developer Services dependencies can be added and removed in app build gradle file.
   * <p>
   * This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>
   * TR ID: C14581655
   * <p>
   *   <pre>
   *   Test Steps:
   *   1. Import a project.
   *   2. Open File > Project Structure
   *   3. Developer Services option is listed and contains the following options: Ads, Authentication, Notifications.
   *   4. Enable all services.
   *   5. Click OK button.
   *   6. Open app/build.gradle
   *   7. Dependencies are added for each of the enabled services.
   *   8. Open File > Structure
   *   9. Disable services for Ads, Authentication, Notification.
   *   10. Click OK button.
   *   11. Open app/build.gradle
   *   12. Dependencies are removed for the services.
   *   Verify:
   *   Toggling Developer Services dependencies reflects in app build gradle file.
   *   </pre>
   * <p>
   *   The test checks both the presence of the string and that the build.gradle file is written correctly by parsing it.
   */
@RunIn(TestGroup.QA)
@Test
public void toggleDevServicesDependencies() throws Exception {
    IdeFrameFixture ideFrameFixture = guiTest.importSimpleApplication();
    ideFrameFixture.openFromMenu(ProjectStructureDialogFixture::find, "File", "Project Structure...").setServiceEnabled("Ads", true).setServiceEnabled("Authentication", true).setServiceEnabled("Notifications", true).clickOk();
    String gradleFileContents = getBuildGradleFileContents();
    assertThat(gradleFileContents).contains("compile 'com.google.android.gms:play-services-ads:");
    assertThat(gradleFileContents).contains("compile 'com.google.android.gms:play-services-auth:");
    assertThat(gradleFileContents).contains("compile 'com.google.android.gms:play-services-gcm:");
    // Parsing of the Gradle file needs to be done in a ReadAction.
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            GradleBuildModel buildModel = GradleBuildModel.parseBuildFile(getBuildGradleFile(), ideFrameFixture.getProject());
            assertThat(dependencyIsPresent(buildModel, "play-services-ads")).isTrue();
            assertThat(dependencyIsPresent(buildModel, "play-services-auth")).isTrue();
            assertThat(dependencyIsPresent(buildModel, "play-services-gcm")).isTrue();
        }
    });
    // Disable the services.
    ideFrameFixture.openFromMenu(ProjectStructureDialogFixture::find, "File", "Project Structure...").setServiceEnabled("Ads", false).setServiceEnabled("Authentication", false).setServiceEnabled("Notifications", false).clickOk();
    gradleFileContents = getBuildGradleFileContents();
    assertThat(gradleFileContents).doesNotContain("compile 'com.google.android.gms:play-services-ads:");
    assertThat(gradleFileContents).doesNotContain("compile 'com.google.android.gms:play-services-auth:");
    assertThat(gradleFileContents).doesNotContain("compile 'com.google.android.gms:play-services-gcm:");
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            GradleBuildModel buildModel = GradleBuildModel.parseBuildFile(getBuildGradleFile(), ideFrameFixture.getProject());
            assertThat(dependencyIsPresent(buildModel, "play-services-ads")).isFalse();
            assertThat(dependencyIsPresent(buildModel, "play-services-auth")).isFalse();
            assertThat(dependencyIsPresent(buildModel, "play-services-gcm")).isFalse();
        }
    });
}
Also used : ProjectStructureDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) Test(org.junit.Test) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 14 with IdeFrameFixture

use of com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture 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();
}
Also used : IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) PatternTextMatcher(org.fest.swing.util.PatternTextMatcher) Ignore(org.junit.Ignore) Test(org.junit.Test) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 15 with IdeFrameFixture

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

the class LaunchAndroidApplicationTest method testCppDebugOnEmulatorWithBreakpoint.

/**
   * To verify that sample ndk projects can be imported and breakpoints in code are hit.
   * <p>
   * This is run to qualify releases. Please involve the test team in substantial changes.
   * <p>
   * TR ID: C14578820
   * <p>
   *   <pre>
   *   Test Steps:
   *   1. Open Android Studio
   *   2. Import Teapot from the cloned repo
   *   3. Open TeapotNativeActivity.cpp
   *   4. Click on any method and make sure it finds the method or its declaration
   *   5. Search for the symbol HandleInput and put a break point in the method
   *   6. Deploy to a device/emulator
   *   7. Wait for notification that the debugger is connected
   *   8. Teapot should show up on the device
   *   9. Touch to interact
   *   Verify:
   *   1. After step 9, the breakpoint is triggered.
   *   </pre>
   * <p>
   */
@Ignore("http://b/30795134")
@RunIn(TestGroup.QA)
@Test
public void testCppDebugOnEmulatorWithBreakpoint() throws Exception {
    WelcomeFrameFixture welcomeFrame = WelcomeFrameFixture.find(guiTest.robot());
    welcomeFrame.importCodeSample();
    BrowseSamplesWizardFixture samplesWizard = BrowseSamplesWizardFixture.find(guiTest.robot());
    samplesWizard.selectSample("Ndk/Teapot").clickNext();
    ConfigureAndroidProjectStepFixture configStep = samplesWizard.getConfigureFormFactorStep();
    configStep.enterApplicationName("TeapotTest");
    guiTest.setProjectPath(configStep.getLocationInFileSystem());
    samplesWizard.clickFinish();
    IdeFrameFixture ideFrameFixture = guiTest.ideFrame();
    ideFrameFixture.waitForGradleProjectSyncToFinish().getEditor().open("app/src/main/jni/TeapotNativeActivity.cpp").moveBetween("g_engine.Draw", "Frame()").invokeAction(// First break point - First Frame is drawn
    EditorFixture.EditorAction.TOGGLE_LINE_BREAKPOINT).moveBetween("static int32_t Handle", "Input(").invokeAction(EditorFixture.EditorAction.GOTO_IMPLEMENTATION).invokeAction(// Second break point - HandleInput()
    EditorFixture.EditorAction.TOGGLE_LINE_BREAKPOINT);
    assertThat(guiTest.ideFrame().getEditor().getCurrentLine()).contains("int32_t Engine::HandleInput(");
    createAVD();
    ideFrameFixture.debugApp(APP_NAME).selectDevice(AVD_NAME).clickOk();
    // Wait for the UI App to be up and running, by waiting for the first Frame draw to get hit.
    expectBreakPoint("g_engine.DrawFrame()");
    // Simulate a screen touch
    getEmulatorConnection().tapRunningAvd(400, 400);
    // Wait for the Cpp HandleInput() break point to get hit.
    expectBreakPoint("Engine* eng = (Engine*)app->userData;");
}
Also used : ConfigureAndroidProjectStepFixture(com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.ConfigureAndroidProjectStepFixture) BrowseSamplesWizardFixture(com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.BrowseSamplesWizardFixture) IdeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture) WelcomeFrameFixture(com.android.tools.idea.tests.gui.framework.fixture.WelcomeFrameFixture) Ignore(org.junit.Ignore) Test(org.junit.Test) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Aggregations

IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)19 Test (org.junit.Test)15 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)9 RunIn (com.android.tools.idea.tests.gui.framework.RunIn)7 PatternTextMatcher (org.fest.swing.util.PatternTextMatcher)6 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)4 Ignore (org.junit.Ignore)4 JTreeFixture (org.fest.swing.fixture.JTreeFixture)3 ProjectStructureDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.ProjectStructureDialogFixture)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 DebugToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture)1 RenameRefactoringDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.RenameRefactoringDialogFixture)1 WelcomeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.WelcomeFrameFixture)1 NlComponentFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture)1 NlEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture)1 BrowseSamplesWizardFixture (com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.BrowseSamplesWizardFixture)1 ConfigureAndroidProjectStepFixture (com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.ConfigureAndroidProjectStepFixture)1 BuildTypesTabFixture (com.android.tools.idea.tests.gui.framework.fixture.projectstructure.BuildTypesTabFixture)1