Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: efee60a6e0de745002e2609428990754948c5d08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*******************************************************************************
 * Copyright (c) 2005, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Tom Schindl - bug 151205
 *******************************************************************************/
package org.eclipse.jface.tests.viewers;

import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;

public class VirtualLazyTreeViewerTest extends TreeViewerTest {

	protected int setDataCalls = 0;

	public VirtualLazyTreeViewerTest(String name) {
		super(name);
	}

    protected StructuredViewer createViewer(Composite parent) {
    	Tree tree = new Tree(parent, SWT.VIRTUAL);
    	tree.addListener(SWT.SetData, new Listener(){

			public void handleEvent(Event event) {
				setDataCalls++;
			}});
        fTreeViewer = new TreeViewer(tree);
        fTreeViewer.setContentProvider(new TestModelLazyTreeContentProvider((TreeViewer) fTreeViewer));
        return fTreeViewer;
    }
    
    public void setUp() {
    	super.setUp();
    	// process events because the content provider uses an asyncExec to set the item count of the tree
    	processEvents();
    }
    
    protected void setInput() {
		super.setInput();
	}
    
    public void tearDown() {
    	super.tearDown();
//    	System.out.println("calls: " + setDataCalls);
    }
    
    public void testLeafIsExpandable() {
    	TestElement leafElement = fRootElement.getChildAt(2).getChildAt(3).getChildAt(2);
    	assertEquals(0, leafElement.getChildCount());
		assertFalse(fTreeViewer.isExpandable(leafElement));
    }

    public void testRootIsExpandable() {
    	TestElement rootElement = fRootElement.getChildAt(2);
    	assertTrue(rootElement.getChildCount() > 0);
    	assertTrue(fTreeViewer.isExpandable(rootElement));
    }
    
    public void testNodeIsExpandable() {
    	TestElement nodeElement = fRootElement.getChildAt(2).getChildAt(3);
    	assertTrue(nodeElement.getChildCount() > 0);
    	assertTrue(fTreeViewer.isExpandable(nodeElement));
    }
    

    public void testRefreshWithDuplicateChild() {
    	// Test leads to infinite loop. Duplicate children are a bad idea in virtual trees.
    }
    
    public void testSetExpandedWithCycle() {
    	// Test leads to infinite loop. Cycles are a bad idea in virtual trees.
    }
    
    public void testFilterExpanded() {
    	// no need to test since virtual trees do not support filtering
    }
    
    public void testFilter() {
    	// no need to test since virtual trees do not support filtering
    }
    
    public void testSetFilters() {
    	// no need to test since virtual trees do not support filtering
    }
    
    public void testInsertSiblingWithFilterFiltered() {
    	// no need to test since virtual trees do not support filtering
    }
    
    public void testInsertSiblingWithFilterNotFiltered() {
    	// no need to test since virtual trees do not support filtering
    }
    
    public void testInsertSiblingWithSorter() {
    	// no need to test since virtual trees do not support sorting
    }
        
    public void testRenameWithFilter() {
    	// no need to test since virtual trees do not support filtering
    }
    
    public void testRenameWithSorter() {
    	// no need to test since virtual trees do not support sorting
    }
    
    public void testSorter() {
    	// no need to test since virtual trees do not support sorting
    }
    
    // Temporary overrides for bug 347491:
    public void testRefreshWithAddedChildren() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
		super.testRefreshWithAddedChildren();
    }

    public void testDeleteSibling() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
		super.testDeleteSibling();
    }
    
    public void testExpandToLevel() {
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
    	super.testExpandToLevel();
    }
    
    public void testInsertSibling() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
    	super.testInsertSibling();
    }
    
    public void testInsertSiblings() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
   	super.testInsertSiblings();
    }
    
    public void testSetInput() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
    	super.testSetInput();
    }
    
    public void testSomeChildrenChanged() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
    	super.testSomeChildrenChanged();
    }

	public void testWorldChanged() {
		if (disableTestsBug347491)
			return;
		if (setDataCalls == 0) {
			System.err.println("SWT.SetData is not received. Cancelled test " + getName());
			return;
		}
		super.testWorldChanged();
	}
}

Back to the top