source: trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestPerspective.java @ 140

Last change on this file since 140 was 140, checked in by boris, 19 years ago
  • added problems view to modelica nature
File size: 5.2 KB
Line 
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
42package org.modelica.mdt.test;
43
44import java.util.Collections;
45import java.util.Vector;
46
47import org.eclipse.ui.IPageLayout;
48import org.eclipse.ui.IWorkbench;
49import org.eclipse.ui.IWorkbenchPage;
50import org.eclipse.ui.IWorkbenchWindow;
51import org.eclipse.ui.PlatformUI;
52import org.eclipse.ui.WorkbenchException;
53import org.eclipse.ui.console.IConsoleConstants;
54import org.eclipse.ui.wizards.IWizardCategory;
55
56import junit.framework.TestCase;
57
58public class TestPerspective extends TestCase
59{
60    private Vector<String> wizardShortcuts = new Vector<String>(4);
61    private Vector<String> showViewShortcuts = new Vector<String>(2);
62   
63    @Override
64    protected void setUp() throws Exception
65    {
66        /*
67         * init vector with expected new wizards shortcuts in
68         * modelica prespective
69         */             
70        assertTrue(Collections.addAll(wizardShortcuts,
71                /* modelica wizards */
72                "org.modelica.mdt.NewProjectWizard",
73                "org.modelica.mdt.NewClassWizard",
74                "org.modelica.mdt.NewPackageWizard",
75                /* generic wizards */
76                "org.eclipse.ui.wizards.new.folder",
77                "org.eclipse.ui.wizards.new.file"));
78       
79        /*
80         * init vector with expected new wizards shortcuts in
81         * modelica prespective
82         */             
83        assertTrue(Collections.addAll(showViewShortcuts,
84                /* modelica views */
85                "org.modelica.mdt.ProjectsView",
86                /* generic views */
87                IPageLayout.ID_PROBLEM_VIEW,
88                IConsoleConstants.ID_CONSOLE_VIEW));
89    }
90   
91    /**
92     * perform tests on modelica perspective
93     * @throws WorkbenchException
94     */
95    public void testModelicaPerspective() throws WorkbenchException
96    {
97        IWorkbench workbench = PlatformUI.getWorkbench(); 
98       
99        /*
100         * open modelica perspective
101         */
102        IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); 
103        workbench.showPerspective("org.modelica.mdt.perspective", window); 
104       
105        IWorkbenchPage page = window.getPages()[0];
106
107        /*
108         * check that all 'new wizards' shortcuts are installed
109         */
110        Vector<String> presentWizShortcuts = new Vector<String>();
111       
112        for (String scut : page.getNewWizardShortcuts())
113        {
114            presentWizShortcuts.addElement(scut);
115        }
116        assertTrue(presentWizShortcuts.containsAll(wizardShortcuts));
117               
118        /*
119         * check that all 'show view' shortcuts are installed
120         */
121        Vector<String> presentShowViewShortcuts = new Vector<String>();     
122        for (String scut : page.getShowViewShortcuts())
123        {
124            presentShowViewShortcuts.addElement(scut);
125        }
126        assertTrue(presentShowViewShortcuts.containsAll(showViewShortcuts));
127       
128        /*
129         * check that all views are present
130         */
131        assertNotNull(page.findView("org.modelica.mdt.ProjectsView"));
132        assertNotNull(page.findView(IConsoleConstants.ID_CONSOLE_VIEW));
133        assertNotNull(page.findView(IPageLayout.ID_PROBLEM_VIEW));
134
135    }
136    /**
137     * perform tests on modelica new wizards catagory
138     * @throws WorkbenchException
139     */
140   
141    public void testModelicaNewWizardsCatagory()
142    {
143        IWizardCategory category = 
144            PlatformUI.getWorkbench().getNewWizardRegistry().
145              findCategory("org.modelica.mdt.ModelicaCategory");
146               
147        assertNotNull("Modelica New Wizards catagory not found",  category);
148        assertEquals("Modelica New Wizards catagory labeled unexpectedly",
149                "Modelica", category.getLabel());
150       
151        assertNotNull("New Project Wizard not found", 
152                category.findWizard("org.modelica.mdt.NewProjectWizard"));
153       
154        assertNotNull("New Class Wizard not found", 
155                category.findWizard("org.modelica.mdt.NewClassWizard"));
156
157    }
158
159
160}
Note: See TracBrowser for help on using the repository browser.