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

Last change on this file since 293 was 293, checked in by boris, 19 years ago
  • changed all ö to utf-8 correct ö where wc was complaining, oh the excuses you can find to avoid studying math
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.NewClassWizard",
73                "org.modelica.mdt.NewPackageWizard",
74                /* generic wizards */
75                "org.eclipse.ui.wizards.new.folder",
76                "org.eclipse.ui.wizards.new.file"));
77       
78        /*
79         * init vector with expected new wizards shortcuts in
80         * modelica prespective
81         */             
82        assertTrue(Collections.addAll(showViewShortcuts,
83                /* modelica views */
84                "org.modelica.mdt.ProjectsView",
85                /* generic views */
86                IPageLayout.ID_PROBLEM_VIEW,
87                IConsoleConstants.ID_CONSOLE_VIEW));
88    }
89   
90    /**
91     * perform tests on modelica perspective
92     * @throws WorkbenchException
93     */
94    public void testModelicaPerspective() throws WorkbenchException
95    {
96        IWorkbench workbench = PlatformUI.getWorkbench(); 
97       
98        /*
99         * open modelica perspective
100         */
101        IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); 
102        workbench.showPerspective("org.modelica.mdt.perspective", window); 
103       
104        IWorkbenchPage page = window.getPages()[0];
105
106        /*
107         * check that all 'new wizards' shortcuts are installed
108         */
109        Vector<String> presentWizShortcuts = new Vector<String>();
110       
111        for (String scut : page.getNewWizardShortcuts())
112        {
113            presentWizShortcuts.addElement(scut);
114        }
115        assertTrue(presentWizShortcuts.containsAll(wizardShortcuts));
116               
117        /*
118         * check that all 'show view' shortcuts are installed
119         */
120        Vector<String> presentShowViewShortcuts = new Vector<String>();     
121        for (String scut : page.getShowViewShortcuts())
122        {
123            presentShowViewShortcuts.addElement(scut);
124        }
125        assertTrue(presentShowViewShortcuts.containsAll(showViewShortcuts));
126       
127        /*
128         * check that all views are present
129         */
130        assertNotNull(page.findView("org.modelica.mdt.ProjectsView"));
131        assertNotNull(page.findView(IConsoleConstants.ID_CONSOLE_VIEW));
132        assertNotNull(page.findView(IPageLayout.ID_PROBLEM_VIEW));
133
134    }
135    /**
136     * perform tests on modelica new wizards catagory
137     * @throws WorkbenchException
138     */
139   
140    public void testModelicaNewWizardsCatagory()
141    {
142        IWizardCategory category = 
143            PlatformUI.getWorkbench().getNewWizardRegistry().
144              findCategory("org.modelica.mdt.ModelicaCategory");
145               
146        assertNotNull("Modelica New Wizards catagory not found",  category);
147        assertEquals("Modelica New Wizards catagory labeled unexpectedly",
148                "Modelica", category.getLabel());
149       
150        assertNotNull("New Project Wizard not found", 
151                category.findWizard("org.modelica.mdt.NewProjectWizard"));
152       
153        assertNotNull("New Class Wizard not found", 
154                category.findWizard("org.modelica.mdt.NewClassWizard"));
155
156    }
157
158
159}
Note: See TracBrowser for help on using the repository browser.