mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-17 18:39:07 +02:00
UserServiceDialog, ICMP6ServiceDialog, ICMPServiceDialog and TagServiceDialog unit tests
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: ICMPServiceDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "ICMP6ServiceDialogTest.h"
|
||||
|
||||
#include "../../../../config.h"
|
||||
//#include "../../global.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qfile.h>
|
||||
#include <qtextstream.h>
|
||||
#include <QTest>
|
||||
#include <iostream>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectTreeView.h"
|
||||
#include "ObjectTreeViewItem.h"
|
||||
#include "ObjectEditor.h"
|
||||
#include "FWObjectClipboard.h"
|
||||
#include "TextEditWidget.h"
|
||||
#include "fwbuilder/Address.h"
|
||||
#include "fwbuilder/IPv4.h"
|
||||
#include "fwbuilder/IPv6.h"
|
||||
#include "FWBTree.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "StartTipDialog.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/Interface.h"
|
||||
#include "IPServiceDialog.h"
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/ICMP6Service.h"
|
||||
#include "ICMPServiceDialog.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
void ICMP6ServiceDialogTest::initTestCase()
|
||||
{
|
||||
new FWObjectClipboard();
|
||||
mw = new FWWindow();
|
||||
mw->show();
|
||||
mw->startupLoad();
|
||||
StartTipDialog *d = mw->findChild<StartTipDialog*>();
|
||||
d->close();
|
||||
om = dynamic_cast<ObjectManipulator*>(mw->getCurrentObjectTree()->parent()->parent());
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
Library* ICMP6ServiceDialogTest::findUserLibrary()
|
||||
{
|
||||
Library *lib = NULL;
|
||||
foreach (FWObject *obj, mw->db()->getByType(Library::TYPENAME))
|
||||
{
|
||||
if (obj->getName() == "User")
|
||||
{
|
||||
lib = Library::cast(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
||||
|
||||
void ICMP6ServiceDialogTest::testDialog()
|
||||
{
|
||||
ICMP6Service *service = ICMP6Service::cast(om->createObject(FWBTree().getStandardSlotForObject(findUserLibrary(), ICMP6Service::TYPENAME), ICMP6Service::TYPENAME, "testICMP6Service"));
|
||||
om->editObject(service);
|
||||
|
||||
ICMPServiceDialog *dialog = mw->findChild<ICMPServiceDialog*>("w_ICMP6ServiceDialog");
|
||||
QLineEdit *obj_name = dialog->findChild<QLineEdit*>("obj_name");
|
||||
QSpinBox *type = dialog->findChild<QSpinBox*>("icmpType");
|
||||
QSpinBox *code = dialog->findChild<QSpinBox*>("icmpCode");
|
||||
TextEditWidget *comment = dialog->findChild<TextEditWidget*>("comment");
|
||||
|
||||
obj_name->clear();
|
||||
QTest::keyClicks(obj_name, "TestICMPService");
|
||||
QTest::keyClick(obj_name, Qt::Key_Enter);
|
||||
QVERIFY(service->getName() == "TestICMPService");
|
||||
|
||||
comment->clear();
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClicks(comment, "Test comment");
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClick(comment, Qt::Key_Tab);
|
||||
QTest::qWait(100);
|
||||
QVERIFY (service->getComment() == "Test comment");
|
||||
|
||||
type->clear();
|
||||
for (int i=0; i<52; i++)
|
||||
QTest::keyClick(type, Qt::Key_Up);
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("type") == 50);
|
||||
|
||||
for (int i=0; i<210; i++)
|
||||
QTest::keyClick(type, Qt::Key_Up);
|
||||
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("type") == 255);
|
||||
|
||||
code->clear();
|
||||
for (int i=0; i<52; i++)
|
||||
QTest::keyClick(code, Qt::Key_Up);
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("code") == 50);
|
||||
|
||||
for (int i=0; i<210; i++)
|
||||
QTest::keyClick(code, Qt::Key_Up);
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("code") == 255);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2009 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: ICMP6ServiceDialogTest.h 2723 2010-03-16 17:32:18Z 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 ICMP6ServiceDialogTest_H
|
||||
#define ICMP6ServiceDialogTest_H
|
||||
|
||||
#include <QObject>
|
||||
#include "ObjectManipulator.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
|
||||
class ICMP6ServiceDialogTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
libfwbuilder::Library* findUserLibrary();
|
||||
ObjectManipulator *om;
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testDialog();
|
||||
};
|
||||
|
||||
#endif // ICMP6ServiceDialogTest_H
|
||||
@@ -0,0 +1,96 @@
|
||||
include(../../../../qmake.inc)
|
||||
include(../gui_common.inc)
|
||||
|
||||
QT += testlib network gui
|
||||
TARGET = ICMP6ServiceDialogTest
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
SOURCES += main_ICMP6ServiceDialogTest.cpp \
|
||||
ICMP6ServiceDialogTest.cpp
|
||||
|
||||
HEADERS += ICMP6ServiceDialogTest.h
|
||||
|
||||
CONFIG -= release
|
||||
CONFIG += debug
|
||||
LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS
|
||||
|
||||
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..."; \
|
||||
./${TARGET}
|
||||
run_tests.depends = build_tests
|
||||
build_tests.depends = all
|
||||
clean_tests.depends = all
|
||||
QMAKE_EXTRA_TARGETS += run_tests build_tests clean_tests
|
||||
|
||||
|
||||
contains( HAVE_ANTLR_RUNTIME, 1 ) {
|
||||
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
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: main_IPDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "ICMP6ServiceDialogTest.h"
|
||||
#include "FWWindow.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "common/commoninit.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include <QTest>
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
//std::string respath;
|
||||
//int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = NULL;
|
||||
FWBSettings *st = NULL;
|
||||
char** args;
|
||||
QApplication *app = NULL;
|
||||
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
app = new QApplication(argc, argv, 0);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
st = new FWBSettings();
|
||||
st->init();
|
||||
init(argv);
|
||||
|
||||
//respath = std::string(PREFIX) + "/share/libfwbuilder";
|
||||
//std::string full_res_path = std::string(PREFIX) + "/resources/resources.xml";
|
||||
|
||||
string full_res_path = respath + FS_SEPARATOR + "resources.xml";
|
||||
|
||||
try
|
||||
{
|
||||
new Resources(full_res_path);
|
||||
} catch (FWException &e)
|
||||
{
|
||||
cerr << "Can not read resource file from " << full_res_path << endl;
|
||||
}
|
||||
ICMP6ServiceDialogTest tst;
|
||||
QTest::qExec(&tst);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: ICMPServiceDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "ICMPServiceDialogTest.h"
|
||||
|
||||
#include "../../../../config.h"
|
||||
//#include "../../global.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qfile.h>
|
||||
#include <qtextstream.h>
|
||||
#include <QTest>
|
||||
#include <iostream>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectTreeView.h"
|
||||
#include "ObjectTreeViewItem.h"
|
||||
#include "ObjectEditor.h"
|
||||
#include "FWObjectClipboard.h"
|
||||
#include "TextEditWidget.h"
|
||||
#include "fwbuilder/Address.h"
|
||||
#include "fwbuilder/IPv4.h"
|
||||
#include "fwbuilder/IPv6.h"
|
||||
#include "FWBTree.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "ICMPServiceDialogTest.h"
|
||||
#include "StartTipDialog.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/Interface.h"
|
||||
#include "IPServiceDialog.h"
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/ICMPService.h"
|
||||
#include "ICMPServiceDialog.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
void ICMPServiceDialogTest::initTestCase()
|
||||
{
|
||||
new FWObjectClipboard();
|
||||
mw = new FWWindow();
|
||||
mw->show();
|
||||
mw->startupLoad();
|
||||
StartTipDialog *d = mw->findChild<StartTipDialog*>();
|
||||
d->close();
|
||||
om = dynamic_cast<ObjectManipulator*>(mw->getCurrentObjectTree()->parent()->parent());
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
Library* ICMPServiceDialogTest::findUserLibrary()
|
||||
{
|
||||
Library *lib = NULL;
|
||||
foreach (FWObject *obj, mw->db()->getByType(Library::TYPENAME))
|
||||
{
|
||||
if (obj->getName() == "User")
|
||||
{
|
||||
lib = Library::cast(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
||||
|
||||
void ICMPServiceDialogTest::testDialog()
|
||||
{
|
||||
ICMPService *service = ICMPService::cast(om->createObject(FWBTree().getStandardSlotForObject(findUserLibrary(), ICMPService::TYPENAME), ICMPService::TYPENAME, "testICMPService"));
|
||||
om->editObject(service);
|
||||
|
||||
ICMPServiceDialog *dialog = mw->findChild<ICMPServiceDialog*>("w_ICMPServiceDialog");
|
||||
QLineEdit *obj_name = dialog->findChild<QLineEdit*>("obj_name");
|
||||
QSpinBox *type = dialog->findChild<QSpinBox*>("icmpType");
|
||||
QSpinBox *code = dialog->findChild<QSpinBox*>("icmpCode");
|
||||
TextEditWidget *comment = dialog->findChild<TextEditWidget*>("comment");
|
||||
|
||||
obj_name->clear();
|
||||
QTest::keyClicks(obj_name, "TestICMPService");
|
||||
QTest::keyClick(obj_name, Qt::Key_Enter);
|
||||
QVERIFY(service->getName() == "TestICMPService");
|
||||
|
||||
comment->clear();
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClicks(comment, "Test comment");
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClick(comment, Qt::Key_Tab);
|
||||
QTest::qWait(100);
|
||||
QVERIFY (service->getComment() == "Test comment");
|
||||
|
||||
type->clear();
|
||||
for (int i=0; i<52; i++)
|
||||
QTest::keyClick(type, Qt::Key_Up);
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("type") == 50);
|
||||
|
||||
for (int i=0; i<210; i++)
|
||||
QTest::keyClick(type, Qt::Key_Up);
|
||||
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("type") == 255);
|
||||
|
||||
code->clear();
|
||||
for (int i=0; i<52; i++)
|
||||
QTest::keyClick(code, Qt::Key_Up);
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("code") == 50);
|
||||
|
||||
for (int i=0; i<210; i++)
|
||||
QTest::keyClick(code, Qt::Key_Up);
|
||||
QTest::keyClick(type, Qt::Key_Enter);
|
||||
QVERIFY(service->getInt("code") == 255);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2009 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: ICMPServiceDialogTest.h 2723 2010-03-16 17:32:18Z 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 ICMPServiceDialogTest_H
|
||||
#define ICMPServiceDialogTest_H
|
||||
|
||||
#include <QObject>
|
||||
#include "ObjectManipulator.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
|
||||
class ICMPServiceDialogTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
libfwbuilder::Library* findUserLibrary();
|
||||
ObjectManipulator *om;
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testDialog();
|
||||
};
|
||||
|
||||
#endif // ICMPServiceDialogTest_H
|
||||
@@ -0,0 +1,96 @@
|
||||
include(../../../../qmake.inc)
|
||||
include(../gui_common.inc)
|
||||
|
||||
QT += testlib network gui
|
||||
TARGET = ICMPServiceDialogTest
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
SOURCES += main_ICMPServiceDialogTest.cpp \
|
||||
ICMPServiceDialogTest.cpp
|
||||
|
||||
HEADERS += ICMPServiceDialogTest.h
|
||||
|
||||
CONFIG -= release
|
||||
CONFIG += debug
|
||||
LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS
|
||||
|
||||
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..."; \
|
||||
./${TARGET}
|
||||
run_tests.depends = build_tests
|
||||
build_tests.depends = all
|
||||
clean_tests.depends = all
|
||||
QMAKE_EXTRA_TARGETS += run_tests build_tests clean_tests
|
||||
|
||||
|
||||
contains( HAVE_ANTLR_RUNTIME, 1 ) {
|
||||
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
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: main_IPDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "ICMPServiceDialogTest.h"
|
||||
#include "FWWindow.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "common/commoninit.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include <QTest>
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
//std::string respath;
|
||||
//int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = NULL;
|
||||
FWBSettings *st = NULL;
|
||||
char** args;
|
||||
QApplication *app = NULL;
|
||||
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
app = new QApplication(argc, argv, 0);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
st = new FWBSettings();
|
||||
st->init();
|
||||
init(argv);
|
||||
|
||||
//respath = std::string(PREFIX) + "/share/libfwbuilder";
|
||||
//std::string full_res_path = std::string(PREFIX) + "/resources/resources.xml";
|
||||
|
||||
string full_res_path = respath + FS_SEPARATOR + "resources.xml";
|
||||
|
||||
try
|
||||
{
|
||||
new Resources(full_res_path);
|
||||
} catch (FWException &e)
|
||||
{
|
||||
cerr << "Can not read resource file from " << full_res_path << endl;
|
||||
}
|
||||
ICMPServiceDialogTest tst;
|
||||
QTest::qExec(&tst);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: TagServiceDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "TagServiceDialogTest.h"
|
||||
|
||||
#include "../../../../config.h"
|
||||
//#include "../../global.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qfile.h>
|
||||
#include <qtextstream.h>
|
||||
#include <QTest>
|
||||
#include <iostream>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectTreeView.h"
|
||||
#include "ObjectTreeViewItem.h"
|
||||
#include "ObjectEditor.h"
|
||||
#include "FWObjectClipboard.h"
|
||||
#include "TextEditWidget.h"
|
||||
#include "fwbuilder/Address.h"
|
||||
#include "fwbuilder/IPv4.h"
|
||||
#include "fwbuilder/IPv6.h"
|
||||
#include "FWBTree.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "TagServiceDialogTest.h"
|
||||
#include "StartTipDialog.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/Interface.h"
|
||||
#include "IPServiceDialog.h"
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/TagService.h"
|
||||
#include "TagServiceDialog.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
void TagServiceDialogTest::initTestCase()
|
||||
{
|
||||
new FWObjectClipboard();
|
||||
mw = new FWWindow();
|
||||
mw->show();
|
||||
mw->startupLoad();
|
||||
StartTipDialog *d = mw->findChild<StartTipDialog*>();
|
||||
d->close();
|
||||
om = dynamic_cast<ObjectManipulator*>(mw->getCurrentObjectTree()->parent()->parent());
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
Library* TagServiceDialogTest::findUserLibrary()
|
||||
{
|
||||
Library *lib = NULL;
|
||||
foreach (FWObject *obj, mw->db()->getByType(Library::TYPENAME))
|
||||
{
|
||||
if (obj->getName() == "User")
|
||||
{
|
||||
lib = Library::cast(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
||||
|
||||
void TagServiceDialogTest::testDialog()
|
||||
{
|
||||
TagService *service = TagService::cast(om->createObject(FWBTree().getStandardSlotForObject(findUserLibrary(), TagService::TYPENAME), TagService::TYPENAME, "testTagService"));
|
||||
om->editObject(service);
|
||||
|
||||
TagServiceDialog *dialog = mw->findChild<TagServiceDialog*>("w_TagServiceDialog");
|
||||
QLineEdit *obj_name = dialog->findChild<QLineEdit*>("obj_name");
|
||||
QLineEdit *tagcode = dialog->findChild<QLineEdit*>("tagcode");
|
||||
TextEditWidget *comment = dialog->findChild<TextEditWidget*>("comment");
|
||||
|
||||
obj_name->clear();
|
||||
QTest::keyClicks(obj_name, "TestTagService");
|
||||
QTest::keyClick(obj_name, Qt::Key_Enter);
|
||||
QVERIFY(service->getName() == "TestTagService");
|
||||
|
||||
tagcode->clear();
|
||||
QTest::keyClicks(tagcode, "45");
|
||||
QTest::keyClick(tagcode, Qt::Key_Enter);
|
||||
QVERIFY(service->getCode() == "45");
|
||||
|
||||
comment->clear();
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClicks(comment, "Test comment");
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClick(comment, Qt::Key_Tab);
|
||||
QTest::qWait(100);
|
||||
QVERIFY (service->getComment() == "Test comment");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2009 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: TagServiceDialogTest.h 2723 2010-03-16 17:32:18Z 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 TagServiceDialogTest_H
|
||||
#define TagServiceDialogTest_H
|
||||
|
||||
#include <QObject>
|
||||
#include "ObjectManipulator.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
|
||||
class TagServiceDialogTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
libfwbuilder::Library* findUserLibrary();
|
||||
ObjectManipulator *om;
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testDialog();
|
||||
};
|
||||
|
||||
#endif // TagServiceDialogTest_H
|
||||
@@ -0,0 +1,96 @@
|
||||
include(../../../../qmake.inc)
|
||||
include(../gui_common.inc)
|
||||
|
||||
QT += testlib network gui
|
||||
TARGET = TagServiceDialogTest
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
SOURCES += main_TagServiceDialogTest.cpp \
|
||||
TagServiceDialogTest.cpp
|
||||
|
||||
HEADERS += TagServiceDialogTest.h
|
||||
|
||||
CONFIG -= release
|
||||
CONFIG += debug
|
||||
LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS
|
||||
|
||||
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..."; \
|
||||
./${TARGET}
|
||||
run_tests.depends = build_tests
|
||||
build_tests.depends = all
|
||||
clean_tests.depends = all
|
||||
QMAKE_EXTRA_TARGETS += run_tests build_tests clean_tests
|
||||
|
||||
|
||||
contains( HAVE_ANTLR_RUNTIME, 1 ) {
|
||||
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
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: main_IPDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "TagServiceDialogTest.h"
|
||||
#include "FWWindow.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "common/commoninit.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include <QTest>
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
//std::string respath;
|
||||
//int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = NULL;
|
||||
FWBSettings *st = NULL;
|
||||
char** args;
|
||||
QApplication *app = NULL;
|
||||
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
app = new QApplication(argc, argv, 0);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
st = new FWBSettings();
|
||||
st->init();
|
||||
init(argv);
|
||||
|
||||
//respath = std::string(PREFIX) + "/share/libfwbuilder";
|
||||
//std::string full_res_path = std::string(PREFIX) + "/resources/resources.xml";
|
||||
|
||||
string full_res_path = respath + FS_SEPARATOR + "resources.xml";
|
||||
|
||||
try
|
||||
{
|
||||
new Resources(full_res_path);
|
||||
} catch (FWException &e)
|
||||
{
|
||||
cerr << "Can not read resource file from " << full_res_path << endl;
|
||||
}
|
||||
TagServiceDialogTest tst;
|
||||
QTest::qExec(&tst);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: UserServiceDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "UserServiceDialogTest.h"
|
||||
|
||||
#include "../../../../config.h"
|
||||
//#include "../../global.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qfile.h>
|
||||
#include <qtextstream.h>
|
||||
#include <QTest>
|
||||
#include <iostream>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectTreeView.h"
|
||||
#include "ObjectTreeViewItem.h"
|
||||
#include "ObjectEditor.h"
|
||||
#include "FWObjectClipboard.h"
|
||||
#include "TextEditWidget.h"
|
||||
#include "fwbuilder/Address.h"
|
||||
#include "fwbuilder/IPv4.h"
|
||||
#include "fwbuilder/IPv6.h"
|
||||
#include "FWBTree.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "UserServiceDialogTest.h"
|
||||
#include "StartTipDialog.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/Interface.h"
|
||||
#include "IPServiceDialog.h"
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/UserService.h"
|
||||
#include "UserDialog.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
void UserServiceDialogTest::initTestCase()
|
||||
{
|
||||
new FWObjectClipboard();
|
||||
mw = new FWWindow();
|
||||
mw->show();
|
||||
mw->startupLoad();
|
||||
StartTipDialog *d = mw->findChild<StartTipDialog*>();
|
||||
d->close();
|
||||
om = dynamic_cast<ObjectManipulator*>(mw->getCurrentObjectTree()->parent()->parent());
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
Library* UserServiceDialogTest::findUserLibrary()
|
||||
{
|
||||
Library *lib = NULL;
|
||||
foreach (FWObject *obj, mw->db()->getByType(Library::TYPENAME))
|
||||
{
|
||||
if (obj->getName() == "User")
|
||||
{
|
||||
lib = Library::cast(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
||||
|
||||
void UserServiceDialogTest::testDialog()
|
||||
{
|
||||
UserService *service = UserService::cast(om->createObject(FWBTree().getStandardSlotForObject(findUserLibrary(), UserService::TYPENAME), UserService::TYPENAME, "testUserService"));
|
||||
om->editObject(service);
|
||||
|
||||
UserDialog *dialog = mw->findChild<UserDialog*>("w_UserDialog");
|
||||
QLineEdit *obj_name = dialog->findChild<QLineEdit*>("obj_name");
|
||||
QLineEdit *userid = dialog->findChild<QLineEdit*>("userid");
|
||||
TextEditWidget *comment = dialog->findChild<TextEditWidget*>("comment");
|
||||
|
||||
obj_name->clear();
|
||||
QTest::keyClicks(obj_name, "TestTagService");
|
||||
QTest::keyClick(obj_name, Qt::Key_Enter);
|
||||
QVERIFY(service->getName() == "TestTagService");
|
||||
|
||||
userid->clear();
|
||||
QTest::keyClicks(userid, "45");
|
||||
QTest::keyClick(userid, Qt::Key_Enter);
|
||||
QVERIFY(service->getUserId() == "45");
|
||||
|
||||
comment->clear();
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClicks(comment, "Test comment");
|
||||
QTest::mouseClick(comment, Qt::LeftButton);
|
||||
QTest::keyClick(comment, Qt::Key_Tab);
|
||||
QTest::qWait(100);
|
||||
QVERIFY (service->getComment() == "Test comment");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2009 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: UserServiceDialogTest.h 2723 2010-03-16 17:32:18Z 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 UserServiceDialogTest_H
|
||||
#define UserServiceDialogTest_H
|
||||
|
||||
#include <QObject>
|
||||
#include "ObjectManipulator.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
|
||||
class UserServiceDialogTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
libfwbuilder::Library* findUserLibrary();
|
||||
ObjectManipulator *om;
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testDialog();
|
||||
};
|
||||
|
||||
#endif // UserServiceDialogTest_H
|
||||
@@ -0,0 +1,96 @@
|
||||
include(../../../../qmake.inc)
|
||||
include(../gui_common.inc)
|
||||
|
||||
QT += testlib network gui
|
||||
TARGET = UserServiceDialogTest
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
SOURCES += main_UserServiceDialogTest.cpp \
|
||||
UserServiceDialogTest.cpp
|
||||
|
||||
HEADERS += UserServiceDialogTest.h
|
||||
|
||||
CONFIG -= release
|
||||
CONFIG += debug
|
||||
LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS
|
||||
|
||||
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..."; \
|
||||
./${TARGET}
|
||||
run_tests.depends = build_tests
|
||||
build_tests.depends = all
|
||||
clean_tests.depends = all
|
||||
QMAKE_EXTRA_TARGETS += run_tests build_tests clean_tests
|
||||
|
||||
|
||||
contains( HAVE_ANTLR_RUNTIME, 1 ) {
|
||||
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
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id: main_IPDialogTest.cpp 2723 2010-03-16 17:32:18Z 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 "UserServiceDialogTest.h"
|
||||
#include "FWWindow.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "common/commoninit.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include <QTest>
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
//std::string respath;
|
||||
//int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = NULL;
|
||||
FWBSettings *st = NULL;
|
||||
char** args;
|
||||
QApplication *app = NULL;
|
||||
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
app = new QApplication(argc, argv, 0);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
st = new FWBSettings();
|
||||
st->init();
|
||||
init(argv);
|
||||
|
||||
//respath = std::string(PREFIX) + "/share/libfwbuilder";
|
||||
//std::string full_res_path = std::string(PREFIX) + "/resources/resources.xml";
|
||||
|
||||
string full_res_path = respath + FS_SEPARATOR + "resources.xml";
|
||||
|
||||
try
|
||||
{
|
||||
new Resources(full_res_path);
|
||||
} catch (FWException &e)
|
||||
{
|
||||
cerr << "Can not read resource file from " << full_res_path << endl;
|
||||
}
|
||||
UserServiceDialogTest tst;
|
||||
QTest::qExec(&tst);
|
||||
}
|
||||
Reference in New Issue
Block a user