Search in sources :

Example 1 with DebugToolWindowFixture

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

the class LaunchAndroidApplicationTest method expectBreakPoint.

private void expectBreakPoint(String lineText) {
    DebugToolWindowFixture debugToolWindow = guiTest.ideFrame().getDebugToolWindow().waitForBreakPointHit();
    // Check we have the right debug line
    assertThat(guiTest.ideFrame().getEditor().getCurrentLine()).contains(lineText);
    // Remove break point
    guiTest.ideFrame().getEditor().invokeAction(EditorFixture.EditorAction.TOGGLE_LINE_BREAKPOINT);
    debugToolWindow.pressResumeProgram();
}
Also used : DebugToolWindowFixture(com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture)

Example 2 with DebugToolWindowFixture

use of com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture 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 3 with DebugToolWindowFixture

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

the class BasicNativeDebuggerTest method verifyVariablesAtBreakpoint.

private boolean verifyVariablesAtBreakpoint(String[] expectedVariablePatterns, String debugConfigName) {
    DebugToolWindowFixture debugToolWindowFixture = new DebugToolWindowFixture(guiTest.ideFrame());
    final ExecutionToolWindowFixture.ContentFixture contentFixture = debugToolWindowFixture.findContent(debugConfigName);
    contentFixture.clickDebuggerTreeRoot();
    Wait.seconds(1).expecting("debugger tree to appear").until(() -> contentFixture.getDebuggerTreeRoot() != null);
    // Get the debugger tree and print it.
    XDebuggerTreeNode debuggerTreeRoot = contentFixture.getDebuggerTreeRoot();
    if (debuggerTreeRoot == null) {
        return false;
    }
    List<String> unmatchedPatterns = getUnmatchedTerminalVariableValues(expectedVariablePatterns, debuggerTreeRoot);
    return unmatchedPatterns.isEmpty();
}
Also used : DebugToolWindowFixture(com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture) ExecutionToolWindowFixture(com.android.tools.idea.tests.gui.framework.fixture.ExecutionToolWindowFixture) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode)

Aggregations

DebugToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture)3 ExecutionToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.ExecutionToolWindowFixture)1 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)1 HashMap (com.intellij.util.containers.HashMap)1 XDebuggerTreeNode (com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode)1 PatternTextMatcher (org.fest.swing.util.PatternTextMatcher)1