use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.
the class ModelTest method doubleClickAllChildren.
/**
* Performs a Perf double-click action on every element in the
* TreeViewer model.
*
* @param root some element that will serve as the root
* @param tv a TreeViewer containing elements from the Perf model
* @param dblClick the double-click action to perform on every
* element of the TreeViewer.
*/
private void doubleClickAllChildren(TreeParent root, TreeViewer tv, PerfDoubleClickAction dblClick) {
for (TreeParent child : root.getChildren()) {
// see PerfDoubleClickAction for IStructuredSelection
tv.setSelection(new StructuredSelection(child));
dblClick.run();
doubleClickAllChildren(child, tv, dblClick);
}
}
use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.
the class ModelTest method testPercentages.
@Test
public void testPercentages() {
TreeParent invisibleRoot = buildModel("resources/defaultevent-data/perf.data", "resources/defaultevent-data/perf.data.txt", "resources/defaultevent-data/perf.data.err.log");
checkChildrenPercentages(invisibleRoot, invisibleRoot.getPercent());
}
use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.
the class ModelTest method testDoubleClickAction.
@Test
public void testDoubleClickAction() {
TreeParent invisibleRoot = buildModel("resources/defaultevent-data/perf.data", "resources/defaultevent-data/perf.data.txt", "resources/defaultevent-data/perf.data.err.log");
PerfPlugin.getDefault().setModelRoot(invisibleRoot);
// update the model root for the view
PerfCore.refreshView("resources/defaultevent-data/perf.data");
// number of parents excluding invisibleRoot
int numOfParents = getNumberOfParents(invisibleRoot) - 1;
// create a double click action to act on the tree viewer
try {
PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
TreeViewer tv = view.getTreeViewer();
PerfDoubleClickAction dblClick = new PerfDoubleClickAction(tv);
// double click every element
doubleClickAllChildren(invisibleRoot, tv, dblClick);
// If all elements are expanded, this is the number of elements
// in our model that have children.
assertEquals(numOfParents, tv.getExpandedElements().length);
} catch (PartInitException e) {
fail("Failed to open the Profiling View.");
}
}
use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.
the class ModelTest method testParserMultiEvent.
@Test
public void testParserMultiEvent() {
TreeParent invisibleRoot = buildModel("resources/multievent-data/perf.data", "resources/multievent-data/perf.data.txt", "resources/multievent-data/perf.data.err.log");
assertEquals(invisibleRoot.getChildren().length, 5);
String cur = null;
for (TreeParent event : invisibleRoot.getChildren()) {
cur = event.getName();
// Assert specific properties extracted by the parser.
if ("cpu-clock".equals(cur)) {
assertTrue(event.hasChildren());
assertEquals(event.getChildren().length, 1);
TreeParent cmd = event.getChildren()[0];
assertEquals(cmd.getChildren().length, 1);
String[] cmdLabels = { "hellotest" };
checkCommadLabels(cmdLabels, cmd);
} else if ("task-clock".equals(cur)) {
assertTrue(event.hasChildren());
assertEquals(event.getChildren().length, 1);
TreeParent cmd = event.getChildren()[0];
assertEquals(cmd.getChildren().length, 1);
String[] cmdLabels = { "hellotest" };
checkCommadLabels(cmdLabels, cmd);
} else if ("page-faults".equals(cur)) {
assertTrue(event.hasChildren());
assertEquals(event.getChildren().length, 1);
TreeParent cmd = event.getChildren()[0];
assertEquals(cmd.getChildren().length, 3);
String[] cmdLabels = { "ld-2.14.90.so", "[kernel.kallsyms]", "libc-2.14.90.so" };
checkCommadLabels(cmdLabels, cmd);
} else if ("minor-faults".equals(cur)) {
assertTrue(event.hasChildren());
assertEquals(event.getChildren().length, 1);
TreeParent cmd = event.getChildren()[0];
assertEquals(cmd.getChildren().length, 3);
String[] cmdLabels = { "ld-2.14.90.so", "[kernel.kallsyms]", "libc-2.14.90.so" };
checkCommadLabels(cmdLabels, cmd);
} else if ("major-faults".equals(cur)) {
assertFalse(event.hasChildren());
}
}
}
use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.
the class ModelTest method buildModel.
/**
* Build model based on perf data file report.
* @param perfDataLoc location of perf data file
* @param perfTextDataLoc location of perf data text file
* @param perfErrorDataLoc location of error log file
* @return tree model based on perf data report.
*/
private TreeParent buildModel(String perfDataLoc, String perfTextDataLoc, String perfErrorDataLoc) {
TreeParent invisibleRoot = new TreeParent("");
BufferedReader input = null;
BufferedReader error = null;
try {
input = new BufferedReader(new FileReader(perfTextDataLoc));
error = new BufferedReader(new FileReader(perfErrorDataLoc));
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
PerfCore.parseReport(config, null, null, perfDataLoc, null, invisibleRoot, false, input, error);
return invisibleRoot;
}
Aggregations