${GUI_Event} ${GUI_OCCViewer} ${GEOM_GEOM} ${GEOM_GEOMBase}
${VTK_LIBRARIES} ${SVTK} ${SalomeObject} ${SalomePrs}
)
+
INSTALL(TARGETS HYDROGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
set(PROJECT_LIBRARIES HYDROGUI)
set(TEST_EXE test_HYDROGUI)
include(../../CMake/CPPUnitTests.cmake)
- target_link_libraries(test_HYDROGUI ${CAS_OCAF} ${CAS_MODELER} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} HYDROData HYDROGUI)
+ target_link_libraries(test_HYDROGUI ${CPPUNIT_LIBRARIES} HYDROData HYDROGUI)
+
+ INSTALL(TARGETS test_HYDROGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
endif(SALOME_BUILD_TESTS)
#ifndef HYDROGUI_ZLEVELSMODEL_H
#define HYDROGUI_ZLEVELSMODEL_H
+#include <HYDROGUI.h>
#include <HYDROData_Entity.h>
-
#include <QAbstractListModel>
#include <QPixmap>
* \class HYDROGUI_ZLevelsModel
* \brief The class representing custom list model for the Z levels
*/
-class HYDROGUI_ZLevelsModel : public QAbstractListModel
+class HYDRO_EXPORT HYDROGUI_ZLevelsModel : public QAbstractListModel
{
Q_OBJECT
bool isObjectVisible( int theIndex ) const;
private:
+ friend class test_HYDROGUI_ZLevelsModel;
+
Object2VisibleList myObjects;
QPixmap myEmpty, myEye;
};
#include <cppunit/TestRunner.h>
#include <cppunit/TextTestProgressListener.h>
#include <stdexcept>
+#include <QApplication>
-int
- main( int argc, char* argv[] )
+int main( int argc, char* argv[] )
{
+ QApplication anApp( argc, argv );
+
std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
// Create the event manager and test controller
-#include<test_HYDROGUI_ZLevelsModel.h>
+#undef HYDROGUI_EXPORTS
+
+#include <test_HYDROGUI_ZLevelsModel.h>
+#include <HYDROData_Document.h>
+#include <HYDROGUI_ZLevelsModel.h>
+
+Handle_HYDROData_Document GetDocument()
+{
+ return HYDROData_Document::Document( 0 );
+}
+
+HYDROGUI_ZLevelsModel::Object2VisibleList CreateTestObjects( int theObjCount )
+{
+ HYDROGUI_ZLevelsModel::Object2VisibleList anObjects;
+
+ for( int i=0; i<theObjCount; i++ )
+ {
+ Handle_HYDROData_Entity anObj = GetDocument()->CreateObject( KIND_IMMERSIBLE_ZONE );
+
+ std::string aName = " ";
+ aName[0] = 'A' + i;
+ anObj->SetName( QString::fromStdString( aName ) );
+
+ bool isVisible = i%2==0;
+
+ anObjects.append( HYDROGUI_ZLevelsModel::Object2Visible( anObj, isVisible ) );
+ }
+ return anObjects;
+}
+
+std::string test_HYDROGUI_ZLevelsModel::GetObjects( HYDROGUI_ZLevelsModel* theModel ) const
+{
+ std::string anObjects;
+ for( int i=0, n=theModel->myObjects.size(); i<n; i++ )
+ {
+ std::string anObjName = theModel->myObjects[i].first->GetName().toStdString();
+ if( theModel->isObjectVisible( i ) )
+ anObjName = "*" + anObjName;
+ if( i>0 )
+ anObjects += ", ";
+ anObjects += anObjName;
+ }
+ return anObjects;
+}
void test_HYDROGUI_ZLevelsModel::testMoveUp()
{
- CPPUNIT_ASSERT(1 == 2);
+ HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel();
+ aModel->setObjects( CreateTestObjects( 6 ) );
+
+ CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) );
+
+ delete aModel;
}
#include <cppunit/extensions/HelperMacros.h>
+class HYDROGUI_ZLevelsModel;
+
class test_HYDROGUI_ZLevelsModel : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(test_HYDROGUI_ZLevelsModel);
CPPUNIT_TEST(testMoveUp);
CPPUNIT_TEST_SUITE_END();
private:
+ std::string GetObjects( HYDROGUI_ZLevelsModel* theModel ) const;
public:
-
// checks move up
void testMoveUp();
};