source: trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestModelicaElementContentProvider.java @ 295

Last change on this file since 295 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: 4.1 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 org.eclipse.jface.viewers.TreeViewer;
45import org.eclipse.swt.widgets.Shell;
46import org.eclipse.ui.model.WorkbenchLabelProvider;
47import org.modelica.mdt.core.IModelicaProject;
48import org.modelica.mdt.core.ModelicaCore;
49import org.modelica.mdt.test.util.Area51Projects;
50import org.modelica.mdt.test.util.Utility;
51import org.modelica.mdt.ui.ModelicaElementContentProvider;
52import org.modelica.mdt.ui.SystemLibrary;
53
54import junit.framework.TestCase;
55
56/**
57 * @author Elmir Jagudin
58 */
59public class TestModelicaElementContentProvider extends TestCase
60{
61
62    private IModelicaProject modelicaProject;
63    private IModelicaProject nonModelicaProject;
64   
65    /* the test subject */
66    ModelicaElementContentProvider provider;
67
68   
69    @Override
70    protected void setUp() 
71    {
72        Area51Projects.createProjects();
73       
74        modelicaProject = 
75            Utility.getProject(Area51Projects.MODELICA_PROJECT_NAME);
76       
77        nonModelicaProject = 
78            Utility.getProject(Area51Projects.SIMPLE_PROJECT_NAME);
79       
80        /*
81         * the content provider must be hooked to a viewer
82         * and the input to the viewer must be set,
83         * otherwise stuff will break in bad ways
84         */
85        provider = new ModelicaElementContentProvider();
86        TreeViewer viewer = new TreeViewer(new Shell());
87        viewer.setLabelProvider(new WorkbenchLabelProvider());
88        viewer.setContentProvider(provider);
89        viewer.setInput(ModelicaCore.getModelicaRoot());
90    }
91   
92    /**
93     * this test checks that modelica elements have a system library element
94     * and non-modelica lacks it
95     */
96    public void testPresensOfSystemLibrary()
97    {
98       
99        /*
100         * check that the modelica project have a system library
101         */
102        boolean systemLibraryElementFound = false;
103        for (Object elm : provider.getChildren(modelicaProject))
104        {
105            if (elm instanceof SystemLibrary)
106            {
107                systemLibraryElementFound = true;
108                break;
109            }
110        }
111        assertTrue("no system library element found in modelica project",
112                systemLibraryElementFound);
113
114        /*
115         * check that the non-modelica project does _not_ have a system library
116         */
117        for (Object elm : provider.getChildren(nonModelicaProject))
118        {
119            if (elm instanceof SystemLibrary)
120            {
121                fail("non modelica project contains system library");
122            }
123        }
124    }
125
126}
Note: See TracBrowser for help on using the repository browser.