mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-10 04:15:51 +00:00
Some test improvements
This commit is contained in:
@ -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");
|
||||
|
Reference in New Issue
Block a user