Search in sources :

Example 11 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method testModelDefaultGenericStructure.

@Test
public void testModelDefaultGenericStructure() {
    TreeParent invisibleRoot = buildModel("resources/defaultevent-data/perf.data", "resources/defaultevent-data/perf.data.txt", "resources/defaultevent-data/perf.data.err.log");
    checkChildrenStructure(invisibleRoot, stack);
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 12 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method checkChildrenStructure.

/**
 * @param root some element that will serve as the root
 * @param stack a stack of classes
 */
private void checkChildrenStructure(TreeParent root, Stack<Class<?>> stack) {
    if (!stack.isEmpty()) {
        // children of root must be instances of the top class on the stack
        Class<?> klass = stack.pop();
        for (TreeParent tp : root.getChildren()) {
            // tp.getClass() instanceof klass
            assertTrue(klass.isAssignableFrom(tp.getClass()));
            // each sibling needs its own stack
            Stack<Class<?>> newStack = new Stack<>();
            newStack.addAll(stack);
            checkChildrenStructure(tp, newStack);
        }
    }
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) Stack(java.util.Stack)

Example 13 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method testModelMultiEventGenericStructure.

@Test
public void testModelMultiEventGenericStructure() {
    TreeParent invisibleRoot = buildModel("resources/multievent-data/perf.data", "resources/multievent-data/perf.data.txt", "resources/multievent-data/perf.data.err.log");
    checkChildrenStructure(invisibleRoot, stack);
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 14 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method checkCommadLabels.

/**
 * Check whether the command labels in model rooted at cmd exist in
 * list of labels cmdLabels.
 * @param cmdLabels list of command labels
 * @param cmd root of tree model
 */
private void checkCommadLabels(String[] cmdLabels, TreeParent cmd) {
    List<String> cmdList = new ArrayList<>(Arrays.asList(cmdLabels));
    for (TreeParent dso : cmd.getChildren()) {
        assertTrue(cmdList.get(0).equals(dso.getName()));
        cmdList.remove(0);
    }
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) ArrayList(java.util.ArrayList)

Aggregations

TreeParent (org.eclipse.linuxtools.internal.perf.model.TreeParent)14 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)7 Test (org.junit.Test)7 BufferedReader (java.io.BufferedReader)4 IOException (java.io.IOException)3 FileReader (java.io.FileReader)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 PMCommand (org.eclipse.linuxtools.internal.perf.model.PMCommand)2 PMDso (org.eclipse.linuxtools.internal.perf.model.PMDso)2 PMFile (org.eclipse.linuxtools.internal.perf.model.PMFile)2 PMSymbol (org.eclipse.linuxtools.internal.perf.model.PMSymbol)2 Stack (java.util.Stack)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 PMEvent (org.eclipse.linuxtools.internal.perf.model.PMEvent)1