From 8fcb090760df865af55289e9cbd99a8bdb05cd0a Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Wed, 13 Jul 2011 18:24:16 -0700 Subject: [PATCH] applied patches by Vadim Zhukov persgray@gmail.com to unit tests --- .../generatedScriptTestsSecuwall.cpp | 14 +++++++++++++- .../instDialogClusterTest.cpp | 4 ++-- .../instDialogCompileTest.cpp | 2 +- .../instDialogInspectTest.cpp | 2 +- .../instDialogInstallTest.cpp | 10 ++++++++-- .../instDialogObjectListTest.cpp | 2 +- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/unit_tests/generatedScriptTestsSecuwall/generatedScriptTestsSecuwall.cpp b/src/unit_tests/generatedScriptTestsSecuwall/generatedScriptTestsSecuwall.cpp index 6fe7b3db7..b90625a81 100644 --- a/src/unit_tests/generatedScriptTestsSecuwall/generatedScriptTestsSecuwall.cpp +++ b/src/unit_tests/generatedScriptTestsSecuwall/generatedScriptTestsSecuwall.cpp @@ -92,11 +92,13 @@ void GeneratedScriptTest::runCompiler(const std::string &test_file, void GeneratedScriptTest::assertDirsEqual(const std::string &left_dir, const std::string &right_dir) { + QStringList leftList, rightList; QDirIterator leftIt(QString (left_dir.c_str()), QDir::Files, QDirIterator::Subdirectories); QDirIterator rightIt(QString (right_dir.c_str()), QDir::Files, QDirIterator::Subdirectories); while (leftIt.hasNext() && rightIt.hasNext()) { - assertFilesEqual(leftIt.next().toStdString(), rightIt.next().toStdString()); + leftList += leftIt.next(); + rightList += rightIt.next(); } if (leftIt.hasNext()) @@ -107,6 +109,16 @@ void GeneratedScriptTest::assertDirsEqual(const std::string &left_dir, { CPPUNIT_FAIL("Directory " + right_dir + " contains more files than " + left_dir); } + + leftList.sort(); + rightList.sort(); + + QList::const_iterator i, j; + for (i = leftList.constBegin(), j = rightList.constBegin(); + i != leftList.constEnd(); + ++i, ++j) { + assertFilesEqual(QString(*i).toStdString(), QString(*j).toStdString()); + } } void GeneratedScriptTest::assertFilesEqual(const std::string &left_filename, diff --git a/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp b/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp index cf7f4bdd7..70928647d 100644 --- a/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp +++ b/src/unit_tests/instDialogClusterTest/instDialogClusterTest.cpp @@ -156,7 +156,7 @@ QPoint findItemPos(ObjectTreeViewItem *item, ObjectTreeView *tree) void instDialogClusterTest::closeContextMenu() { - QMenu *menu; + QMenu *menu = NULL; foreach(QWidget *w, QApplication::allWidgets()) { if (w->objectName() == "objectTreeContextMenu") @@ -177,7 +177,7 @@ void instDialogClusterTest::openContextMenu(ObjectManipulator *om, QPoint item_pos = findItemPos(item, tree); om->contextMenuRequested(item_pos); - QMenu *menu; + QMenu *menu = NULL; foreach(QWidget *w, QApplication::allWidgets()) { if (w->objectName() == "objectTreeContextMenu") diff --git a/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp b/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp index a8ad39162..a1131d23a 100644 --- a/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp +++ b/src/unit_tests/instDialogCompileTest/instDialogCompileTest.cpp @@ -79,7 +79,7 @@ QPoint findItemPos(ObjectTreeViewItem *item, ObjectTreeView *tree) void instDialogCompileTest::closeContextMenu() { - QMenu *menu; + QMenu *menu = NULL; foreach(QWidget *w, QApplication::allWidgets()) { if (w->objectName() == "objectTreeContextMenu") diff --git a/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp b/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp index 79e5d0d44..cb1c31f50 100644 --- a/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp +++ b/src/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp @@ -97,7 +97,7 @@ QPoint findItemPos(ObjectTreeViewItem *item, ObjectTreeView *tree) void instDialogInspectTest::closeContextMenu() { - QMenu *menu; + QMenu *menu = NULL; foreach(QWidget *w, QApplication::allWidgets()) { if (w->objectName() == "objectTreeContextMenu") diff --git a/src/unit_tests/instDialogInstallTest/instDialogInstallTest.cpp b/src/unit_tests/instDialogInstallTest/instDialogInstallTest.cpp index ce7e9ed01..9163ef1c8 100644 --- a/src/unit_tests/instDialogInstallTest/instDialogInstallTest.cpp +++ b/src/unit_tests/instDialogInstallTest/instDialogInstallTest.cpp @@ -137,7 +137,10 @@ void instDialogInstallTest::initTestCase() void instDialogInstallTest::cleanupTestCase() { - setenv("SSH_AUTH_SOCK", ssh_auth_sock, 1); + if (ssh_auth_sock != NULL) + setenv("SSH_AUTH_SOCK", ssh_auth_sock, 1); + else + unsetenv("SSH_AUTH_SOCK"); QDir().rmdir("test_install"); QFile::remove("test1.fw"); } @@ -356,7 +359,10 @@ void instDialogInstallTest::testInstall2() { QVERIFY(list->topLevelItem(i)->text(1) == "Failure"); } - setenv("SSH_AUTH_SOCK", ssh_auth_sock, 1); + if (ssh_auth_sock != NULL) + setenv("SSH_AUTH_SOCK", ssh_auth_sock, 1); + else + unsetenv("SSH_AUTH_SOCK"); QString text = dlg->findChild("procLogDisplay")->toPlainText(); QVERIFY(!text.isEmpty()); diff --git a/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp b/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp index a260f5733..c797da09c 100644 --- a/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp +++ b/src/unit_tests/instDialogObjectListTest/instDialogObjectListTest.cpp @@ -270,7 +270,7 @@ QPoint findItemPos(ObjectTreeViewItem *item, ObjectTreeView *tree) void instDialogObjectListTest::closeContextMenu() { - QMenu *menu; + QMenu *menu = NULL; foreach(QWidget *w, QApplication::allWidgets()) { if (w->objectName() == "objectTreeContextMenu")