Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 493136 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.gef4.dot.tests/.classpath (+1 lines)
Lines 3-8 Link Here
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="src" path="xtend-gen"/>
6
	<classpathentry kind="src" path="src-gen"/>
7
	<classpathentry kind="src" path="src-gen"/>
7
	<classpathentry kind="output" path="bin"/>
8
	<classpathentry kind="output" path="bin"/>
8
</classpath>
9
</classpath>
(-)a/org.eclipse.gef4.dot.tests/.gitignore (-1 / +2 lines)
Lines 1-2 Link Here
1
/output/
1
/output/
2
/src-gen/
2
/src-gen/
3
/xtend-gen/
(-)a/org.eclipse.gef4.dot.tests/.project (+6 lines)
Lines 6-11 Link Here
6
	</projects>
6
	</projects>
7
	<buildSpec>
7
	<buildSpec>
8
		<buildCommand>
8
		<buildCommand>
9
			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
14
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
15
			<arguments>
11
			</arguments>
16
			</arguments>
Lines 25-29 Link Here
25
		<nature>org.eclipse.pde.PluginNature</nature>
30
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
27
		<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
32
		<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
33
		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
28
	</natures>
34
	</natures>
29
</projectDescription>
35
</projectDescription>
(-)a/org.eclipse.gef4.dot.tests/build.properties (-2 / +4 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2015 itemis AG and others.
2
# Copyright (c) 2015, 2016 itemis AG and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 7-15 Link Here
7
#
7
#
8
# Contributors:
8
# Contributors:
9
#     Alexander Ny�en (itemis AG) - initial API and implementation
9
#     Alexander Ny�en (itemis AG) - initial API and implementation
10
#     Tamas Miklossy  (itemis AG) - add xtend-gen to the source folders
10
###############################################################################
11
###############################################################################
11
source.. = src/,\
12
source.. = src/,\
12
           src-gen/
13
           src-gen/,\
14
           xtend-gen/
13
output.. = bin/
15
output.. = bin/
14
bin.includes = META-INF/,\
16
bin.includes = META-INF/,\
15
               .
17
               .
(-)a/org.eclipse.gef4.dot.tests/pom.xml (+33 lines)
Lines 20-25 Link Here
20
		<sourceDirectory>src</sourceDirectory>
20
		<sourceDirectory>src</sourceDirectory>
21
		<plugins>
21
		<plugins>
22
			<plugin>
22
			<plugin>
23
				<artifactId>maven-clean-plugin</artifactId>
24
				<version>${maven-clean-plugin.version}</version>
25
				<executions>
26
					<execution>
27
						<id>gen-clean</id>
28
						<phase>clean</phase>
29
						<configuration>
30
							<filesets combine.children="append">
31
								<fileset>
32
									<directory>${basedir}/xtend-gen/</directory>
33
								</fileset>
34
							</filesets>
35
						</configuration>
36
					</execution>
37
				</executions>
38
			</plugin>
39
			<plugin>
40
                <groupId>org.eclipse.xtend</groupId>
41
                <artifactId>xtend-maven-plugin</artifactId>
42
                <version>${xtext.version}</version>
43
                <executions>
44
                    <execution>
45
                        <goals>
46
                            <goal>compile</goal>
47
                        </goals>
48
                    </execution>
49
                </executions>
50
                <configuration>
51
					<encoding>${project.build.sourceEncoding}</encoding>
52
					<outputDirectory>xtend-gen</outputDirectory>
53
				</configuration>
54
            </plugin>
55
			<plugin>
23
				<groupId>org.eclipse.tycho</groupId>
56
				<groupId>org.eclipse.tycho</groupId>
24
				<artifactId>tycho-surefire-plugin</artifactId>
57
				<artifactId>tycho-surefire-plugin</artifactId>
25
			</plugin>
58
			</plugin>
(-)a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotInterpreterTests.java (-48 / +47 lines)
Lines 52-58 Link Here
52
52
53
	@Test
53
	@Test
54
	public void digraphType() {
54
	public void digraphType() {
55
		Graph graph = interpreter.interpret(parse("digraph Sample{1;2;1->2}")) //$NON-NLS-1$
55
		Graph graph = interpreter
56
				.interpret(parse(DotSampleGraphs.TWO_NODES_ONE_DIRECTED_EDGE))
56
				.get(0);
57
				.get(0);
57
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
58
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
58
		Assert.assertEquals(DotAttributes._TYPE__G__DIGRAPH,
59
		Assert.assertEquals(DotAttributes._TYPE__G__DIGRAPH,
Lines 61-68 Link Here
61
62
62
	@Test
63
	@Test
63
	public void graphType() {
64
	public void graphType() {
64
		Graph graph = interpreter.interpret(parse("graph Sample{1;2;1--2}")) //$NON-NLS-1$
65
		Graph graph = interpreter
65
				.get(0);
66
				.interpret(parse(DotSampleGraphs.TWO_NODES_ONE_EDGE)).get(0);
66
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
67
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
67
		Assert.assertEquals(DotAttributes._TYPE__G__GRAPH,
68
		Assert.assertEquals(DotAttributes._TYPE__G__GRAPH,
68
				DotAttributes._getType(graph));
69
				DotAttributes._getType(graph));
Lines 70-76 Link Here
70
71
71
	@Test
72
	@Test
72
	public void nodeDefaultLabel() {
73
	public void nodeDefaultLabel() {
73
		Graph graph = interpreter.interpret(parse("graph Sample{1}")).get(0); //$NON-NLS-1$
74
		Graph graph = interpreter.interpret(parse(DotSampleGraphs.ONE_NODE))
75
				.get(0);
74
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
76
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
75
		Assert.assertEquals("1", //$NON-NLS-1$
77
		Assert.assertEquals("1", //$NON-NLS-1$
76
				DotAttributes._getName(graph.getNodes().get(0)));
78
				DotAttributes._getName(graph.getNodes().get(0)));
Lines 78-84 Link Here
78
80
79
	@Test
81
	@Test
80
	public void nodeCount() {
82
	public void nodeCount() {
81
		Graph graph = interpreter.interpret(parse("graph Sample{1;2}")).get(0); //$NON-NLS-1$
83
		Graph graph = interpreter.interpret(parse(DotSampleGraphs.TWO_NODES))
84
				.get(0);
82
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
85
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
83
		Assert.assertEquals(2, graph.getNodes().size());
86
		Assert.assertEquals(2, graph.getNodes().size());
84
	}
87
	}
Lines 86-92 Link Here
86
	@Test
89
	@Test
87
	public void edgeCount() {
90
	public void edgeCount() {
88
		Graph graph = interpreter
91
		Graph graph = interpreter
89
				.interpret(parse("graph Sample{1;2;1--2;2--2;1--1}")).get(0); //$NON-NLS-1$
92
				.interpret(parse(DotSampleGraphs.TWO_NODES_AND_THREE_EDGES))
93
				.get(0);
90
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
94
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
91
		Assert.assertEquals(3, graph.getEdges().size());
95
		Assert.assertEquals(3, graph.getEdges().size());
92
	}
96
	}
Lines 94-100 Link Here
94
	@Test
98
	@Test
95
	public void nodeLabel() {
99
	public void nodeLabel() {
96
		Graph graph = interpreter
100
		Graph graph = interpreter
97
				.interpret(parse("graph Sample{1[label=\"Node1\"];}")).get(0); //$NON-NLS-1$
101
				.interpret(parse(DotSampleGraphs.NODE_LABEL_LOCAL)).get(0);
98
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
102
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
99
		Assert.assertEquals("Node1", //$NON-NLS-1$
103
		Assert.assertEquals("Node1", //$NON-NLS-1$
100
				DotAttributes.getLabel(graph.getNodes().get(0)));
104
				DotAttributes.getLabel(graph.getNodes().get(0)));
Lines 103-110 Link Here
103
	@Test
107
	@Test
104
	public void edgeLabel() {
108
	public void edgeLabel() {
105
		Graph graph = interpreter
109
		Graph graph = interpreter
106
				.interpret(parse("graph Sample{1;2;1--2[label=\"Edge1\"]}")) //$NON-NLS-1$
110
				.interpret(parse(DotSampleGraphs.EDGE_LABEL_LOCAL)).get(0);
107
				.get(0);
108
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
111
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
109
		Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$
112
		Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$
110
				.get(0)));
113
				.get(0)));
Lines 113-120 Link Here
113
	@Test
116
	@Test
114
	public void edgeStyle() {
117
	public void edgeStyle() {
115
		Graph graph = interpreter
118
		Graph graph = interpreter
116
				.interpret(parse("graph Sample{1;2;1->2[style=dashed]}")) //$NON-NLS-1$
119
				.interpret(parse(DotSampleGraphs.EDGE_STYLE_LOCAL)).get(0);
117
				.get(0);
118
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
120
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
119
		Assert.assertEquals(EdgeStyle.DASHED.toString(),
121
		Assert.assertEquals(EdgeStyle.DASHED.toString(),
120
				DotAttributes.getStyle(graph.getEdges().get(0)));
122
				DotAttributes.getStyle(graph.getEdges().get(0)));
Lines 123-130 Link Here
123
	@Test
125
	@Test
124
	public void globalEdgeStyle() {
126
	public void globalEdgeStyle() {
125
		Graph graph = interpreter
127
		Graph graph = interpreter
126
				.interpret(parse("graph Sample{edge[style=dashed];1;2;1--2}")) //$NON-NLS-1$
128
				.interpret(parse(DotSampleGraphs.EDGE_STYLE_GLOBAL)).get(0);
127
				.get(0);
128
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
129
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
129
		Assert.assertEquals(EdgeStyle.DASHED.toString(),
130
		Assert.assertEquals(EdgeStyle.DASHED.toString(),
130
				DotAttributes.getStyle(graph.getEdges().get(0)));
131
				DotAttributes.getStyle(graph.getEdges().get(0)));
Lines 133-141 Link Here
133
	@Test
134
	@Test
134
	public void globalEdgeLabel() {
135
	public void globalEdgeLabel() {
135
		Graph graph = interpreter
136
		Graph graph = interpreter
136
				.interpret(
137
				.interpret(parse(DotSampleGraphs.EDGE_LABEL_GLOBAL)).get(0);
137
						parse("graph Sample{edge[label=\"Edge1\"];1;2;1--2}")) //$NON-NLS-1$
138
				.get(0);
139
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
138
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
140
		Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$
139
		Assert.assertEquals("Edge1", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$
141
				.get(0)));
140
				.get(0)));
Lines 144-151 Link Here
144
	@Test
143
	@Test
145
	public void globalNodeLabel() {
144
	public void globalNodeLabel() {
146
		Graph graph = interpreter
145
		Graph graph = interpreter
147
				.interpret(parse("graph Sample{node[label=\"Node1\"];1;}")) //$NON-NLS-1$
146
				.interpret(parse(DotSampleGraphs.NODE_LABEL_GLOBAL)).get(0);
148
				.get(0);
149
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
147
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
150
		Assert.assertEquals("Node1", //$NON-NLS-1$
148
		Assert.assertEquals("Node1", //$NON-NLS-1$
151
				DotAttributes.getLabel(graph.getNodes().get(0)));
149
				DotAttributes.getLabel(graph.getNodes().get(0)));
Lines 154-160 Link Here
154
	@Test
152
	@Test
155
	public void layoutSpring() {
153
	public void layoutSpring() {
156
		Graph graph = interpreter
154
		Graph graph = interpreter
157
				.interpret(parse("graph Sample{graph[layout=fdp];1;}")).get(0); //$NON-NLS-1$
155
				.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_FDP)).get(0);
158
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
156
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
159
		Assert.assertEquals(Layout.FDP.toString(),
157
		Assert.assertEquals(Layout.FDP.toString(),
160
				DotAttributes.getLayout(graph));
158
				DotAttributes.getLayout(graph));
Lines 163-170 Link Here
163
	@Test
161
	@Test
164
	public void layoutGrid() {
162
	public void layoutGrid() {
165
		Graph graph = interpreter
163
		Graph graph = interpreter
166
				.interpret(parse("graph Sample{graph[layout=osage];1;}")) //$NON-NLS-1$
164
				.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_OSAGE)).get(0);
167
				.get(0);
168
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
165
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
169
		Assert.assertEquals(Layout.OSAGE.toString(),
166
		Assert.assertEquals(Layout.OSAGE.toString(),
170
				DotAttributes.getLayout(graph));
167
				DotAttributes.getLayout(graph));
Lines 173-180 Link Here
173
	@Test
170
	@Test
174
	public void layoutRadial() {
171
	public void layoutRadial() {
175
		Graph graph = interpreter
172
		Graph graph = interpreter
176
				.interpret(parse("graph Sample{graph[layout=twopi];1;}")) //$NON-NLS-1$
173
				.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_TWOPI)).get(0);
177
				.get(0);
178
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
174
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
179
		Assert.assertEquals(Layout.TWOPI.toString(),
175
		Assert.assertEquals(Layout.TWOPI.toString(),
180
				DotAttributes.getLayout(graph));
176
				DotAttributes.getLayout(graph));
Lines 183-189 Link Here
183
	@Test
179
	@Test
184
	public void layoutTree() {
180
	public void layoutTree() {
185
		Graph graph = interpreter
181
		Graph graph = interpreter
186
				.interpret(parse("graph Sample{graph[layout=dot];1;}")).get(0); //$NON-NLS-1$
182
				.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_DOT)).get(0);
187
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
183
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
188
		Assert.assertEquals(Layout.DOT.toString(),
184
		Assert.assertEquals(Layout.DOT.toString(),
189
				DotAttributes.getLayout(graph));
185
				DotAttributes.getLayout(graph));
Lines 192-199 Link Here
192
	@Test
188
	@Test
193
	public void layoutHorizontalTreeViaLayout() {
189
	public void layoutHorizontalTreeViaLayout() {
194
		Graph graph = interpreter
190
		Graph graph = interpreter
195
				.interpret(
191
				.interpret(parse(DotSampleGraphs.GRAPH_LAYOUT_DOT_HORIZONTAL))
196
						parse("graph Sample{graph[layout=dot];rankdir=LR;1;}")) //$NON-NLS-1$
197
				.get(0);
192
				.get(0);
198
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
193
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
199
		Assert.assertEquals(Layout.DOT.toString(),
194
		Assert.assertEquals(Layout.DOT.toString(),
Lines 204-210 Link Here
204
	@Test
199
	@Test
205
	public void layoutHorizontalTreeViaAttribute() {
200
	public void layoutHorizontalTreeViaAttribute() {
206
		Graph graph = interpreter
201
		Graph graph = interpreter
207
				.interpret(parse("graph Sample{rankdir=LR;1;}")).get(0); //$NON-NLS-1$
202
				.interpret(parse(DotSampleGraphs.GRAPH_RANKDIR_LR)).get(0);
208
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
203
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
209
		Assert.assertEquals(Rankdir.LR, DotAttributes.getRankdirParsed(graph));
204
		Assert.assertEquals(Rankdir.LR, DotAttributes.getRankdirParsed(graph));
210
	}
205
	}
Lines 212-218 Link Here
212
	@Test
207
	@Test
213
	public void globalNodeAttributeAdHocNodes() {
208
	public void globalNodeAttributeAdHocNodes() {
214
		Graph graph = interpreter
209
		Graph graph = interpreter
215
				.interpret(parse("graph{node[label=\"TEXT\"];1--2}")).get(0); //$NON-NLS-1$
210
				.interpret(
211
						parse(DotSampleGraphs.GLOBAL_NODE_LABEL_AD_HOC_NODES))
212
				.get(0);
216
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
213
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
217
		Assert.assertEquals("TEXT", //$NON-NLS-1$
214
		Assert.assertEquals("TEXT", //$NON-NLS-1$
218
				DotAttributes.getLabel(graph.getNodes().get(0)));
215
				DotAttributes.getLabel(graph.getNodes().get(0)));
Lines 221-227 Link Here
221
	@Test
218
	@Test
222
	public void globalEdgeAttributeAdHocNodes() {
219
	public void globalEdgeAttributeAdHocNodes() {
223
		Graph graph = interpreter
220
		Graph graph = interpreter
224
				.interpret(parse("graph{edge[label=\"TEXT\"];1--2}")).get(0); //$NON-NLS-1$
221
				.interpret(
222
						parse(DotSampleGraphs.GLOBAL_EDGE_LABEL_AD_HOC_NODES))
223
				.get(0);
225
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
224
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
226
		Assert.assertEquals("TEXT", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$
225
		Assert.assertEquals("TEXT", DotAttributes.getLabel(graph.getEdges() //$NON-NLS-1$
227
				.get(0)));
226
				.get(0)));
Lines 230-236 Link Here
230
	@Test
229
	@Test
231
	public void headerCommentGraph() {
230
	public void headerCommentGraph() {
232
		Graph graph = interpreter
231
		Graph graph = interpreter
233
				.interpret(parse("/*A header comment*/\ngraph{1--2}")).get(0); //$NON-NLS-1$
232
				.interpret(parse(DotSampleGraphs.HEADER_COMMENT)).get(0);
234
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
233
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
235
		Assert.assertEquals(2, graph.getNodes().size());
234
		Assert.assertEquals(2, graph.getNodes().size());
236
		Assert.assertEquals(1, graph.getEdges().size());
235
		Assert.assertEquals(1, graph.getEdges().size());
Lines 239-245 Link Here
239
	@Test
238
	@Test
240
	public void nodesBeforeEdges() {
239
	public void nodesBeforeEdges() {
241
		Graph graph = interpreter
240
		Graph graph = interpreter
242
				.interpret(parse("graph{1;2;3;4; 1--2;2--3;2--4}")).get(0); //$NON-NLS-1$
241
				.interpret(parse(DotSampleGraphs.NODES_BEFORE_EDGES)).get(0);
243
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
242
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
244
		Assert.assertEquals(4, graph.getNodes().size());
243
		Assert.assertEquals(4, graph.getNodes().size());
245
		Assert.assertEquals(3, graph.getEdges().size());
244
		Assert.assertEquals(3, graph.getEdges().size());
Lines 248-256 Link Here
248
	@Test
247
	@Test
249
	public void nodesAfterEdges() {
248
	public void nodesAfterEdges() {
250
		Graph graph = interpreter
249
		Graph graph = interpreter
251
				.interpret(
250
				.interpret(parse(DotSampleGraphs.NODES_AFTER_EDGES)).get(0);
252
						parse("graph{1--2;2--3;2--4;1[label=\"node\"];2;3;4}")) //$NON-NLS-1$
253
				.get(0);
254
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
251
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
255
		Assert.assertEquals(4, graph.getNodes().size());
252
		Assert.assertEquals(4, graph.getNodes().size());
256
		Assert.assertEquals(3, graph.getEdges().size());
253
		Assert.assertEquals(3, graph.getEdges().size());
Lines 260-266 Link Here
260
257
261
	@Test
258
	@Test
262
	public void useInterpreterTwice() {
259
	public void useInterpreterTwice() {
263
		String dot = "graph{1;2;3;4; 1--2;2--3;2--4}"; //$NON-NLS-1$
260
		String dot = DotSampleGraphs.NODES_AFTER_EDGES;
264
		Graph graph = interpreter.interpret(parse(dot)).get(0);
261
		Graph graph = interpreter.interpret(parse(dot)).get(0);
265
		graph = interpreter.interpret(parse(dot)).get(0);
262
		graph = interpreter.interpret(parse(dot)).get(0);
266
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
263
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
Lines 270-277 Link Here
270
267
271
	@Test
268
	@Test
272
	public void idsWithQuotes() {
269
	public void idsWithQuotes() {
273
		String dot = "graph{\"node 1\";\"node 2\"}"; //$NON-NLS-1$
270
		Graph graph = interpreter
274
		Graph graph = interpreter.interpret(parse(dot)).get(0);
271
				.interpret(parse(DotSampleGraphs.IDS_WITH_QUOTES)).get(0);
275
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
272
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
276
		List<Node> list = graph.getNodes();
273
		List<Node> list = graph.getNodes();
277
		Assert.assertEquals("node 1", //$NON-NLS-1$
274
		Assert.assertEquals("node 1", //$NON-NLS-1$
Lines 282-289 Link Here
282
279
283
	@Test
280
	@Test
284
	public void escapedQuotes() {
281
	public void escapedQuotes() {
285
		String dot = "graph{n1[label=\"node \\\"1\\\"\"]}"; //$NON-NLS-1$
282
		Graph graph = interpreter
286
		Graph graph = interpreter.interpret(parse(dot)).get(0);
283
				.interpret(parse(DotSampleGraphs.ESCAPED_QUOTES_LABEL)).get(0);
287
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
284
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
288
		Assert.assertEquals("node \"1\"", //$NON-NLS-1$
285
		Assert.assertEquals("node \"1\"", //$NON-NLS-1$
289
				DotAttributes.getLabel(graph.getNodes().get(0)));
286
				DotAttributes.getLabel(graph.getNodes().get(0)));
Lines 291-298 Link Here
291
288
292
	@Test
289
	@Test
293
	public void fullyQuoted() {
290
	public void fullyQuoted() {
294
		String dot = "graph{\"n1\";\"n2\";\"n1\"--\"n2\"}"; //$NON-NLS-1$
291
		Graph graph = interpreter
295
		Graph graph = interpreter.interpret(parse(dot)).get(0);
292
				.interpret(parse(DotSampleGraphs.FULLY_QUOTED_IDS)).get(0);
296
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
293
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
297
		Assert.assertEquals(2, graph.getNodes().size());
294
		Assert.assertEquals(2, graph.getNodes().size());
298
		Assert.assertEquals(1, graph.getEdges().size());
295
		Assert.assertEquals(1, graph.getEdges().size());
Lines 305-312 Link Here
305
302
306
	@Test
303
	@Test
307
	public void labelsWithQuotes() {
304
	public void labelsWithQuotes() {
308
		String dot = "graph{n1[label=\"node 1\"];n2[label=\"node 2\"];n1--n2[label=\"edge 1\"]}"; //$NON-NLS-1$
305
		Graph graph = interpreter
309
		Graph graph = interpreter.interpret(parse(dot)).get(0);
306
				.interpret(parse(DotSampleGraphs.QUOTED_LABELS)).get(0);
310
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
307
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
311
		List<Node> list = graph.getNodes();
308
		List<Node> list = graph.getNodes();
312
		Assert.assertEquals("node 1", //$NON-NLS-1$
309
		Assert.assertEquals("node 1", //$NON-NLS-1$
Lines 319-334 Link Here
319
316
320
	@Test
317
	@Test
321
	public void newLinesInLabels() {
318
	public void newLinesInLabels() {
322
		String dot = "graph{n1[label=\"node\n1\"]}"; //$NON-NLS-1$
319
		Graph graph = interpreter
323
		Graph graph = interpreter.interpret(parse(dot)).get(0);
320
				.interpret(parse(DotSampleGraphs.NEW_LINES_IN_LABELS)).get(0);
324
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
321
		Assert.assertNotNull("Created graph must not be null", graph); //$NON-NLS-1$
325
		Assert.assertEquals("node\n1", //$NON-NLS-1$
322
		Assert.assertEquals("node" + System.lineSeparator() + "1", //$NON-NLS-1$
326
				DotAttributes.getLabel(graph.getNodes().get(0)));
323
				DotAttributes.getLabel(graph.getNodes().get(0)));
327
	}
324
	}
328
325
329
	@Test
326
	@Test
330
	public void multiEdgeStatements() {
327
	public void multiEdgeStatements() {
331
		Graph graph = new DotImport().importDot("digraph{1->2->3->4}"); //$NON-NLS-1$
328
		Graph graph = new DotImport()
329
				.importDot(DotSampleGraphs.MULTI_EDGE_STATEMENTS);
332
		assertEquals(4, graph.getNodes().size());
330
		assertEquals(4, graph.getNodes().size());
333
		assertEquals(3, graph.getEdges().size());
331
		assertEquals(3, graph.getEdges().size());
334
		/* Each node should be connected to one other, the previous node: */
332
		/* Each node should be connected to one other, the previous node: */
Lines 350-356 Link Here
350
	@Test
348
	@Test
351
	/* see http://www.graphviz.org/doc/info/attrs.html#d:style */
349
	/* see http://www.graphviz.org/doc/info/attrs.html#d:style */
352
	public void edgeStyleInvis() {
350
	public void edgeStyleInvis() {
353
		Graph graph = new DotImport().importDot("digraph{1->2[style=invis]}");
351
		Graph graph = new DotImport()
352
				.importDot(DotSampleGraphs.EDGE_STYLE_INVIS);
354
		assertEquals(2, graph.getNodes().size());
353
		assertEquals(2, graph.getNodes().size());
355
		assertEquals(1, graph.getEdges().size());
354
		assertEquals(1, graph.getEdges().size());
356
	}
355
	}
(-)a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotParserTests.java (-23 / +103 lines)
Lines 56-122 Link Here
56
56
57
	@Test
57
	@Test
58
	public void testEmptyGraph() {
58
	public void testEmptyGraph() {
59
		testString("graph {}");
59
		testString(DotSampleGraphs.EMPTY);
60
	}
60
	}
61
61
62
	@Test
62
	@Test
63
	public void testEmptyDirectedGraph() {
63
	public void testEmptyDirectedGraph() {
64
		testString("digraph {}");
64
		testString(DotSampleGraphs.EMPTY_DIRECTED);
65
	}
65
	}
66
66
67
	@Test
67
	@Test
68
	public void testEmptyStrictGraph() {
68
	public void testEmptyStrictGraph() {
69
		testString("strict graph {}");
69
		testString(DotSampleGraphs.EMPTY_STRICT);
70
	}
70
	}
71
71
72
	@Test
72
	@Test
73
	public void testEmptyStrictDirectedGraph() {
73
	public void testEmptyStrictDirectedGraph() {
74
		testString("strict digraph {}");
74
		testString(DotSampleGraphs.EMPTY_STRICT_DIRECTED);
75
	}
75
	}
76
76
77
	@Test
77
	@Test
78
	public void testGraphWithOneNode() {
78
	public void testGraphWithOneNode() {
79
		testString("graph {n1}");
79
		testString(DotSampleGraphs.ONE_NODE);
80
	}
80
	}
81
81
82
	@Test
82
	@Test
83
	public void testGraphWithOneNodeAndEmptyNodeAttributeList() {
83
	public void testGraphWithOneNodeAndEmptyNodeAttributeList() {
84
		testString("graph {n1[]}");
84
		testString(DotSampleGraphs.EMPTY_NODE_ATTRIBUTE_LIST);
85
	}
85
	}
86
86
87
	@Test
87
	@Test
88
	public void testGraphWithOneEdge() {
88
	public void testGraphWithOneEdge() {
89
		testString("graph {n1--n2}");
89
		testString(DotSampleGraphs.ONE_EDGE);
90
	}
91
92
	@Test
93
	public void testDirectedGraphWithOneEdge() {
94
		testString(DotSampleGraphs.ONE_DIRECTED_EDGE);
90
	}
95
	}
91
96
92
	@Test
97
	@Test
93
	public void testGraphWithOneEdgeAndEmptyEdgeAttributeList() {
98
	public void testGraphWithOneEdgeAndEmptyEdgeAttributeList() {
94
		testString("graph {n1--n2[]}");
99
		testString(DotSampleGraphs.EMPTY_EDGE_ATTRIBUTE_LIST);
100
	}
101
102
	@Test
103
	public void testDirectedGraphWithOneEdgeAndEmptyEdgeAttributeList() {
104
		testString(DotSampleGraphs.EMPTY_DIRECTED_EDGE_ATTRIBUTE_LIST);
95
	}
105
	}
96
106
97
	@Test
107
	@Test
98
	public void testGraphWithEmptyGraphAttributeStatement() {
108
	public void testGraphWithEmptyGraphAttributeStatement() {
99
		testString("graph {graph[]}");
109
		testString(DotSampleGraphs.EMPTY_GRAPH_ATTRIBUTE_STATEMENT);
100
	}
110
	}
101
111
102
	@Test
112
	@Test
103
	public void testGraphWithEmptyNodeAttributeStatement() {
113
	public void testGraphWithEmptyNodeAttributeStatement() {
104
		testString("graph {node[]}");
114
		testString(DotSampleGraphs.EMPTY_NODE_ATTRIBUTE_STATEMENT);
105
	}
115
	}
106
116
107
	@Test
117
	@Test
108
	public void testGraphWithEmptyEdgeAttributeStatement() {
118
	public void testGraphWithEmptyEdgeAttributeStatement() {
109
		testString("graph {edge[]}");
119
		testString(DotSampleGraphs.EMPTY_EDGE_ATTRIBUTE_STATEMENT);
110
	}
111
112
	@Test
113
	public void testArrowShapesSingle() {
114
		testFile("arrowshapes_single.dot");
115
	}
116
117
	@Test
118
	public void testArrowShapesMultiple() {
119
		testFile("arrowshapes_multiple.dot");
120
	}
120
	}
121
121
122
	@Test
122
	@Test
Lines 125-131 Link Here
125
	}
125
	}
126
126
127
	@Test
127
	@Test
128
	public void testArrowshapesDirectionBoth() {
128
	public void testArrowShapesDirectionBoth() {
129
		testFile("arrowshapes_direction_both.dot");
129
		testFile("arrowshapes_direction_both.dot");
130
	}
130
	}
131
131
Lines 135-145 Link Here
135
	}
135
	}
136
136
137
	@Test
137
	@Test
138
	public void testPolygonBasedNodeShapes() {
138
	public void testArrowShapesMultiple() {
139
		testFile("arrowshapes_multiple.dot");
140
	}
141
142
	@Test
143
	public void testArrowShapesSingle() {
144
		testFile("arrowshapes_single.dot");
145
	}
146
147
	@Test
148
	public void testAttributesGraph() {
149
		testFile("attributes_graph.dot");
150
	}
151
152
	@Test
153
	public void testBasicDirectedGraph() {
154
		testFile("basic_directed_graph.dot");
155
	}
156
157
	@Test
158
	public void testGlobalEdgeGraph() {
159
		testFile("global_edge_graph.dot");
160
	}
161
162
	@Test
163
	public void testGlobalNodeGraph() {
164
		testFile("global_node_graph.dot");
165
	}
166
167
	@Test
168
	public void testIdMatchesKeyword() {
169
		testFile("id_matches_keyword.dot");
170
	}
171
172
	@Test
173
	public void testLabeledGraph() {
174
		testFile("labeled_graph.dot");
175
	}
176
177
	@Test
178
	public void testLayoutGridGraph() {
179
		testFile("layout_grid_graph.dot");
180
	}
181
182
	@Test
183
	public void testLayoutRadialGraph() {
184
		testFile("layout_radial_graph.dot");
185
	}
186
187
	@Test
188
	public void testLayoutSpringGraph() {
189
		testFile("layout_spring_graph.dot");
190
	}
191
192
	@Test
193
	public void testLayoutTreeGraph() {
194
		testFile("layout_tree_graph.dot");
195
	}
196
197
	@Test
198
	public void testNodeShapesPolygonBased() {
139
		testFile("nodeshapes_polygon_based.dot");
199
		testFile("nodeshapes_polygon_based.dot");
140
	}
200
	}
141
201
142
	@Test
202
	@Test
203
	public void testNodeGroups() {
204
		testFile("node_groups.dot");
205
	}
206
207
	@Test
208
	public void testSampleInput() {
209
		testFile("sample_input.dot");
210
	}
211
212
	@Test
213
	public void testSimpleDigraph() {
214
		testFile("simple_digraph.dot");
215
	}
216
217
	@Test
218
	public void testSimpleGraph() {
219
		testFile("simple_graph.dot");
220
	}
221
222
	@Test
143
	public void testStyledGraph() {
223
	public void testStyledGraph() {
144
		testFile("styled_graph.dot");
224
		testFile("styled_graph.dot");
145
	}
225
	}
(-)a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotSampleGraphs.xtend (+312 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2016 itemis AG and others.
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     Tamas Miklossy (itemis AG) - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.gef4.dot.tests
14
15
class DotSampleGraphs {
16
	
17
	public static val EMPTY = '''
18
		graph {}
19
	'''
20
	
21
	public static val EMPTY_DIRECTED = '''
22
		digraph {}
23
	'''
24
	
25
	public static val EMPTY_STRICT = '''
26
		strict graph {}
27
	'''
28
	
29
	public static val EMPTY_STRICT_DIRECTED = '''
30
		strict digraph {}
31
	'''
32
	
33
	public static val ONE_NODE = '''
34
		graph {
35
			1
36
		}
37
	'''
38
	
39
	public static val TWO_NODES = '''
40
		graph {
41
			1
42
			2
43
		}
44
	'''
45
	
46
	public static val ONE_EDGE = '''
47
		graph {
48
			1--2
49
		}
50
	'''	
51
	
52
	public static val ONE_DIRECTED_EDGE = '''
53
		digraph {
54
			1->2
55
		}
56
	'''
57
58
	public static val TWO_EDGES = '''
59
		graph {
60
			1--2
61
			3--4
62
		}
63
	'''	
64
	
65
	public static val TWO_NODES_ONE_EDGE = '''
66
		graph {
67
			1;2;
68
			1--2
69
		}
70
	'''
71
	
72
	public static val TWO_NODES_ONE_DIRECTED_EDGE = '''
73
		digraph {
74
			1;2;
75
			1->2
76
		}
77
	'''	
78
	
79
	public static val TWO_NODES_AND_THREE_EDGES = '''
80
		graph {
81
			1;2
82
			1--2
83
			2--2
84
			1--1
85
		}
86
	'''
87
	
88
	public static val EMPTY_NODE_ATTRIBUTE_LIST = '''
89
		graph {
90
			1[]
91
		}
92
	'''
93
	
94
	public static val EMPTY_EDGE_ATTRIBUTE_LIST = '''
95
		graph {
96
			1--2[]
97
		}
98
	'''
99
	
100
	public static val EMPTY_DIRECTED_EDGE_ATTRIBUTE_LIST = '''
101
		digraph {
102
			1->2[]
103
		}
104
	'''
105
	
106
	public static val EMPTY_GRAPH_ATTRIBUTE_STATEMENT = '''
107
		graph {
108
			graph[]
109
		}
110
	'''
111
	
112
	public static val EMPTY_NODE_ATTRIBUTE_STATEMENT = '''
113
		graph {
114
			node[]
115
		}
116
	'''
117
	
118
	public static val EMPTY_EDGE_ATTRIBUTE_STATEMENT = '''
119
		graph {
120
			edge[]
121
		}
122
	'''	
123
124
	public static val ESCAPED_QUOTES_LABEL = '''
125
		graph {
126
			n1[label="node \"1\""]
127
		}
128
	'''
129
	
130
	public static val FULLY_QUOTED_IDS = '''
131
		graph {
132
			"n1"
133
			"n2"
134
			"n1"--"n2"
135
		}
136
	'''
137
	
138
	public static val GLOBAL_EDGE_LABEL_AD_HOC_NODES = '''
139
		graph {
140
			edge[label="TEXT"]
141
			1--2
142
		}
143
	'''
144
	
145
	public static val GLOBAL_NODE_LABEL_AD_HOC_NODES = '''
146
		graph {
147
			node[label="TEXT"]
148
			1--2
149
		}
150
	'''
151
	
152
	public static val GRAPH_LAYOUT_DOT_HORIZONTAL = '''
153
		graph {
154
			graph[layout=dot]
155
			rankdir=LR
156
			1
157
		}
158
	'''
159
	
160
	public static val HEADER_COMMENT = '''
161
		/*A header comment*/
162
		graph {
163
			1--2
164
		}
165
	'''
166
167
	public static val IDS_WITH_QUOTES = '''
168
		graph {
169
			"node 1"
170
			"node 2"
171
		}
172
	'''
173
	
174
	public static val MULTI_EDGE_STATEMENTS = '''
175
		digraph {
176
			1->2->3->4
177
		}
178
	'''
179
	
180
	public static val NEW_LINES_IN_LABELS = '''
181
		graph {
182
			n1[label=
183
		"node
184
		1"]}
185
	'''
186
187
	public static val NODES_AFTER_EDGES = '''
188
		graph {
189
			1--2
190
			2--3
191
			2--4
192
			1[label="node"]
193
			2
194
			3
195
			4
196
		}
197
	'''
198
199
	public static val NODES_BEFORE_EDGES = '''
200
		graph {
201
			1;2;3;4
202
			1--2
203
			2--3
204
			2--4
205
		}
206
	'''
207
	
208
	public static val QUOTED_LABELS = '''
209
		graph {
210
			n1[label="node 1"]
211
			n2[label="node 2"]
212
			n1--n2[label="edge 1"]
213
		}
214
	'''
215
	
216
	
217
/*
218
 ************************************************************************************************************
219
 * Sample dot graphs with different dot attribute valid values
220
 ************************************************************************************************************
221
 */
222
223
	public static val GRAPH_LAYOUT_DOT = '''
224
		graph {
225
			graph[layout=dot]
226
			1
227
		}
228
	'''
229
	
230
	public static val GRAPH_LAYOUT_FDP = '''
231
		graph {
232
			graph[layout=fdp]
233
			1
234
		}
235
	'''	
236
	
237
	public static val GRAPH_LAYOUT_OSAGE = '''
238
		graph {
239
			graph[layout=osage]
240
			1
241
		}
242
	'''
243
	
244
	public static val GRAPH_LAYOUT_TWOPI = '''
245
		graph {
246
			graph[layout=twopi]
247
			1
248
		}
249
	''' 
250
	
251
	public static val GRAPH_RANKDIR_LR = '''
252
		graph {
253
			rankdir=LR
254
			1
255
		}
256
	'''
257
			
258
	public static val EDGE_STYLE_INVIS = '''
259
		digraph {
260
			1->2[style=invis]
261
		}
262
	'''	
263
264
/*
265
 ************************************************************************************************************
266
 * Sample dot graphs with local/global/override dot attributes
267
 ************************************************************************************************************
268
 */
269
	
270
	public static val NODE_LABEL_LOCAL = '''
271
		graph {
272
			1[label="Node1"]
273
		}
274
	'''
275
	
276
	public static val NODE_LABEL_GLOBAL = '''
277
		graph {
278
			node[label="Node1"]
279
			1
280
		}
281
	'''	
282
	
283
	public static val EDGE_LABEL_LOCAL = '''
284
		graph {
285
			1;2;
286
			1--2[label="Edge1"]
287
		}
288
	'''
289
	
290
	public static val EDGE_LABEL_GLOBAL = '''
291
		graph {
292
			edge[label="Edge1"]
293
			1;2
294
			1--2
295
		}
296
	'''
297
	
298
	public static val EDGE_STYLE_GLOBAL = '''
299
		graph {
300
			edge[style=dashed]
301
			1;2
302
			1--2
303
		}
304
	'''
305
	
306
	public static val EDGE_STYLE_LOCAL = '''
307
		graph {
308
			1;2;
309
			1->2[style=dashed]
310
		}
311
	'''
312
}

Return to bug 493136