diff --git a/tests/src/QZXingTests/DecodeValidator.cpp b/tests/src/QZXingTests/DecodeValidator.cpp new file mode 100644 index 0000000..f1402f3 --- /dev/null +++ b/tests/src/QZXingTests/DecodeValidator.cpp @@ -0,0 +1,21 @@ +#include "DecodeValidator.h" + +DecodeValidator::DecodeValidator() : decoder() +{ +} + +std::shared_ptr DecodeValidator::testDecodeWithExpectedOutput(QZXing::DecoderFormat enabledDecoder, const QImage &imageToDecode, const QString &expectedOutput) +{ + std::shared_ptr stats_ = std::make_shared(); + + decoder.setDecoder(enabledDecoder); + + QString result = decoder.decodeImage(imageToDecode, 999, 999, true); + + stats_->setElaspedTime(decoder.getProcessTimeOfLastDecoding()); + stats_->setOperationSuccess(result != ""); + stats_->setResultMatch(result == expectedOutput); + + return stats_; +} + diff --git a/tests/src/QZXingTests/DecodeValidator.h b/tests/src/QZXingTests/DecodeValidator.h new file mode 100644 index 0000000..e0d87ed --- /dev/null +++ b/tests/src/QZXingTests/DecodeValidator.h @@ -0,0 +1,21 @@ +#ifndef DECODEVALIDATOR_H +#define DECODEVALIDATOR_H + +#include "ValidationStats.h" +#include +#include + +class DecodeValidator +{ +private: + QZXing decoder; + +public: + DecodeValidator(); + + std::shared_ptr testDecodeWithExpectedOutput(QZXing::DecoderFormat enabledDecoder, + const QImage &imageToDecode, + const QString &expectedOutput); +}; + +#endif // DECODEVALIDATOR_H diff --git a/tests/src/QZXingTests/QZXingTests.pro b/tests/src/QZXingTests/QZXingTests.pro new file mode 100644 index 0000000..06ed942 --- /dev/null +++ b/tests/src/QZXingTests/QZXingTests.pro @@ -0,0 +1,22 @@ +QT += core +QT -= gui + +CONFIG += gnu++11 + +TARGET = QZXingTests +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +SOURCES += main.cpp \ + DecodeValidator.cpp \ + ValidationStats.cpp + +HEADERS += \ + DecodeValidator.h \ + ValidationStats.h + + + +include(../../../src/QZXing.pri) diff --git a/tests/src/QZXingTests/ValidationStats.cpp b/tests/src/QZXingTests/ValidationStats.cpp new file mode 100644 index 0000000..36fd92a --- /dev/null +++ b/tests/src/QZXingTests/ValidationStats.cpp @@ -0,0 +1,47 @@ +#include "ValidationStats.h" + +bool ValidationStats::getOperationSuccess() const +{ + return operationSuccess; +} + +void ValidationStats::setOperationSuccess(bool value) +{ + operationSuccess = value; +} + +bool ValidationStats::getResultMatch() const +{ + return resultMatch; +} + +void ValidationStats::setResultMatch(bool value) +{ + resultMatch = value; +} + +QString ValidationStats::getErrorMessage() const +{ + return errorMessage; +} + +void ValidationStats::setErrorMessage(const QString &value) +{ + errorMessage = value; +} + +int64_t ValidationStats::getElaspedTime() const +{ + return elaspedTime; +} + +void ValidationStats::setElaspedTime(const int64_t &value) +{ + elaspedTime = value; +} + +ValidationStats::ValidationStats() +{ + +} + diff --git a/tests/src/QZXingTests/ValidationStats.h b/tests/src/QZXingTests/ValidationStats.h new file mode 100644 index 0000000..0223893 --- /dev/null +++ b/tests/src/QZXingTests/ValidationStats.h @@ -0,0 +1,28 @@ +#ifndef VALIDATIONSTATS_H +#define VALIDATIONSTATS_H + +#include +#include + +class ValidationStats +{ +private: + bool operationSuccess; + bool resultMatch; + QString errorMessage; + int64_t elaspedTime; + +public: + ValidationStats(); + bool getOperationSuccess() const; + bool getResultMatch() const; + QString getErrorMessage() const; + int64_t getElaspedTime() const; + + void setOperationSuccess(bool value); + void setResultMatch(bool value); + void setErrorMessage(const QString &value); + void setElaspedTime(const int64_t &value); +}; + +#endif // VALIDATIONSTATS_H diff --git a/tests/src/QZXingTests/main.cpp b/tests/src/QZXingTests/main.cpp new file mode 100644 index 0000000..d93611d --- /dev/null +++ b/tests/src/QZXingTests/main.cpp @@ -0,0 +1,9 @@ +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + return a.exec(); +} +