diff --git a/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp b/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp index b22782e8e..cf7f4bdd7 100644 --- a/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp +++ b/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp @@ -67,9 +67,12 @@ #include #include #include + #include "FWBApplication.h" #include "UserWorkflow.h" #include "FWObjectClipboard.h" +#include "StartTipDialog.h" + using namespace std; using namespace QTest; @@ -81,7 +84,28 @@ void instDialogClusterTest::initTestCase() mw = new FWWindow(); wfl = new UserWorkflow(); mw->show(); + mw->startupLoad(); + + QTest::qWait(5000); + + StartTipDialog *d = mw->findChild(); + if (d!=NULL) d->close(); + mw->loadFile("test_work.fwb", false); + + QTest::qWait(1000); + + ObjectManipulator *om = mw->activeProject()->findChild("om"); + + FWObject *user_lib = mw->db()->findObjectByName(Library::TYPENAME, "User"); + QVERIFY(user_lib != NULL); + + om->openLibForObject(user_lib); + + FWObject *cl = om->getCurrentLib(); + + QVERIFY(cl != NULL); + QVERIFY(cl == user_lib); } void instDialogClusterTest::openPolicy(QString fwname) @@ -144,10 +168,15 @@ void instDialogClusterTest::closeContextMenu() menu->hide(); } -void instDialogClusterTest::openContextMenu(ObjectManipulator *om, ObjectTreeViewItem *item, ObjectTreeView *tree, const QString &actionText) +void instDialogClusterTest::openContextMenu(ObjectManipulator *om, + ObjectTreeViewItem *item, + ObjectTreeView *tree, + const QString &actionText) { QTimer::singleShot(100, this, SLOT(closeContextMenu())); - om->contextMenuRequested(findItemPos(item, tree)); + QPoint item_pos = findItemPos(item, tree); + om->contextMenuRequested(item_pos); + QMenu *menu; foreach(QWidget *w, QApplication::allWidgets()) { @@ -157,6 +186,7 @@ void instDialogClusterTest::openContextMenu(ObjectManipulator *om, ObjectTreeVie break; } } + foreach (QObject *act, menu->children()) { QAction *action = dynamic_cast(act); @@ -172,11 +202,22 @@ void instDialogClusterTest::openContextMenu(ObjectManipulator *om, ObjectTreeVie void instDialogClusterTest::page1_8() { ObjectTreeView *tree = mw->getCurrentObjectTree(); - ObjectTreeViewItem *test3 = dynamic_cast(tree->findItems("test3", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); - tree->selectionModel()->select(tree->indexAt(findItemPos(test3, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + QVERIFY(tree != NULL); + + ObjectTreeViewItem *test3 = dynamic_cast( + tree->findItems( + "test3", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); + QVERIFY(test3 != NULL); + + tree->selectionModel()->select( + tree->indexAt(findItemPos(test3, tree)), + QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->setCurrentItem(test3); - ObjectManipulator *om = mw->findChild("om"); + + ObjectManipulator *om = mw->activeProject()->findChild("om"); + openContextMenu(om, test3, tree, "Compile"); + instDialog *dlg = NULL; foreach (QWidget *w, app->allWidgets()) if (dynamic_cast(w) != NULL) @@ -207,7 +248,7 @@ void instDialogClusterTest::page1_9() ObjectTreeViewItem *cluster1 = dynamic_cast(tree->findItems("cluster1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); tree->selectionModel()->select(tree->indexAt(findItemPos(cluster1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->setCurrentItem(cluster1); - ObjectManipulator *om = mw->findChild("om"); + ObjectManipulator *om = mw->activeProject()->findChild("om"); openContextMenu(om, cluster1, tree, "Compile"); instDialog *dlg = NULL; foreach (QWidget *w, app->allWidgets()) diff --git a/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp b/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp index 2341fedbe..a8ad39162 100644 --- a/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp +++ b/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp @@ -134,7 +134,7 @@ void instDialogCompileTest::openContextMenu(ObjectManipulator *om, void instDialogCompileTest::testSelectButtonsVisibility() { - ObjectManipulator *om = mw->findChild("om"); + ObjectManipulator *om = mw->activeProject()->findChild("om"); ObjectTreeView *tree = om->getCurrentObjectTree(); tree->expandAll(); diff --git a/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp b/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp index 0c38a5874..79e5d0d44 100644 --- a/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp +++ b/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp @@ -62,7 +62,7 @@ void instDialogInspectTest::initTestCase() mw->show(); mw->loadFile("test_work.fwb", false); dialogClosed = false; - om = mw->findChild("om"); + om = mw->activeProject()->findChild("om"); tree = mw->activeProject()->getCurrentObjectTree(); tree->expandAll(); } diff --git a/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp b/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp index 7b4eb0137..a260f5733 100644 --- a/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp +++ b/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp @@ -390,7 +390,7 @@ void instDialogObjectListTest::test_compile_3() { openPolicy("test1"); QTest::qWait(10); - QToolButton* compileThis = mw->findChild("compile_this_fw"); + QToolButton* compileThis = mw->activeProject()->findChild("compile_this_fw"); QVERIFY(compileThis != NULL); QTest::mouseClick (compileThis, Qt::LeftButton); QTest::qWait(100); @@ -403,6 +403,7 @@ void instDialogObjectListTest::test_compile_3() QVERIFY(table != NULL); QVERIFY(table->isColumnHidden(COMPILE_CHECKBOX_COLUMN) == false); QVERIFY(table->isColumnHidden(INSTALL_CHECKBOX_COLUMN) == true); + QVERIFY(table->topLevelItemCount() == 1); verifyCompileCheckboxes(table, 1); QTest::qWait(100); @@ -419,7 +420,7 @@ void instDialogObjectListTest::test_compile_4() { openPolicy("test2"); QTest::qWait(100); - QToolButton* compileThis = mw->findChild("compile_this_fw"); + QToolButton* compileThis = mw->activeProject()->findChild("compile_this_fw"); QVERIFY(compileThis != NULL); QTest::mouseClick (compileThis, Qt::LeftButton); QTest::qWait(100); @@ -446,7 +447,7 @@ void instDialogObjectListTest::test_compile_4() void instDialogObjectListTest::test_compile_5() { - ObjectTreeView *tree = mw->getCurrentObjectTree(); + ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree(); tree->expandAll(); ObjectTreeViewItem *test1 = dynamic_cast(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); @@ -455,7 +456,7 @@ void instDialogObjectListTest::test_compile_5() tree->scrollToItem(test1); // <<<<<<<<<<<<<< tree->selectionModel()->select(tree->indexAt(findItemPos(test1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->setCurrentItem(test1); - ObjectManipulator *om = mw->findChild("om"); + ObjectManipulator *om = mw->activeProject()->findChild("om"); openContextMenu(om, test1, tree, "Compile"); instDialog *dlg = NULL; foreach (QWidget *w, app->allWidgets()) @@ -479,7 +480,7 @@ void instDialogObjectListTest::test_compile_5() */ void instDialogObjectListTest::test_compile_6() { - ObjectTreeView *tree = mw->getCurrentObjectTree(); + ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree(); tree->expandAll(); ObjectTreeViewItem *test1 = dynamic_cast(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); @@ -488,7 +489,7 @@ void instDialogObjectListTest::test_compile_6() tree->scrollToItem(test2); // <<<<<<<<<<<<<< tree->selectionModel()->select(tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->setCurrentItem(test2); - ObjectManipulator *om = mw->findChild("om"); + ObjectManipulator *om = mw->activeProject()->findChild("om"); openContextMenu(om, test2, tree, "Compile"); instDialog *dlg = NULL; foreach (QWidget *w, app->allWidgets()) @@ -513,7 +514,7 @@ void instDialogObjectListTest::test_compile_6() */ void instDialogObjectListTest::test_compile_7() { - ObjectTreeView *tree = mw->getCurrentObjectTree(); + ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree(); tree->expandAll(); ObjectTreeViewItem *test1 = dynamic_cast(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); @@ -527,7 +528,7 @@ void instDialogObjectListTest::test_compile_7() tree->selectionModel()->select( tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select); - ObjectManipulator *om = mw->findChild("om"); + ObjectManipulator *om = mw->activeProject()->findChild("om"); openContextMenu(om, test2, tree, "Compile"); instDialog *dlg = NULL; foreach (QWidget *w, app->allWidgets()) @@ -591,7 +592,7 @@ void instDialogObjectListTest::test_actually_compile_1() if (QFileInfo("test1.fw").exists()) QVERIFY(QFile("test1.fw").remove()); - ObjectTreeView *tree = mw->getCurrentObjectTree(); + ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree(); tree->expandAll(); ObjectTreeViewItem *test1 = dynamic_cast(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); @@ -605,7 +606,7 @@ void instDialogObjectListTest::test_actually_compile_1() tree->selectionModel()->select( tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select); - ObjectManipulator *om = mw->findChild("om"); + ObjectManipulator *om = mw->activeProject()->findChild("om"); openContextMenu(om, test2, tree, "Compile"); instDialog *dlg = NULL; foreach (QWidget *w, app->allWidgets())