diff options
author | Denis Shienkov <scapig2@yandex.ru> | 2011-10-22 21:38:23 +0400 |
---|---|---|
committer | Denis Shienkov <scapig2@yandex.ru> | 2011-10-22 21:38:23 +0400 |
commit | 74fd89965ad84590cc00c2ee812fbb6c4671de3c (patch) | |
tree | d4034bb63a17cceff3c735a8fb765a2a183f2a6b /tests | |
parent | c7fc8a378e2b239099aab675d4f0f7d922d4db01 (diff) |
Removed unnecessary files.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/guidevtest/testsdialog.cpp | 85 | ||||
-rw-r--r-- | tests/guidevtest/testsdialog.h | 47 | ||||
-rw-r--r-- | tests/guidevtest/testsdialog.ui | 44 | ||||
-rw-r--r-- | tests/guidevtest/unittestinfo.h | 19 | ||||
-rw-r--r-- | tests/guidevtest/unittestmanager.cpp | 185 | ||||
-rw-r--r-- | tests/guidevtest/unittestmanager.h | 93 |
6 files changed, 0 insertions, 473 deletions
diff --git a/tests/guidevtest/testsdialog.cpp b/tests/guidevtest/testsdialog.cpp deleted file mode 100644 index 7f7cbb62..00000000 --- a/tests/guidevtest/testsdialog.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "testsdialog.h" -#include "ui_testsdialog.h" -#include "unittestmanager.h" - - - -// TestsViewModel - -/* Public methods */ - -TestsViewModel::TestsViewModel(UnitTestManager *manager, QObject *parent) - : QAbstractListModel(parent) -{ - m_unitList = manager->units(); -} - -int TestsViewModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return m_unitList.count(); -} - -QVariant TestsViewModel::data(const QModelIndex &index, int role) const -{ - if (index.isValid() - && (index.row() < m_unitList.count())) { - UnitTestBase *item = m_unitList.at(index.row()); - if (role == Qt::DisplayRole) - return item->name(); - if (role == Qt::CheckStateRole) - return item->isEnabled() ? Qt::Checked : Qt::Unchecked; - } - return QVariant(); -} - -QVariant TestsViewModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_UNUSED(section); - Q_UNUSED(orientation); - Q_UNUSED(role); - return QVariant(); -} - -Qt::ItemFlags TestsViewModel::flags(const QModelIndex &index) const -{ - Qt::ItemFlags flag = Qt::ItemIsEnabled; - if (index.isValid()) - flag |= Qt::ItemIsUserCheckable | Qt::ItemIsSelectable; - return flag; -} - -bool TestsViewModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (index.isValid()) { - UnitTestBase *item = m_unitList.at(index.row()); - if (role == Qt::CheckStateRole) { - bool enable = value.toBool(); - if (item->isEnabled() != enable) { - item->setEnable(enable); - emit dataChanged(index, index); - return true; - } - } - } - return false; -} - - - -// TestsDialog - -/* Public methods */ - -TestsDialog::TestsDialog(UnitTestManager *manager) - : ui(new Ui::TestsDialog) -{ - ui->setupUi(this); - m_model = new TestsViewModel(manager, this); - ui->listView->setModel(m_model); -} - -TestsDialog::~TestsDialog() -{ - delete ui; -} diff --git a/tests/guidevtest/testsdialog.h b/tests/guidevtest/testsdialog.h deleted file mode 100644 index f6492d53..00000000 --- a/tests/guidevtest/testsdialog.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef TESTSDIALOG_H -#define TESTSDIALOG_H - -#include <QtGui/QDialog> -#include <QtCore/QAbstractListModel> - - - -namespace Ui { -class TestsDialog; -} - -class UnitTestManager; -class UnitTestBase; - -class TestsViewModel : public QAbstractListModel -{ - Q_OBJECT -public: - explicit TestsViewModel(UnitTestManager *manager, QObject *parent = 0); - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole); - -private: - QList<UnitTestBase *> m_unitList; -}; - - - -class TestsDialog : public QDialog -{ - Q_OBJECT -public: - explicit TestsDialog(UnitTestManager *manager); - ~TestsDialog(); - -private: - Ui::TestsDialog *ui; - TestsViewModel *m_model; -}; - -#endif // TESTSDIALOG_H diff --git a/tests/guidevtest/testsdialog.ui b/tests/guidevtest/testsdialog.ui deleted file mode 100644 index 67ab4928..00000000 --- a/tests/guidevtest/testsdialog.ui +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>TestsDialog</class> - <widget class="QDialog" name="TestsDialog"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>150</width> - <height>172</height> - </rect> - </property> - <property name="windowTitle"> - <string>Available tests</string> - </property> - <property name="modal"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QListView" name="listView"/> - </item> - <item> - <widget class="QCheckBox" name="brkBox"> - <property name="text"> - <string>Break all tests on error</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cfgButton"> - <property name="text"> - <string>Configure</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/tests/guidevtest/unittestinfo.h b/tests/guidevtest/unittestinfo.h deleted file mode 100644 index 540ec10e..00000000 --- a/tests/guidevtest/unittestinfo.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UNITTESTINFO_H -#define UNITTESTINFO_H - -#include "unittestmanager.h" - - - -class UnitTestInfo : public UnitTestBase -{ - Q_OBJECT -public: - explicit UnitTestInfo(QObject *parent = 0); - -public slots: - virtual void start(); - -}; - -#endif // UNITTESTINFO_H diff --git a/tests/guidevtest/unittestmanager.cpp b/tests/guidevtest/unittestmanager.cpp deleted file mode 100644 index d0c4cb3b..00000000 --- a/tests/guidevtest/unittestmanager.cpp +++ /dev/null @@ -1,185 +0,0 @@ -#include "unittestmanager.h" -#include "unittestinfo.h" - -#include <QtCore/QTimer> -#include <QtCore/QSettings> -#include <QtCore/QDateTime> - - - -// UnitTestBase - -/* Public methods */ - -UnitTestBase::UnitTestBase(UnitID id, QObject *parent) - : QObject(parent) - , m_id(id) -{ - m_enableParam = "%1/enable"; -} - -void UnitTestBase::setPorts(const QString &src, const QString &dst) -{ - m_srcPort = src; - m_dstPort = dst; -} - -void UnitTestBase::setEnable(bool enable) -{ - QSettings settings; - settings.setValue(m_enableParam.arg(m_id), enable); -} - -bool UnitTestBase::isEnabled() const -{ - QSettings settings; - return settings.value(m_enableParam.arg(m_id)).toBool(); -} - -int UnitTestBase::id() const -{ - return m_id; -} - -QString UnitTestBase::name() const -{ - return m_name; -} - -QString UnitTestBase::description() const -{ - return m_description; -} - - - -// UnitTestFactory - -/* Public methods */ - -UnitTestBase *UnitTestFactory::create(UnitTestBase::UnitID id) -{ - switch (id) { - case UnitTestBase::InfoUnitId: - return new UnitTestInfo(); - default:; - } - - return 0; -} - - - -// UnitTestManager - -/* Public methods */ - -UnitTestManager::UnitTestManager(QObject *parent) - : QObject(parent) - , m_count(0) - , m_it(0) -{ - // Create all units. - m_unitList.append(UnitTestFactory::create(UnitTestBase::InfoUnitId)); - //.. - //... - - foreach (UnitTestBase *unit, m_unitList) - connect(unit, SIGNAL(finished()), this, SLOT(procStep())); - - m_count = m_unitList.count(); - - connect(this, SIGNAL(started()), this, SLOT(procLogStart())); - connect(this, SIGNAL(finished()), this, SLOT(procLogFinish())); -} - -void UnitTestManager::setPorts(const QString &src, const QString &dst) -{ - m_srcPort = src; - m_dstPort = dst; -} - -QList<UnitTestBase *> UnitTestManager::units() const -{ - return m_unitList; -} - -void UnitTestManager::setLogFileName(const QString &name) -{ - QSettings settings; - settings.setValue(UnitTestManager::m_logFileParam, name); -} - -bool UnitTestManager::openLog() -{ - QSettings settings; - QString name(settings.value(UnitTestManager::m_logFileParam).toString()); - m_log.setFileName(name); - return (m_log.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)); -} - -bool UnitTestManager::writeToLog(const QString &content) -{ - return (m_log.write(content.toLocal8Bit()) > 0); -} - -void UnitTestManager::closeLog() -{ - m_log.close(); -} - -QString UnitTestManager::timestamp() -{ - return QDateTime::currentDateTime().toString(); -} - -/* Public slots */ - -void UnitTestManager::start() -{ - emit started(); - m_it = 0; - procStep(); -} - -void UnitTestManager::stop() -{ -} - -/* Private slots */ - -void UnitTestManager::procStep() -{ - if (m_it == m_count) { - emit finished(); - return; - } - - UnitTestBase *unit = m_unitList.at(m_it++); - if (unit->isEnabled()) { - unit->setPorts(m_srcPort, m_dstPort); - QTimer::singleShot(1000, unit, SLOT(start())); - } - else - procStep(); -} - -void UnitTestManager::procLogStart() -{ - bool ret = UnitTestManager::openLog(); - QString startHeader(tr("=== T E S T S S T A R T E D ===\n\n\n")); - ret = UnitTestManager::writeToLog(startHeader); - UnitTestManager::closeLog(); -} - -void UnitTestManager::procLogFinish() -{ - bool ret = UnitTestManager::openLog(); - QString stopHeader(tr("\n\n\n=== T E S T S S T O P P E D ===\n\n\n")); - ret = UnitTestManager::writeToLog(stopHeader); - UnitTestManager::closeLog(); -} - -// -const QString UnitTestManager::m_logFileParam = "UnitTestManager/logFile"; -QFile UnitTestManager::m_log; diff --git a/tests/guidevtest/unittestmanager.h b/tests/guidevtest/unittestmanager.h deleted file mode 100644 index 3bacdd61..00000000 --- a/tests/guidevtest/unittestmanager.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef UNITTESTMANAGER_H -#define UNITTESTMANAGER_H - -#include <QtCore/QObject> -#include <QtCore/QFile> - - - -class UnitTestBase : public QObject -{ - Q_OBJECT -signals: - void finished(); - void error(); - -public: - enum UnitID { - InfoUnitId, - - }; - - explicit UnitTestBase(UnitID id, QObject *parent = 0); - void setPorts(const QString &src, const QString &dst); - void setEnable(bool enable); - bool isEnabled() const; - - int id() const; - QString name() const; - QString description() const; - -public slots: - virtual void start() = 0; - -protected: - int m_id; - QString m_name; - QString m_description; - QString m_enableParam; - -private: - QString m_srcPort; - QString m_dstPort; -}; - - - -class UnitTestFactory -{ -public: - static UnitTestBase *create(UnitTestBase::UnitID id); -}; - - - -class UnitTestManager : public QObject -{ - Q_OBJECT -signals: - void started(); - void finished(); - -public: - explicit UnitTestManager(QObject *parent = 0); - void setPorts(const QString &src, const QString &dst); - QList<UnitTestBase *> units() const; - - static void setLogFileName(const QString &name); - static bool openLog(); - static bool writeToLog(const QString &content); - static void closeLog(); - static QString timestamp(); - -public slots: - void start(); - void stop(); - -private slots: - void procStep(); - void procLogStart(); - void procLogFinish(); - -private: - int m_count; - int m_it; - QString m_srcPort; - QString m_dstPort; - QList<UnitTestBase *> m_unitList; - - static const QString m_logFileParam; - static QFile m_log; -}; - -#endif // UNITTESTMANAGER_H |