1 | /* |
---|
2 | * This file is part of Modelica Development Tooling. |
---|
3 | * |
---|
4 | * Copyright (c) 2005, Linköpings universitet, Department of |
---|
5 | * Computer and Information Science, PELAB |
---|
6 | * |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * (The new BSD license, see also |
---|
10 | * http://www.opensource.org/licenses/bsd-license.php) |
---|
11 | * |
---|
12 | * |
---|
13 | * Redistribution and use in source and binary forms, with or without |
---|
14 | * modification, are permitted provided that the following conditions are |
---|
15 | * met: |
---|
16 | * |
---|
17 | * * Redistributions of source code must retain the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer. |
---|
19 | * |
---|
20 | * * Redistributions in binary form must reproduce the above copyright |
---|
21 | * notice, this list of conditions and the following disclaimer in |
---|
22 | * the documentation and/or other materials provided with the |
---|
23 | * distribution. |
---|
24 | * |
---|
25 | * * Neither the name of Linköpings universitet nor the names of its |
---|
26 | * contributors may be used to endorse or promote products derived from |
---|
27 | * this software without specific prior written permission. |
---|
28 | * |
---|
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
32 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
33 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
34 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
35 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
36 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
37 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
39 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
40 | */ |
---|
41 | |
---|
42 | package org.modelica.mdt.test; |
---|
43 | |
---|
44 | import java.util.Collections; |
---|
45 | import java.util.Vector; |
---|
46 | |
---|
47 | import org.eclipse.ui.IWorkbench; |
---|
48 | import org.eclipse.ui.IWorkbenchPage; |
---|
49 | import org.eclipse.ui.IWorkbenchWindow; |
---|
50 | import org.eclipse.ui.PlatformUI; |
---|
51 | import org.eclipse.ui.WorkbenchException; |
---|
52 | import org.eclipse.ui.console.IConsoleConstants; |
---|
53 | import org.eclipse.ui.wizards.IWizardCategory; |
---|
54 | |
---|
55 | import junit.framework.TestCase; |
---|
56 | |
---|
57 | public class TestPerspective extends TestCase |
---|
58 | { |
---|
59 | private Vector<String> wizardShortcuts = new Vector<String>(4); |
---|
60 | private Vector<String> showViewShortcuts = new Vector<String>(2); |
---|
61 | |
---|
62 | @Override |
---|
63 | protected void setUp() throws Exception |
---|
64 | { |
---|
65 | /* |
---|
66 | * init vector with expected new wizards shortcuts in |
---|
67 | * modelica prespective |
---|
68 | */ |
---|
69 | assertTrue(Collections.addAll(wizardShortcuts, |
---|
70 | /* modelica wizards */ |
---|
71 | "org.modelica.mdt.NewProjectWizard", |
---|
72 | "org.modelica.mdt.NewClassWizard", |
---|
73 | /* generic wizards */ |
---|
74 | "org.eclipse.ui.wizards.new.folder", |
---|
75 | "org.eclipse.ui.wizards.new.file")); |
---|
76 | |
---|
77 | /* |
---|
78 | * init vector with expected new wizards shortcuts in |
---|
79 | * modelica prespective |
---|
80 | */ |
---|
81 | assertTrue(Collections.addAll(showViewShortcuts, |
---|
82 | /* modelica views */ |
---|
83 | "org.modelica.mdt.ProjectsView", |
---|
84 | /* generic views */ |
---|
85 | IConsoleConstants.ID_CONSOLE_VIEW)); |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | * perform tests on modelica perspective |
---|
90 | * @throws WorkbenchException |
---|
91 | */ |
---|
92 | public void testModelicaPerspective() throws WorkbenchException |
---|
93 | { |
---|
94 | IWorkbench workbench = PlatformUI.getWorkbench(); |
---|
95 | |
---|
96 | /* |
---|
97 | * open modelica perspective |
---|
98 | */ |
---|
99 | IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); |
---|
100 | workbench.showPerspective("org.modelica.mdt.perspective", window); |
---|
101 | |
---|
102 | IWorkbenchPage page = window.getPages()[0]; |
---|
103 | |
---|
104 | /* |
---|
105 | * check that all 'new wizards' shortcuts are installed |
---|
106 | */ |
---|
107 | Vector<String> presentWizShortcuts = new Vector<String>(); |
---|
108 | |
---|
109 | for (String scut : page.getNewWizardShortcuts()) |
---|
110 | { |
---|
111 | presentWizShortcuts.addElement(scut); |
---|
112 | } |
---|
113 | assertTrue(presentWizShortcuts.containsAll(wizardShortcuts)); |
---|
114 | |
---|
115 | /* |
---|
116 | * check that all 'show view' shortcuts are installed |
---|
117 | */ |
---|
118 | Vector<String> presentShowViewShortcuts = new Vector<String>(); |
---|
119 | for (String scut : page.getShowViewShortcuts()) |
---|
120 | { |
---|
121 | presentShowViewShortcuts.addElement(scut); |
---|
122 | } |
---|
123 | assertTrue(presentShowViewShortcuts.containsAll(showViewShortcuts)); |
---|
124 | |
---|
125 | /* |
---|
126 | * check that all views are present |
---|
127 | */ |
---|
128 | assertNotNull(page.findView("org.modelica.mdt.ProjectsView")); |
---|
129 | assertNotNull(page.findView(IConsoleConstants.ID_CONSOLE_VIEW)); |
---|
130 | |
---|
131 | } |
---|
132 | /** |
---|
133 | * perform tests on modelica new wizards catagory |
---|
134 | * @throws WorkbenchException |
---|
135 | */ |
---|
136 | |
---|
137 | public void testModelicaNewWizardsCatagory() |
---|
138 | { |
---|
139 | IWizardCategory category = |
---|
140 | PlatformUI.getWorkbench().getNewWizardRegistry(). |
---|
141 | findCategory("org.modelica.mdt.ModelicaCategory"); |
---|
142 | |
---|
143 | assertNotNull("Modelica New Wizards catagory not found", category); |
---|
144 | assertEquals("Modelica New Wizards catagory labeled unexpectedly", |
---|
145 | "Modelica", category.getLabel()); |
---|
146 | |
---|
147 | assertNotNull("New Project Wizard not found", |
---|
148 | category.findWizard("org.modelica.mdt.NewProjectWizard")); |
---|
149 | |
---|
150 | assertNotNull("New Class Wizard not found", |
---|
151 | category.findWizard("org.modelica.mdt.NewClassWizard")); |
---|
152 | |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | } |
---|