1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-18 09:18:23 +01:00

fixed broken unit tests

This commit is contained in:
Vadim Kurland 2011-07-08 19:12:50 -07:00
parent 8158519a06
commit e4c31fa623
4 changed files with 60 additions and 18 deletions

View File

@ -67,9 +67,12 @@
#include <QMenuBar> #include <QMenuBar>
#include <QApplication> #include <QApplication>
#include <QCoreApplication> #include <QCoreApplication>
#include "FWBApplication.h" #include "FWBApplication.h"
#include "UserWorkflow.h" #include "UserWorkflow.h"
#include "FWObjectClipboard.h" #include "FWObjectClipboard.h"
#include "StartTipDialog.h"
using namespace std; using namespace std;
using namespace QTest; using namespace QTest;
@ -81,7 +84,28 @@ void instDialogClusterTest::initTestCase()
mw = new FWWindow(); mw = new FWWindow();
wfl = new UserWorkflow(); wfl = new UserWorkflow();
mw->show(); mw->show();
mw->startupLoad();
QTest::qWait(5000);
StartTipDialog *d = mw->findChild<StartTipDialog*>();
if (d!=NULL) d->close();
mw->loadFile("test_work.fwb", false); mw->loadFile("test_work.fwb", false);
QTest::qWait(1000);
ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("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) void instDialogClusterTest::openPolicy(QString fwname)
@ -144,10 +168,15 @@ void instDialogClusterTest::closeContextMenu()
menu->hide(); 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())); QTimer::singleShot(100, this, SLOT(closeContextMenu()));
om->contextMenuRequested(findItemPos(item, tree)); QPoint item_pos = findItemPos(item, tree);
om->contextMenuRequested(item_pos);
QMenu *menu; QMenu *menu;
foreach(QWidget *w, QApplication::allWidgets()) foreach(QWidget *w, QApplication::allWidgets())
{ {
@ -157,6 +186,7 @@ void instDialogClusterTest::openContextMenu(ObjectManipulator *om, ObjectTreeVie
break; break;
} }
} }
foreach (QObject *act, menu->children()) foreach (QObject *act, menu->children())
{ {
QAction *action = dynamic_cast<QAction*>(act); QAction *action = dynamic_cast<QAction*>(act);
@ -172,11 +202,22 @@ void instDialogClusterTest::openContextMenu(ObjectManipulator *om, ObjectTreeVie
void instDialogClusterTest::page1_8() void instDialogClusterTest::page1_8()
{ {
ObjectTreeView *tree = mw->getCurrentObjectTree(); ObjectTreeView *tree = mw->getCurrentObjectTree();
ObjectTreeViewItem *test3 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test3", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); QVERIFY(tree != NULL);
tree->selectionModel()->select(tree->indexAt(findItemPos(test3, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
ObjectTreeViewItem *test3 = dynamic_cast<ObjectTreeViewItem*>(
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); tree->setCurrentItem(test3);
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om");
ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
openContextMenu(om, test3, tree, "Compile"); openContextMenu(om, test3, tree, "Compile");
instDialog *dlg = NULL; instDialog *dlg = NULL;
foreach (QWidget *w, app->allWidgets()) foreach (QWidget *w, app->allWidgets())
if (dynamic_cast<instDialog*>(w) != NULL) if (dynamic_cast<instDialog*>(w) != NULL)
@ -207,7 +248,7 @@ void instDialogClusterTest::page1_9()
ObjectTreeViewItem *cluster1 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("cluster1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); ObjectTreeViewItem *cluster1 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("cluster1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
tree->selectionModel()->select(tree->indexAt(findItemPos(cluster1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->selectionModel()->select(tree->indexAt(findItemPos(cluster1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
tree->setCurrentItem(cluster1); tree->setCurrentItem(cluster1);
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om"); ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
openContextMenu(om, cluster1, tree, "Compile"); openContextMenu(om, cluster1, tree, "Compile");
instDialog *dlg = NULL; instDialog *dlg = NULL;
foreach (QWidget *w, app->allWidgets()) foreach (QWidget *w, app->allWidgets())

View File

@ -134,7 +134,7 @@ void instDialogCompileTest::openContextMenu(ObjectManipulator *om,
void instDialogCompileTest::testSelectButtonsVisibility() void instDialogCompileTest::testSelectButtonsVisibility()
{ {
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om"); ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
ObjectTreeView *tree = om->getCurrentObjectTree(); ObjectTreeView *tree = om->getCurrentObjectTree();
tree->expandAll(); tree->expandAll();

View File

@ -62,7 +62,7 @@ void instDialogInspectTest::initTestCase()
mw->show(); mw->show();
mw->loadFile("test_work.fwb", false); mw->loadFile("test_work.fwb", false);
dialogClosed = false; dialogClosed = false;
om = mw->findChild<ObjectManipulator*>("om"); om = mw->activeProject()->findChild<ObjectManipulator*>("om");
tree = mw->activeProject()->getCurrentObjectTree(); tree = mw->activeProject()->getCurrentObjectTree();
tree->expandAll(); tree->expandAll();
} }

View File

@ -390,7 +390,7 @@ void instDialogObjectListTest::test_compile_3()
{ {
openPolicy("test1"); openPolicy("test1");
QTest::qWait(10); QTest::qWait(10);
QToolButton* compileThis = mw->findChild<QToolButton*>("compile_this_fw"); QToolButton* compileThis = mw->activeProject()->findChild<QToolButton*>("compile_this_fw");
QVERIFY(compileThis != NULL); QVERIFY(compileThis != NULL);
QTest::mouseClick (compileThis, Qt::LeftButton); QTest::mouseClick (compileThis, Qt::LeftButton);
QTest::qWait(100); QTest::qWait(100);
@ -403,6 +403,7 @@ void instDialogObjectListTest::test_compile_3()
QVERIFY(table != NULL); QVERIFY(table != NULL);
QVERIFY(table->isColumnHidden(COMPILE_CHECKBOX_COLUMN) == false); QVERIFY(table->isColumnHidden(COMPILE_CHECKBOX_COLUMN) == false);
QVERIFY(table->isColumnHidden(INSTALL_CHECKBOX_COLUMN) == true); QVERIFY(table->isColumnHidden(INSTALL_CHECKBOX_COLUMN) == true);
QVERIFY(table->topLevelItemCount() == 1);
verifyCompileCheckboxes(table, 1); verifyCompileCheckboxes(table, 1);
QTest::qWait(100); QTest::qWait(100);
@ -419,7 +420,7 @@ void instDialogObjectListTest::test_compile_4()
{ {
openPolicy("test2"); openPolicy("test2");
QTest::qWait(100); QTest::qWait(100);
QToolButton* compileThis = mw->findChild<QToolButton*>("compile_this_fw"); QToolButton* compileThis = mw->activeProject()->findChild<QToolButton*>("compile_this_fw");
QVERIFY(compileThis != NULL); QVERIFY(compileThis != NULL);
QTest::mouseClick (compileThis, Qt::LeftButton); QTest::mouseClick (compileThis, Qt::LeftButton);
QTest::qWait(100); QTest::qWait(100);
@ -446,7 +447,7 @@ void instDialogObjectListTest::test_compile_4()
void instDialogObjectListTest::test_compile_5() void instDialogObjectListTest::test_compile_5()
{ {
ObjectTreeView *tree = mw->getCurrentObjectTree(); ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree();
tree->expandAll(); tree->expandAll();
ObjectTreeViewItem *test1 = ObjectTreeViewItem *test1 =
dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
@ -455,7 +456,7 @@ void instDialogObjectListTest::test_compile_5()
tree->scrollToItem(test1); // <<<<<<<<<<<<<< tree->scrollToItem(test1); // <<<<<<<<<<<<<<
tree->selectionModel()->select(tree->indexAt(findItemPos(test1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->selectionModel()->select(tree->indexAt(findItemPos(test1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
tree->setCurrentItem(test1); tree->setCurrentItem(test1);
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om"); ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
openContextMenu(om, test1, tree, "Compile"); openContextMenu(om, test1, tree, "Compile");
instDialog *dlg = NULL; instDialog *dlg = NULL;
foreach (QWidget *w, app->allWidgets()) foreach (QWidget *w, app->allWidgets())
@ -479,7 +480,7 @@ void instDialogObjectListTest::test_compile_5()
*/ */
void instDialogObjectListTest::test_compile_6() void instDialogObjectListTest::test_compile_6()
{ {
ObjectTreeView *tree = mw->getCurrentObjectTree(); ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree();
tree->expandAll(); tree->expandAll();
ObjectTreeViewItem *test1 = ObjectTreeViewItem *test1 =
dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
@ -488,7 +489,7 @@ void instDialogObjectListTest::test_compile_6()
tree->scrollToItem(test2); // <<<<<<<<<<<<<< tree->scrollToItem(test2); // <<<<<<<<<<<<<<
tree->selectionModel()->select(tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); tree->selectionModel()->select(tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
tree->setCurrentItem(test2); tree->setCurrentItem(test2);
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om"); ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
openContextMenu(om, test2, tree, "Compile"); openContextMenu(om, test2, tree, "Compile");
instDialog *dlg = NULL; instDialog *dlg = NULL;
foreach (QWidget *w, app->allWidgets()) foreach (QWidget *w, app->allWidgets())
@ -513,7 +514,7 @@ void instDialogObjectListTest::test_compile_6()
*/ */
void instDialogObjectListTest::test_compile_7() void instDialogObjectListTest::test_compile_7()
{ {
ObjectTreeView *tree = mw->getCurrentObjectTree(); ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree();
tree->expandAll(); tree->expandAll();
ObjectTreeViewItem *test1 = ObjectTreeViewItem *test1 =
dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
@ -527,7 +528,7 @@ void instDialogObjectListTest::test_compile_7()
tree->selectionModel()->select( tree->selectionModel()->select(
tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select); tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select);
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om"); ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
openContextMenu(om, test2, tree, "Compile"); openContextMenu(om, test2, tree, "Compile");
instDialog *dlg = NULL; instDialog *dlg = NULL;
foreach (QWidget *w, app->allWidgets()) foreach (QWidget *w, app->allWidgets())
@ -591,7 +592,7 @@ void instDialogObjectListTest::test_actually_compile_1()
if (QFileInfo("test1.fw").exists()) if (QFileInfo("test1.fw").exists())
QVERIFY(QFile("test1.fw").remove()); QVERIFY(QFile("test1.fw").remove());
ObjectTreeView *tree = mw->getCurrentObjectTree(); ObjectTreeView *tree = mw->activeProject()->getCurrentObjectTree();
tree->expandAll(); tree->expandAll();
ObjectTreeViewItem *test1 = ObjectTreeViewItem *test1 =
dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first()); dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
@ -605,7 +606,7 @@ void instDialogObjectListTest::test_actually_compile_1()
tree->selectionModel()->select( tree->selectionModel()->select(
tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select); tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select);
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om"); ObjectManipulator *om = mw->activeProject()->findChild<ObjectManipulator*>("om");
openContextMenu(om, test2, tree, "Compile"); openContextMenu(om, test2, tree, "Compile");
instDialog *dlg = NULL; instDialog *dlg = NULL;
foreach (QWidget *w, app->allWidgets()) foreach (QWidget *w, app->allWidgets())