-
Notifications
You must be signed in to change notification settings - Fork 20
/
XDSMLPerspective_Test.xtend
134 lines (113 loc) · 5.02 KB
/
XDSMLPerspective_Test.xtend
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
/*******************************************************************************
* Copyright (c) 2016, 2017 Inria 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:
* Inria - initial API and implementation
*******************************************************************************/
package org.eclipse.gemoc.studio.tests.system.lwb.feature
import org.eclipse.gemoc.xdsmlframework.ide.ui.XDSMLFrameworkUI
import org.eclipse.gemoc.xdsmlframework.test.lib.MelangeUiInjectorProvider
import org.eclipse.gemoc.xdsmlframework.test.lib.WorkspaceTestHelper
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner
import org.eclipse.swtbot.swt.finder.keyboard.Keyboard
import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes
import org.eclipse.xtext.junit4.AbstractXtextTests
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException
import org.junit.Rule
import org.eclipse.gemoc.xdsmlframework.test.lib.TailWorkspaceLogToStderrRule
import org.eclipse.gemoc.commons.eclipse.messagingsystem.api.MessagingSystem
import org.junit.rules.TestName
import org.eclipse.gemoc.xdsmlframework.test.lib.GEMOCTestVideoHelper
import org.eclipse.gemoc.commons.eclipse.messagingsystem.api.MessagingSystemManager
/**
* This class check the content of the XDSML Perspective
*/
@RunWith(SWTBotJunit4ClassRunner)
@InjectWith(MelangeUiInjectorProvider)
//@FixMethodOrder(MethodSorters::NAME_ASCENDING)
public class XDSMLPerspective_Test extends AbstractXtextTests {
static WorkspaceTestHelper helper = new WorkspaceTestHelper
static SWTWorkbenchBot bot;
static MessagingSystem messaggingSystem
@Rule public TestName testName = new TestName();
@BeforeClass
def static void beforeClass() throws Exception {
GEMOCTestVideoHelper.addTestSuiteVideoLog("starting "+XDSMLPerspective_Test.canonicalName);
val MessagingSystemManager msm = new MessagingSystemManager()
messaggingSystem = msm.createBestPlatformMessagingSystem("","");
messaggingSystem.important(XDSMLPerspective_Test.canonicalName,"")
messaggingSystem.important(System.getProperty("user.dir"),"")
bot = new SWTWorkbenchBot()
SWTBotPreferences.TIMEOUT = WorkspaceTestHelper.SWTBotPreferencesTIMEOUT_4_GEMOC;
SWTBotPreferences.PLAYBACK_DELAY = WorkspaceTestHelper.SWTBotPreferencesPLAYBACK_DELAY_4_GEMOC;
IResourcesSetupUtil::cleanWorkspace
helper.init
}
@Before
override setUp() {
GEMOCTestVideoHelper.addTestSuiteVideoLog(" - "+testName.methodName);
bot.resetWorkbench
// helps to reset the workspace state by closing menu as bot.resetWorkbench is not enough
val Keyboard key = KeyboardFactory.getSWTKeyboard();
key.pressShortcut(Keystrokes.ESC);
// make sure we are on the correct perspective
bot.perspectiveById(XDSMLFrameworkUI.ID_PERSPECTIVE).activate()
// val projExplorerBot = bot.viewByTitle("Project Explorer").bot
}
@Rule
public TailWorkspaceLogToStderrRule workspaceLogRule = new TailWorkspaceLogToStderrRule();
@After
override tearDown() {
bot.sleep(500);
// Nothing to do
}
@Test
def void test01_FileMenuContent() throws Exception {
helper.assertContains("Menu does not contain", "GEMOC Java xDSML Project",
bot.menu("File").menu("New").menuItems())
helper.assertContains("Menu does not contain", "K3 Project", bot.menu("File").menu("New").menuItems())
helper.assertContains("Menu does not contain", "Ecore Modeling Project",
bot.menu("File").menu("New").menuItems())
}
@Test
def void test02_toolbarDropDownNewMenuContent() throws Exception {
val newMenu = bot.toolbarDropDownButtonWithTooltip("New")
newMenu.menuItem("K3 Project").click
bot.button("Cancel").click
newMenu.menuItem("GEMOC Java xDSML Project").click
bot.button("Cancel").click
newMenu.menuItem("Ecore Modeling Project").click
// Workaround to discard the error message that pops when webkitgtk is not installed on the system
// "Unknown Mozilla path (MOZILLA_FIVE_HOME not set)"
try {
bot.button("No").click
} catch (WidgetNotFoundException e) {
}
bot.shell("New Ecore Modeling Project").setFocus
bot.button("Cancel").click
}
@Test
def void test03_toolbarContent() throws Exception {
bot.toolbarButtonWithTooltip("Install GEMOC Components").click
bot.sleep(8000);
bot.shell("GEMOC Components Discovery").setFocus
try {
bot.toolbarButtonWithTooltip("Cancel Operation").click(); // the update site check may be very long -> do not wait
} catch (WidgetNotFoundException e) {}
bot.button("Cancel").click
}
}