Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the model instance json (#9660)
Create a static lib of Util instead of compiling it for each test
- Loading branch information
Showing
16 changed files
with
337 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# This file is part of OpenModelica. | ||
# | ||
# Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), | ||
# c/o Linköpings universitet, Department of Computer and Information Science, | ||
# SE-58183 Linköping, Sweden. | ||
# | ||
# All rights reserved. | ||
# | ||
# THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR | ||
# THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2. | ||
# ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE | ||
# OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
# | ||
# The OpenModelica software and the Open Source Modelica | ||
# Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
# from OSMC, either from the above address, | ||
# from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
# http://www.openmodelica.org, and in the OpenModelica distribution. | ||
# GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
# | ||
# This program is distributed WITHOUT ANY WARRANTY; without | ||
# even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
# IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
# | ||
# See the full OSMC Public License conditions for more details. | ||
# | ||
#/ | ||
|
||
LIBS += -L../../bin/tests -lUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# This file is part of OpenModelica. | ||
# | ||
# Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), | ||
# c/o Linköpings universitet, Department of Computer and Information Science, | ||
# SE-58183 Linköping, Sweden. | ||
# | ||
# All rights reserved. | ||
# | ||
# THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR | ||
# THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2. | ||
# ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE | ||
# OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
# | ||
# The OpenModelica software and the Open Source Modelica | ||
# Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
# from OSMC, either from the above address, | ||
# from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
# http://www.openmodelica.org, and in the OpenModelica distribution. | ||
# GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
# | ||
# This program is distributed WITHOUT ANY WARRANTY; without | ||
# even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
# IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
# | ||
# See the full OSMC Public License conditions for more details. | ||
# | ||
#/ | ||
|
||
include(../Common/Testsuite.pri) | ||
include(../Common/Util.pri) | ||
|
||
TARGET = ModelInstance | ||
|
||
SOURCES += ModelInstanceTest.cpp | ||
|
||
HEADERS += ModelInstanceTest.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* This file is part of OpenModelica. | ||
* | ||
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), | ||
* c/o Linköpings universitet, Department of Computer and Information Science, | ||
* SE-58183 Linköping, Sweden. | ||
* | ||
* All rights reserved. | ||
* | ||
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR | ||
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2. | ||
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, | ||
* ACCORDING TO RECIPIENTS CHOICE. | ||
* | ||
* The OpenModelica software and the Open Source Modelica | ||
* Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
* from OSMC, either from the above address, | ||
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
* http://www.openmodelica.org, and in the OpenModelica distribution. | ||
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
* | ||
* See the full OSMC Public License conditions for more details. | ||
* | ||
*/ | ||
/* | ||
* @author Adeel Asghar <adeel.asghar@liu.se> | ||
*/ | ||
|
||
#include "ModelInstanceTest.h" | ||
#include "Util.h" | ||
#include "OMEditApplication.h" | ||
#include "MainWindow.h" | ||
#include "Modeling/LibraryTreeWidget.h" | ||
|
||
#define GC_THREADS | ||
extern "C" { | ||
#include "meta/meta_modelica.h" | ||
} | ||
|
||
OMEDITTEST_MAIN(ModelInstanceTest) | ||
|
||
void ModelInstanceTest::initTestCase() | ||
{ | ||
MainWindow::instance()->getLibraryWidget()->openFile(QFINDTESTDATA(mFileName)); | ||
if (!MainWindow::instance()->getOMCProxy()->existClass(mPackageName)) { | ||
QFAIL(QString("Failed to load file %1").arg(mFileName).toStdString().c_str()); | ||
} | ||
|
||
mpModelInstance = new ModelInstance::Model(MainWindow::instance()->getOMCProxy()->getModelInstance(mModelName)); | ||
} | ||
|
||
void ModelInstanceTest::classAnnotations() | ||
{ | ||
if (mpModelInstance->getIconAnnotation()->getGraphics().isEmpty()) { | ||
QFAIL("Failed to read the class icon annotation."); | ||
} | ||
|
||
if (mpModelInstance->getDiagramAnnotation()->getGraphics().isEmpty()) { | ||
QFAIL("Failed to read the class diagram annotation."); | ||
} | ||
} | ||
|
||
void ModelInstanceTest::classComponents() | ||
{ | ||
if (mpModelInstance->getElements().isEmpty()) { | ||
QFAIL("Failed to read the class components."); | ||
} | ||
} | ||
|
||
void ModelInstanceTest::classConnections() | ||
{ | ||
if (mpModelInstance->getConnections().isEmpty()) { | ||
QFAIL("Failed to read the class connections."); | ||
} | ||
} | ||
|
||
void ModelInstanceTest::classExtends() | ||
{ | ||
if (mpModelInstance->getExtends().isEmpty()) { | ||
QFAIL("Failed to read the class extends."); | ||
} | ||
} | ||
|
||
void ModelInstanceTest::cleanupTestCase() | ||
{ | ||
if (mpModelInstance) { | ||
delete mpModelInstance; | ||
} | ||
MainWindow::instance()->close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* This file is part of OpenModelica. | ||
* | ||
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), | ||
* c/o Linköpings universitet, Department of Computer and Information Science, | ||
* SE-58183 Linköping, Sweden. | ||
* | ||
* All rights reserved. | ||
* | ||
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR | ||
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2. | ||
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, | ||
* ACCORDING TO RECIPIENTS CHOICE. | ||
* | ||
* The OpenModelica software and the Open Source Modelica | ||
* Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
* from OSMC, either from the above address, | ||
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
* http://www.openmodelica.org, and in the OpenModelica distribution. | ||
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
* | ||
* See the full OSMC Public License conditions for more details. | ||
* | ||
*/ | ||
/* | ||
* @author Adeel Asghar <adeel.asghar@liu.se> | ||
*/ | ||
|
||
#ifndef DIAGRAM_H | ||
#define DIAGRAM_H | ||
|
||
#include <QObject> | ||
|
||
#include "Modeling/Model.h" | ||
|
||
/*! | ||
* \brief The ModelInstanceTest class | ||
* Tests the Model class. | ||
*/ | ||
class ModelInstanceTest: public QObject | ||
{ | ||
Q_OBJECT | ||
private: | ||
const QString mFileName = "ModelInstanceTest.mo"; | ||
const QString mPackageName = "P"; | ||
const QString mModelName = "P.M"; | ||
ModelInstance::Model *mpModelInstance = 0; | ||
private slots: | ||
void initTestCase(); | ||
/*! | ||
* \brief classAnnotations | ||
* Tests the class annotations like icon, diagram etc. | ||
*/ | ||
void classAnnotations(); | ||
/*! | ||
* \brief classComponents | ||
* Tests the class components. | ||
*/ | ||
void classComponents(); | ||
/*! | ||
* \brief classConnections | ||
* Tests the class connections. | ||
*/ | ||
void classConnections(); | ||
void classExtends(); | ||
void cleanupTestCase(); | ||
}; | ||
|
||
#endif // DIAGRAM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package P | ||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model A | ||
C c1, c2; | ||
equation | ||
connect(c1, c2); | ||
end A; | ||
|
||
model M | ||
extends A; | ||
|
||
C c3; | ||
equation | ||
connect(c1, c3) annotation(Line(points = {{-25, 30}, {10, 30}, {10, -20}, {40, -20}})); | ||
|
||
annotation ( | ||
Icon(graphics={Rectangle(extent={{-66,78},{70,-56}}, lineColor={28,108,200})}), | ||
Diagram(graphics={Ellipse(extent={{-62,68},{56,-60}}, lineColor={28,108,200})})); | ||
end M; | ||
end P; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.