~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/DoubleClickTest.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2008, 2009 Red Hat, Inc.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.valgrind.massif.tests;
 
12
 
 
13
 
 
14
import org.eclipse.debug.core.ILaunchConfiguration;
 
15
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 
16
import org.eclipse.jface.viewers.DoubleClickEvent;
 
17
import org.eclipse.jface.viewers.IDoubleClickListener;
 
18
import org.eclipse.jface.viewers.TreePath;
 
19
import org.eclipse.jface.viewers.TreeSelection;
 
20
import org.eclipse.jface.viewers.TreeViewer;
 
21
import org.eclipse.linuxtools.internal.valgrind.massif.MassifHeapTreeNode;
 
22
import org.eclipse.linuxtools.internal.valgrind.massif.MassifLaunchConstants;
 
23
import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot;
 
24
import org.eclipse.linuxtools.internal.valgrind.massif.MassifTreeViewer;
 
25
import org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart;
 
26
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin;
 
27
 
 
28
public class DoubleClickTest extends AbstractMassifTest {
 
29
        private MassifHeapTreeNode node;
 
30
 
 
31
        @Override
 
32
        protected void setUp() throws Exception {
 
33
                super.setUp();
 
34
                proj = createProjectAndBuild("alloctest"); //$NON-NLS-1$        
 
35
        }
 
36
 
 
37
        @Override
 
38
        protected void tearDown() throws Exception {
 
39
                deleteProject(proj);
 
40
                super.tearDown();
 
41
        }
 
42
        
 
43
        private void doDoubleClick() {
 
44
                MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
 
45
                MassifTreeViewer treeViewer = view.getTreeViewer();
 
46
                
 
47
                MassifSnapshot[] snapshots = view.getSnapshots();
 
48
                node = snapshots[1].getRoot(); // first detailed
 
49
                TreePath path = new TreePath(new Object[] { node });
 
50
                while (node.getChildren().length > 0 && !node.hasSourceFile()) {
 
51
                        node = node.getChildren()[0];
 
52
                        path = path.createChildPath(node);
 
53
                }
 
54
                if (node.hasSourceFile()) {
 
55
                        treeViewer.getViewer().expandToLevel(node, TreeViewer.ALL_LEVELS);
 
56
                        TreeSelection selection = new TreeSelection(path);
 
57
        
 
58
                        // do double click
 
59
                        IDoubleClickListener listener = treeViewer.getDoubleClickListener();
 
60
                        listener.doubleClick(new DoubleClickEvent(treeViewer.getViewer(), selection));
 
61
                }
 
62
                else {
 
63
                        fail();
 
64
                }
 
65
        }
 
66
 
 
67
        public void testDoubleClickFile() throws Exception {
 
68
                ILaunchConfiguration config = createConfiguration(proj.getProject());
 
69
                ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
 
70
                wc.setAttribute(MassifLaunchConstants.ATTR_MASSIF_DETAILEDFREQ, 2);
 
71
                wc.doSave();
 
72
                doLaunch(config, "testDoubleClickFile"); //$NON-NLS-1$
 
73
                
 
74
                doDoubleClick();
 
75
                
 
76
                checkFile(proj.getProject(), node);
 
77
        }
 
78
 
 
79
        public void testDoubleClickLine() throws Exception {
 
80
                ILaunchConfiguration config = createConfiguration(proj.getProject());
 
81
                ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
 
82
                wc.setAttribute(MassifLaunchConstants.ATTR_MASSIF_DETAILEDFREQ, 2);
 
83
                wc.doSave();
 
84
                doLaunch(config, "testDoubleClickLine"); //$NON-NLS-1$
 
85
                
 
86
                doDoubleClick();
 
87
                
 
88
                checkLine(node);
 
89
        }
 
90
}