blob: df8a5005e22487de07686a45df64c09a30ff8f17 (
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
|
/*****************************************************************************
* Copyright (c) 2018 CEA LIST, ALL4TEC 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:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.views.documentation.tests;
import static org.junit.Assert.assertNotNull;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.papyrus.infra.ui.util.EditorHelper;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
import org.eclipse.papyrus.views.documentation.Activator;
import org.eclipse.papyrus.views.documentation.views.DocumentationView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@PluginResource("/resources/documentationViewTests/model.di")
/**
* Class to test that the documentation view is well loaded.
*/
public class DocumentationViewTests extends AbstractPapyrusTest {
/** the id of the documentation view */
public static final String viewId = "org.eclipse.papyrus.views.documentation.DocumentationView"; //$NON-NLS-1$
/** Papyrus editor fixture. */
@Rule
public final PapyrusEditorFixture editorFixture = new PapyrusEditorFixture();
/** the documenation view */
private DocumentationView documentationView;
/**
* Initialize tests.
*/
@Before
public void initTests() {
Activator.getDefault().setToggleEditorSetting(true);
RunnableWithResult<?> runnable;
Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<Object>() {
public void run() {
documentationView = getDocumentationView();
documentationView.setFocus();
setStatus(Status.OK_STATUS);
}
});
Assert.assertEquals(runnable.getStatus().getMessage(), IStatus.OK, runnable.getStatus().getSeverity());
editorFixture.ensurePapyrusPerspective();
}
/**
* Test if the documentation view exist.
*/
@Test
public void documentationViewTests() {
assertNotNull("documentation view must exist", documentationView);
}
/**
* Show the view 'documentation'.
*/
public DocumentationView getDocumentationView() {
try {
final IWorkbenchPage activePage = EditorHelper.getActiveWindow().getActivePage();
return (DocumentationView) activePage.showView(DocumentationView.ID);
} catch (final PartInitException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
return null;
}
}
}
|