Made tests for features of 462bd42
This commit is contained in:
parent
462bd42521
commit
91a5de78e9
3 changed files with 157 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.13.3, 2021-01-03T22:07:43. -->
|
<!-- Written by QtCreator 4.13.3, 2021-01-04T18:26:48. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|
@ -64,7 +64,13 @@
|
||||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
<valuemap type="QVariantMap" key="AutoTest.CheckStates">
|
||||||
|
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/tst_ifacilitytest.cpp:iFacilityTest">Checked</value>
|
||||||
|
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/tst_ifacilitytest.cpp:test_user_add_profession">Checked</value>
|
||||||
|
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/tst_ifacilitytest.cpp:test_user_current_profession">Checked</value>
|
||||||
|
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/tst_ifacilitytest.cpp:test_user_remove_profession">Checked</value>
|
||||||
|
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/tst_ifacilitytest.cpp:test_user_serialization">Checked</value>
|
||||||
|
</valuemap>
|
||||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
|
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
|
||||||
|
|
@ -155,7 +161,7 @@
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">true</value>
|
||||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
|
@ -207,7 +213,7 @@
|
||||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">true</value>
|
||||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
|
@ -339,7 +345,82 @@
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Admin/Documents/repos/build-iFacilityProject-Desktop_Qt_5_15_0_MinGW_64_bit-Debug/iFacility</value>
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Admin/Documents/repos/build-iFacilityProject-Desktop_Qt_5_15_0_MinGW_64_bit-Debug/iFacility</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||||
|
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||||
|
<value type="QString">cpu-cycles</value>
|
||||||
|
</valuelist>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||||
|
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||||
|
<value type="QString">-e</value>
|
||||||
|
<value type="QString">cpu-cycles</value>
|
||||||
|
<value type="QString">--call-graph</value>
|
||||||
|
<value type="QString">dwarf,4096</value>
|
||||||
|
<value type="QString">-F</value>
|
||||||
|
<value type="QString">250</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||||
|
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||||
|
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||||
|
<value type="int">0</value>
|
||||||
|
<value type="int">1</value>
|
||||||
|
<value type="int">2</value>
|
||||||
|
<value type="int">3</value>
|
||||||
|
<value type="int">4</value>
|
||||||
|
<value type="int">5</value>
|
||||||
|
<value type="int">6</value>
|
||||||
|
<value type="int">7</value>
|
||||||
|
<value type="int">8</value>
|
||||||
|
<value type="int">9</value>
|
||||||
|
<value type="int">10</value>
|
||||||
|
<value type="int">11</value>
|
||||||
|
<value type="int">12</value>
|
||||||
|
<value type="int">13</value>
|
||||||
|
<value type="int">14</value>
|
||||||
|
</valuelist>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/iFacilityTests.pro</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/Admin/Documents/repos/iFacilityProject/iFacilityTests/iFacilityTests.pro</value>
|
||||||
|
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||||
|
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Admin/Documents/repos/build-iFacilityProject-Desktop_Qt_5_15_0_MinGW_64_bit-Debug/iFacilityTests</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,10 @@ TEMPLATE = app
|
||||||
SOURCES += tst_ifacilitytest.cpp \
|
SOURCES += tst_ifacilitytest.cpp \
|
||||||
..\iFacility\objects\userprofession.cpp \
|
..\iFacility\objects\userprofession.cpp \
|
||||||
..\iFacility\objects\profession.cpp \
|
..\iFacility\objects\profession.cpp \
|
||||||
..\iFacility\objects\user.cpp
|
..\iFacility\objects\user.cpp \
|
||||||
|
..\iFacility\db\database.cpp
|
||||||
|
|
||||||
HEADERS += ..\iFacility\objects\userprofession.h \
|
HEADERS += ..\iFacility\objects\userprofession.h \
|
||||||
..\iFacility\objects\profession.h \
|
..\iFacility\objects\profession.h \
|
||||||
..\iFacility\objects\user.h
|
..\iFacility\objects\user.h \
|
||||||
|
..\iFacility\db\database.h
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,14 @@
|
||||||
#include "../iFacility/objects/userprofession.h"
|
#include "../iFacility/objects/userprofession.h"
|
||||||
#include "../iFacility/objects/profession.h"
|
#include "../iFacility/objects/profession.h"
|
||||||
#include "../iFacility/objects/user.h"
|
#include "../iFacility/objects/user.h"
|
||||||
|
#include "../iFacility/db/database.h"
|
||||||
|
|
||||||
class iFacilityTest : public QObject {
|
class iFacilityTest : public QObject {
|
||||||
private:
|
private:
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
User sampleUser;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iFacilityTest() = default;
|
iFacilityTest() = default;
|
||||||
~iFacilityTest() = default;
|
~iFacilityTest() = default;
|
||||||
|
|
@ -21,6 +24,11 @@ private slots:
|
||||||
void test_user_current_profession();
|
void test_user_current_profession();
|
||||||
void test_user_serialization();
|
void test_user_serialization();
|
||||||
|
|
||||||
|
void test_db_add_user();
|
||||||
|
void test_db_get_user_by_uid();
|
||||||
|
void test_db_get_user_by_login();
|
||||||
|
void test_db_get_users_by_type();
|
||||||
|
void test_db_get_users_gy_profession();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -97,6 +105,65 @@ void iFacilityTest::test_user_serialization() {
|
||||||
QVERIFY(u1.getCurrentProfession() == u2.getCurrentProfession());
|
QVERIFY(u1.getCurrentProfession() == u2.getCurrentProfession());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_add_user() {
|
||||||
|
// 3 administrators (except u7), 1 dispatcher and 2 workers (for later)
|
||||||
|
auto u1 = User::createUser("adm1", "test", UserType::ADMINISTRATOR, "f", "s", "t");
|
||||||
|
auto u2 = User::createUser("adm2", "test", UserType::ADMINISTRATOR, "f", "s", "t");
|
||||||
|
auto u3 = User::createUser("disp1", "test", UserType::DISPATCHER, "f", "s", "t");
|
||||||
|
auto u4 = User::createUser("worker1", "test", UserType::WORKER, "f", "s", "t");
|
||||||
|
auto u5 = User::createUser("worker2", "test", UserType::WORKER, "f", "s", "t");
|
||||||
|
auto u6 = User::createUser("adm3", "test", UserType::ADMINISTRATOR, "f", "s", "t");
|
||||||
|
auto u7 = User::createUser("adm1", "test", UserType::ADMINISTRATOR, "f", "s", "t");
|
||||||
|
|
||||||
|
QVERIFY(Database::instance()->addUser(u1)); // ok
|
||||||
|
QVERIFY(Database::instance()->addUser(u2)); // ok
|
||||||
|
QVERIFY(Database::instance()->addUser(u3)); // ok
|
||||||
|
QVERIFY(Database::instance()->addUser(u4)); // ok
|
||||||
|
QVERIFY(Database::instance()->addUser(u5)); // ok
|
||||||
|
QVERIFY(Database::instance()->addUser(u6)); // ok
|
||||||
|
QVERIFY(!Database::instance()->addUser(u7)); // u7 and u1 has same login
|
||||||
|
|
||||||
|
sampleUser = u1; // saved for later
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_get_user_by_uid() {
|
||||||
|
auto usr1 = Database::instance()->getUser(sampleUser.uID());
|
||||||
|
UID nonExistentUuid = 0;
|
||||||
|
auto usr2 = Database::instance()->getUser(nonExistentUuid);
|
||||||
|
|
||||||
|
QVERIFY(usr1 != nullptr);
|
||||||
|
QVERIFY(usr2 == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_get_user_by_login() {
|
||||||
|
auto usr1 = Database::instance()->getUser(sampleUser.getLogin());
|
||||||
|
QString nonExistentLogin = "not_really_exists";
|
||||||
|
auto usr2 = Database::instance()->getUser(nonExistentLogin);
|
||||||
|
|
||||||
|
QVERIFY(usr1 != nullptr);
|
||||||
|
QVERIFY(usr2 == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_get_users_by_type() {
|
||||||
|
auto admins = Database::instance()->getUsersByType(UserType::ADMINISTRATOR);
|
||||||
|
auto dispatchers = Database::instance()->getUsersByType(UserType::DISPATCHER);
|
||||||
|
auto workers = Database::instance()->getUsersByType(UserType::WORKER);
|
||||||
|
|
||||||
|
QVERIFY(admins.size() == 3);
|
||||||
|
QVERIFY(dispatchers.size() == 1);
|
||||||
|
QVERIFY(workers.size() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_get_users_gy_profession() {
|
||||||
|
auto usr1 = Database::instance()->getUser(sampleUser.getLogin());
|
||||||
|
Profession p = Profession::createProfession("test_prof");
|
||||||
|
usr1->addProfession(p, 3);
|
||||||
|
auto usrs = Database::instance()->getUsersByProfession(p);
|
||||||
|
|
||||||
|
QVERIFY(usrs.size() == 1);
|
||||||
|
QVERIFY(usr1 == usrs[0]);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(iFacilityTest)
|
QTEST_APPLESS_MAIN(iFacilityTest)
|
||||||
|
|
||||||
#include "tst_ifacilitytest.moc"
|
#include "tst_ifacilitytest.moc"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue