diff --git a/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp b/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp new file mode 100644 index 000000000..263f47004 --- /dev/null +++ b/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.cpp @@ -0,0 +1,137 @@ +/* + + Firewall Builder + + Copyright (C) 2010 NetCitadel, LLC + + Author: Roman Bovsunivskiy a2k0001@gmail.com + + $Id: instDialogInspectTest.cpp 2786 2010-04-01 14:05:36Z a2k $ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + To get a copy of the GNU General Public License, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include "instDialogInspectTest.h" + +#include "unistd.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FWObjectClipboard.h" +#include "FWBApplication.h" + +using namespace std; +using namespace QTest; +using namespace libfwbuilder; + + +bool checkProgress(QTreeWidget *list) +{ + for(int i=0; itopLevelItemCount(); i++) + { + if ( (list->topLevelItem(i)->text(1).toStdString() == "Compiling ...") || + (list->topLevelItem(i)->text(1).toStdString() == "Installing ...") ) + return false; + } + return true; +} + +void instDialogInspectTest::initTestCase() +{ + mw = new FWWindow(); + mw->show(); + mw->loadFile("test_work.fwb", false); + FWObjectClipboard *clip = new FWObjectClipboard(); + dialogClosed = false; +} + +void instDialogInspectTest::cleanupTestCase() +{ + if (QFileInfo("test1.fw").exists()) + QVERIFY(QFile::remove("test1.fw")); + if (QFileInfo("test2.fw").exists()) + QVERIFY(QFile::remove("test2.fw")); + if (QFileInfo("test3.fw").exists()) + QVERIFY(QFile::remove("test3.fw")); + if (QFileInfo("test4.fw").exists()) + QVERIFY(QFile::remove("test4.fw")); +} + +void instDialogInspectTest::closeInstallOptions() +{ + QVERIFY(dynamic_cast(app->activeModalWidget()) != NULL); + app->activeModalWidget()->close(); + dialogClosed = true; +} + +void instDialogInspectTest::testInspect() +{ + mw->findChild("installAction")->trigger(); + instDialog *dlg = mw->findChild(); + + QTest::mouseClick(dlg->findChild("pushButton17"), Qt::LeftButton); + + QPushButton *back = dlg->findChild("backButton"); + QPushButton *next = dlg->findChild("nextButton"); + QPushButton *cancel = dlg->findChild("cancelButton"); + + QPushButton *inspect = dlg->findChild("inspectGeneratedFiles"); + + QTreeWidget *selectTable = dlg->findChild("selectTable"); + QTreeWidgetItem *test1item = selectTable->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first(); + test1item->setCheckState(1, Qt::Checked); + test1item->setCheckState(2, Qt::Checked); + + QTest::mouseClick(next, Qt::LeftButton); + + QTreeWidget *list= dlg->findChild("fwWorkList"); + QTextBrowser *processLogDisplay = dlg->findChild("procLogDisplay"); + + while (!checkProgress(list)) + { + QVERIFY(!inspect->isEnabled()); + QTest::qWait(50); + } + QTest::qWait(50); + QVERIFY(inspect->isEnabled()); + + QString oldtext = processLogDisplay->toPlainText(); + QStackedWidget *stack = dlg->findChild(); + + QVERIFY(stack->currentIndex() == 1); + QTest::mouseClick(inspect, Qt::LeftButton); + QVERIFY(stack->currentIndex() == 2); + QVERIFY(back->isEnabled()); + QVERIFY(next->isEnabled()); + + QTest::mouseClick(back, Qt::LeftButton); + QVERIFY(stack->currentIndex() == 1); + QVERIFY(oldtext == processLogDisplay->toPlainText()); + + QTest::mouseClick(inspect, Qt::LeftButton); + QTimer::singleShot(100, this, SLOT(closeInstallOptions())); + QTest::mouseClick(next, Qt::LeftButton); + QVERIFY(dialogClosed); + QVERIFY(stack->currentIndex() == 1); + + QTest::mouseClick(cancel, Qt::LeftButton); +} diff --git a/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.h b/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.h new file mode 100644 index 000000000..82819c3d8 --- /dev/null +++ b/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.h @@ -0,0 +1,56 @@ +/* + + Firewall Builder + + Copyright (C) 2010 NetCitadel, LLC + + Author: Roman Bovsunivskiy a2k0001@gmail.com + + $Id: instDialogInspectTest.h 2786 2010-04-01 14:05:36Z a2k $ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + To get a copy of the GNU General Public License, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#ifndef INSTDIALOGTEST_H +#define INSTDIALOGTEST_H + +#include + +#include "FWBTree.h" +#include "FWWindow.h" +#include "ObjectTreeView.h" +#include "ObjectTreeViewItem.h" +#include "events.h" +#include "fwbuilder/Firewall.h" +#include "fwbuilder/Library.h" +#include "fwbuilder/Policy.h" +#include "instDialog.h" +#include "newClusterDialog.h" +#include "upgradePredicate.h" + +class instDialogInspectTest : public QObject +{ + Q_OBJECT; + bool dialogClosed; +private slots: + void initTestCase(); + void cleanupTestCase(); + + void testInspect(); +public slots: + void closeInstallOptions(); +}; + +#endif // INSTDIALOGTEST_H diff --git a/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.pro b/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.pro new file mode 100644 index 000000000..2a5ec86a6 --- /dev/null +++ b/src/gui/unit_tests/instDialogInspectTest/instDialogInspectTest.pro @@ -0,0 +1,104 @@ +# ------------------------------------------------- +# Project created by QtCreator 2009-12-29T12:59:35 +# ------------------------------------------------- + +include(../../../../qmake.inc) + +QT += testlib network gui +TARGET = instDialogInspectTest +CONFIG += console +CONFIG -= app_bundle +TEMPLATE = app +SOURCES += main_instDialogInspectTest.cpp \ + instDialogInspectTest.cpp + +HEADERS += instDialogInspectTest.h + +RESOURCES += ../../MainRes.qrc +CONFIG -= release +CONFIG += debug +RESOURCES += ../../MainRes.qrc +LIBS += ../guilib/libguilib.a +LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS +OBJECTS_DIR = ../../.obj +MOC_DIR = ../../.moc + +INCLUDEPATH += ../../.ui +INCLUDEPATH += ../../../compiler_lib +INCLUDEPATH += ../../../iptlib +INCLUDEPATH += ../../../.. \ +../../../cisco_lib \ +../../../pflib \ +../../.. + +DEPENDPATH = ../../../common + +!win32:LIBS += ../../../common/libcommon.a +!win32:PRE_TARGETDEPS = ../../../common/libcommon.a + +win32:CONFIG += console + +win32:LIBS += ../../../common/release/common.lib +win32:PRE_TARGETDEPS = ../../../common/release/common.lib + + + +run_tests.commands = echo "Running tests..."; \ + cp -f test.fwb test_work.fwb; \ + ./${TARGET}; \ + rm test_work.fwb +run_tests.depends = build_tests +build_tests.depends = all +clean_tests.depends = all +QMAKE_EXTRA_TARGETS += run_tests build_tests clean_tests + + +INCLUDEPATH += $$ANTLR_INCLUDEPATH +LIBS += ../../$$FWBPARSER_LIB $$ANTLR_LIBS +DEFINES += $$ANTLR_DEFINES + +LIBS += $$LIBS_FWCOMPILER + +# fwtransfer lib. Add this before adding -lQtDBus to LIBS below +LIBS += ../../$$FWTRANSFER_LIB +contains( HAVE_QTDBUS, 1 ):unix { + !macx:QT += network \ + dbus + macx:LIBS += -framework \ + QtDBus +} + +HEADERS += ../../transferDialog.h +SOURCES += ../../transferDialog.cpp + +# !macx:LIBS += -lQtDBus # workaround for QT += dbus not working with Qt < 4.4.0 +INCLUDEPATH += ../../../common \ + ../../../iptlib \ + ../../../pflib \ + ../../../cisco_lib/ \ + ../../../compiler_lib/ +DEPENDPATH = ../../../common \ + ../../../iptlib \ + ../../../pflib \ + ../../../cisco_lib/ \ + ../../../compiler_lib +win32:LIBS += ../../../common/release/common.lib \ + ../../../iptlib/release/iptlib.lib \ + ../../../pflib/release/fwbpf.lib \ + ../../../cisco_lib/release/fwbcisco.lib \ + ../../../compiler_lib/release/compilerdriver.lib +!win32:LIBS += ../../../common/libcommon.a \ + ../../../iptlib/libiptlib.a \ + ../../../pflib/libfwbpf.a \ + ../../../cisco_lib/libfwbcisco.a \ + ../../../compiler_lib/libcompilerdriver.a +win32:PRE_TARGETDEPS = ../../../common/release/common.lib \ + ../../../iptlib/release/iptlib.lib \ + ../../../pflib/release/fwbpf.lib \ + ../../../cisco_lib/release/fwbcisco.lib \ + ../../../compiler_lib/release/compilerdriver.lib +!win32:PRE_TARGETDEPS = ../../../common/libcommon.a \ + ../../../iptlib/libiptlib.a \ + ../../../pflib/libfwbpf.a \ + ../../../cisco_lib/libfwbcisco.a \ + ../../../compiler_lib/libcompilerdriver.a diff --git a/src/gui/unit_tests/instDialogInspectTest/main_instDialogInspectTest.cpp b/src/gui/unit_tests/instDialogInspectTest/main_instDialogInspectTest.cpp new file mode 100644 index 000000000..4ce2aaf95 --- /dev/null +++ b/src/gui/unit_tests/instDialogInspectTest/main_instDialogInspectTest.cpp @@ -0,0 +1,30 @@ +/* + + Firewall Builder + + Copyright (C) 2010 NetCitadel, LLC + + Author: Roman Bovsunivskiy a2k0001@gmail.com + + $Id: main_instDialogInspectTest.cpp 2707 2010-03-10 18:22:19Z a2k $ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + To get a copy of the GNU General Public License, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include "instDialogInspectTest.h" +#include "../main/main_macros.cpp" + + +RUN_TEST(new instDialogInspectTest()); diff --git a/src/gui/unit_tests/instDialogInspectTest/test.fwb b/src/gui/unit_tests/instDialogInspectTest/test.fwb new file mode 100644 index 000000000..b5acaeadc --- /dev/null +++ b/src/gui/unit_tests/instDialogInspectTest/test.fwb @@ -0,0 +1,1352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + established + + established + -m state --state ESTABLISHED,RELATED + + + + established + + established + -m state --state ESTABLISHED,RELATED + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -m record_rpc + + + + + + + + + + -m irc + + + + + + + + + + -m psd --psd-weight-threshold 5 --psd-delay-threshold 10000 + + + + + + + + + + -m string --string test_pattern + + + + + + + + + + -m talk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +