Search in sources :

Example 26 with TreeNode

use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.

the class TreeSettingsTest method testSetTrees.

@Test
public void testSetTrees() {
    TreeNode t = new TreeNode("f", false);
    TreeNode t1 = new TreeNode("as", "as3", false);
    TreeNode t2 = new TreeNode(null, false);
    TreeNode t3 = null;
    assertTrue("Set tree fine1", TreeSettings.setTrees(t, t));
    assertTrue("Set tree fine2", TreeSettings.setTrees(t1, t1));
    assertTrue("Set tree null obj", TreeSettings.setTrees(t2, t2));
    assertFalse("Set trees null", TreeSettings.setTrees(t3, t3));
    assertFalse("Set func null", TreeSettings.setTrees(t3, t));
    assertFalse("Set probe null", TreeSettings.setTrees(t, t3));
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) Test(org.junit.Test)

Example 27 with TreeNode

use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.

the class TreeSettingsTest method testGetFunctionTree.

@Test
public void testGetFunctionTree() {
    TreeNode temp;
    TreeNode t = new TreeNode("f", false);
    TreeNode t1 = new TreeNode(null, false);
    TreeNode t2 = new TreeNode(new StringBuilder("asfd"), true);
    TreeSettings.setTrees(t, t);
    temp = TreeSettings.getFunctionTree();
    assertEquals("Funcs no children", 0, temp.getChildCount());
    assertEquals("Funcs object", t.getData().toString(), temp.getData().toString());
    assertEquals("Funcs display", t.toString(), temp.toString());
    assertEquals("Funcs clickable", t.isClickable(), temp.isClickable());
    TreeSettings.setTrees(t1, t);
    temp = TreeSettings.getFunctionTree();
    assertEquals("Funcs no children", 0, temp.getChildCount());
    assertEquals("Funcs object", t1.getData(), temp.getData());
    assertEquals("Funcs display", t1.toString(), temp.toString());
    assertEquals("Funcs clickable", t1.isClickable(), temp.isClickable());
    TreeSettings.setTrees(t2, t);
    temp = TreeSettings.getFunctionTree();
    assertEquals("Funcs no children", 0, temp.getChildCount());
    assertEquals("Funcs object", t2.getData().toString(), temp.getData());
    assertEquals("Funcs display", t2.toString(), temp.toString());
    assertEquals("Funcs clickable", t2.isClickable(), temp.isClickable());
    t.add(t2);
    t.add(t1);
    TreeSettings.setTrees(t, t);
    temp = TreeSettings.getFunctionTree();
    assertEquals("Funcs has children", 2, temp.getChildCount());
    assertEquals("Funcs child object", t2.getData().toString(), temp.getChildAt(0).getData());
    assertEquals("Funcs child display", t2.toString(), temp.getChildAt(0).toString());
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) Test(org.junit.Test)

Example 28 with TreeNode

use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.

the class TreeSettingsTest method testDefinitionTrees.

@Test
public void testDefinitionTrees() {
    TreeNode temp;
    TreeDefinitionNode t1 = new TreeDefinitionNode("t1", "deftree1", "location", true);
    TreeDefinitionNode t2 = new TreeDefinitionNode("t2", "deftree2", null, true);
    TreeSettings.setTrees(t1, t2);
    temp = TreeSettings.getFunctionTree();
    assertTrue("Tree should have been saved as a definition node", temp instanceof TreeDefinitionNode);
    assertEquals("Funcs definition", t1.getDefinition(), ((TreeDefinitionNode) temp).getDefinition());
    assertEquals("Funcs object", t1.getData(), temp.getData());
    assertEquals("Funcs display", t1.toString(), temp.toString());
    assertEquals("Funcs clickable", t1.isClickable(), temp.isClickable());
    temp = TreeSettings.getProbeTree();
    assertTrue("Even with a null definition, tree should have been saved as a definition node", temp instanceof TreeDefinitionNode);
    assertEquals("Probs definition", t2.getDefinition(), ((TreeDefinitionNode) temp).getDefinition());
    assertEquals("Probs object", t2.getData(), temp.getData());
    assertEquals("Probs display", t2.toString(), temp.toString());
    assertEquals("Probs clickable", t2.isClickable(), temp.isClickable());
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) Test(org.junit.Test)

Example 29 with TreeNode

use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.

the class TreeSettingsTest method testStapNodeData.

@Test
public void testStapNodeData() {
    TreeNode temp;
    TreeNode t1 = new TreeNode(new FunctionNodeData("function ftest(x:long)", null), true);
    t1.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
    TreeNode t2 = new TreeNode(new ProbeNodeData("ptest"), true);
    t2.add(new TreeNode(new ProbevarNodeData("x:long"), false));
    TreeSettings.setTrees(t1, t2);
    temp = TreeSettings.getFunctionTree();
    assertTrue("Improper data type - expected FunctionNodeData but was " + temp.getData().getClass().getSimpleName(), temp.getData() instanceof FunctionNodeData);
    assertEquals("Function data not saved", t1.getData().toString(), temp.getData().toString());
    assertEquals("Funcs has children", t1.getChildCount(), temp.getChildCount());
    assertTrue("Improper data type", temp.getChildAt(0).getData() instanceof FuncparamNodeData);
    assertEquals("Function parameter data not saved", t1.getChildAt(0).getData().toString(), temp.getChildAt(0).getData().toString());
    temp = TreeSettings.getProbeTree();
    assertTrue("Improper data type", temp.getData() instanceof ProbeNodeData);
    assertEquals("Probe data not saved", t2.getData().toString(), temp.getData().toString());
    assertEquals("Probs has children", t2.getChildCount(), temp.getChildCount());
    assertTrue("Improper data type", temp.getChildAt(0).getData() instanceof ProbevarNodeData);
    assertEquals("Probe variable data not saved", t2.getChildAt(0).getData().toString(), temp.getChildAt(0).getData().toString());
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) FunctionNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData) FuncparamNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData) ProbeNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData) ProbevarNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData) Test(org.junit.Test)

Example 30 with TreeNode

use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.

the class TestCreateSystemtapScript method prepareTreeSettings.

/**
 * Load custom contents into the Function/Probe views.
 */
private static void prepareTreeSettings() {
    TapsetLibrary.stop();
    try {
        probeDef = File.createTempFile("probeDef", ".stp");
        funcDef = File.createTempFile("funcDef", ".stp");
        probeDef.deleteOnExit();
        funcDef.deleteOnExit();
    } catch (IOException e) {
    }
    // Leave one of the files blank to test token search failures.
    try (PrintWriter writer = new PrintWriter(probeDef)) {
        writer.print("test file\nptest\nlast line\n");
    } catch (FileNotFoundException e) {
    }
    TreeNode testProbNodeParent = new TreeNode(null, false);
    // Have static/alias folders to comply with convention (change this later).
    testProbNodeParent.add(new TreeNode(probeCategoryEmpty, true));
    testProbNodeParent.add(new TreeNode(probeCategoryFull, true));
    TreeNode testProbNodeGroup = new TreeNode(probeGroup, true);
    String innerProbe = "probegroup.inner";
    TreeNode testProbNode = new TreeDefinitionNode(new ProbeNodeData(innerProbe), innerProbe, probeDef.getPath(), true);
    testProbNode.add(new TreeNode(new ProbevarNodeData("s:string"), false));
    testProbNodeGroup.add(testProbNode);
    testProbNodeParent.getChildAt(1).add(testProbNodeGroup);
    TreeNode testProbNode2 = new TreeDefinitionNode(new ProbeNodeData(probeSingleWithoutDef), probeSingleWithoutDef, null, true);
    testProbNodeParent.getChildAt(1).add(testProbNode2);
    TreeNode testFuncNodeParent = new TreeNode(null, false);
    TreeNode testFuncNode = new TreeDefinitionNode(new FunctionNodeData("function ftest(x:long)", null), funcNodeName, funcDef.getPath(), true);
    testFuncNode.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
    testFuncNodeParent.add(testFuncNode);
    TreeSettings.setTrees(testFuncNodeParent, testProbNodeParent);
    TapsetLibrary.readTreeFile();
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) FunctionNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData) TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ProbeNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData) FuncparamNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData) ProbevarNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData) PrintWriter(java.io.PrintWriter)

Aggregations

TreeNode (org.eclipse.linuxtools.systemtap.structures.TreeNode)34 Test (org.junit.Test)15 TreeDefinitionNode (org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode)4 Scanner (java.util.Scanner)3 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)3 ProbevarNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData)3 ArrayList (java.util.ArrayList)2 IFileStore (org.eclipse.core.filesystem.IFileStore)2 FuncparamNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData)2 FunctionNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData)2 ProbeNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 Matcher (java.util.regex.Matcher)1 IStatus (org.eclipse.core.runtime.IStatus)1