mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
Some test improvements
This commit is contained in:
parent
620c4bd1e3
commit
ab01c9fa08
@ -178,7 +178,8 @@ void AbstractExtItem::setName(const QString _name)
|
||||
void AbstractExtItem::setNumber(int _number)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Number" << _number;
|
||||
if (_number == -1) {
|
||||
bool generateNumber = (_number == -1);
|
||||
if (generateNumber) {
|
||||
_number = []() {
|
||||
qCWarning(LOG_LIB) << "Number is empty, generate new one";
|
||||
qsrand(QTime::currentTime().msec());
|
||||
@ -186,10 +187,11 @@ void AbstractExtItem::setNumber(int _number)
|
||||
qCInfo(LOG_LIB) << "Generated number is" << n;
|
||||
return n;
|
||||
}();
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
m_number = _number;
|
||||
if (generateNumber)
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,11 +5,11 @@ find_package(Gettext REQUIRED)
|
||||
find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core DBus Network Qml Test Widgets)
|
||||
add_definitions(
|
||||
${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Network_DEFINITIONS}
|
||||
${Qt5Qml_DEFINITIONS} ${Qt5Test_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}
|
||||
${Qt5Qml_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}
|
||||
)
|
||||
set(Qt_INCLUDE
|
||||
${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}
|
||||
${Qt5Qml_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5Qml_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}
|
||||
)
|
||||
set(Qt_LIBRARIES
|
||||
${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES}
|
||||
|
@ -2,12 +2,14 @@ set(SUBPROJECT awesomewidgets-test)
|
||||
message(STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find qt test package
|
||||
add_definitions(${Qt5Test_DEFINITIONS})
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
${Qt_INCLUDE}
|
||||
${Qt5Test_INCLUDE_DIRS}
|
||||
${Kf5_INCLUDE}
|
||||
)
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "awtestlibrary.h"
|
||||
|
||||
#include <QSet>
|
||||
#include <QStandardPaths>
|
||||
|
||||
|
||||
char AWTestLibrary::randomChar()
|
||||
@ -33,6 +34,22 @@ double AWTestLibrary::randomDouble()
|
||||
}
|
||||
|
||||
|
||||
QPair<QString, QString> AWTestLibrary::randomFilenames()
|
||||
{
|
||||
QString fileName = QString("%1/").arg(
|
||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation));
|
||||
QString writeFileName = QString("%1/awesomewidgets/tmp/")
|
||||
.arg(QStandardPaths::writableLocation(
|
||||
QStandardPaths::GenericDataLocation));
|
||||
|
||||
QString name = randomString(20);
|
||||
fileName += name;
|
||||
writeFileName += name;
|
||||
|
||||
return QPair<QString, QString>(fileName, writeFileName);
|
||||
}
|
||||
|
||||
|
||||
int AWTestLibrary::randomInt(const int max)
|
||||
{
|
||||
return rand() % max;
|
||||
|
@ -26,6 +26,7 @@ namespace AWTestLibrary
|
||||
{
|
||||
char randomChar();
|
||||
double randomDouble();
|
||||
QPair<QString, QString> randomFilenames();
|
||||
int randomInt(const int max = 100);
|
||||
QString randomString(const int max = 100);
|
||||
QStringList randomStringList(const int max = 100);
|
||||
|
@ -26,7 +26,9 @@
|
||||
|
||||
void TestAbstractExtItem::initTestCase()
|
||||
{
|
||||
generateFilename();
|
||||
auto names = AWTestLibrary::randomFilenames();
|
||||
fileName = names.first;
|
||||
writeFileName = names.second;
|
||||
|
||||
extItem = new ExtUpgrade(nullptr, fileName);
|
||||
extItem->setActive(false);
|
||||
@ -108,18 +110,4 @@ void TestAbstractExtItem::test_copy()
|
||||
}
|
||||
|
||||
|
||||
void TestAbstractExtItem::generateFilename()
|
||||
{
|
||||
fileName = QString("%1/").arg(
|
||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation));
|
||||
writeFileName = QString("%1/awesomewidgets/tmp/")
|
||||
.arg(QStandardPaths::writableLocation(
|
||||
QStandardPaths::GenericDataLocation));
|
||||
|
||||
QString name = AWTestLibrary::randomString(20);
|
||||
fileName += name;
|
||||
writeFileName += name;
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestAbstractExtItem);
|
||||
|
@ -41,7 +41,6 @@ private slots:
|
||||
void test_copy();
|
||||
|
||||
private:
|
||||
void generateFilename();
|
||||
ExtUpgrade *extItem = nullptr;
|
||||
QString comment = QString("A comment");
|
||||
QString name = QString("A name");
|
||||
|
Loading…
Reference in New Issue
Block a user