refactor: extract signal spying to a top-level autotest utility.
parent
fa4f6f651e
commit
e782840847
|
@ -5,6 +5,7 @@
|
|||
#
|
||||
include_directories(BEFORE ../src)
|
||||
|
||||
add_subdirectory(test-utils)
|
||||
add_subdirectory(base32)
|
||||
add_subdirectory(hmac)
|
||||
add_subdirectory(oath)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
#
|
||||
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib)
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib test_lib)
|
||||
|
||||
set(compute_jobs_test_SRCS
|
||||
compute-hotp.cpp
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "account/actions_p.h"
|
||||
|
||||
#include "../test-utils/secret.h"
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "account/actions_p.h"
|
||||
|
||||
#include "../test-utils/secret.h"
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
#
|
||||
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib)
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib test_lib)
|
||||
|
||||
set(dispatcher_test_SRCS
|
||||
dispatcher-dispatch.cpp
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
#
|
||||
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib secrets_test_lib)
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib secrets_test_lib test_lib)
|
||||
qt5_add_resources(RCC_SOURCES resources/resources.qrc)
|
||||
|
||||
ecm_add_test(load-accounts.cpp ${RCC_SOURCES} LINK_LIBRARIES ${Test_DEP_LIBS} TEST_NAME load-accounts NAME_PREFIX account-jobs-)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "account/actions_p.h"
|
||||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QSet>
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/secret.h"
|
||||
#include "../test-utils/spy.h"
|
||||
|
||||
#include "../../test-utils/spy.h"
|
||||
#include "../../secrets/test-utils/random.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "account/actions_p.h"
|
||||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
#include <QString>
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/secret.h"
|
||||
#include "../test-utils/spy.h"
|
||||
|
||||
#include "../../test-utils/spy.h"
|
||||
#include "../../secrets/test-utils/random.h"
|
||||
|
||||
#include <QFile>
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/secret.h"
|
||||
#include "../test-utils/spy.h"
|
||||
|
||||
#include "../../test-utils/spy.h"
|
||||
#include "../../secrets/test-utils/random.h"
|
||||
|
||||
#include <QFile>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
#
|
||||
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib)
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib test_lib)
|
||||
|
||||
set(account_secret_test_SRCS
|
||||
account-secret-password-flow.cpp
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
#include "account/keys.h"
|
||||
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
#
|
||||
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib secrets_test_lib)
|
||||
set(Test_DEP_LIBS Qt5::Core Qt5::Test account_lib account_test_lib secrets_test_lib test_lib)
|
||||
qt5_add_resources(RCC_SOURCES resources/resources.qrc)
|
||||
|
||||
ecm_add_test(storage-object-lifecycles.cpp ${RCC_SOURCES} LINK_LIBRARIES ${Test_DEP_LIBS} TEST_NAME storage-object-lifecycles NAME_PREFIX account-)
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
#include "account/account.h"
|
||||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/spy.h"
|
||||
|
||||
#include "../../test-utils/spy.h"
|
||||
#include "../../secrets/test-utils/random.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "account/account.h"
|
||||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
#include <QString>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "account/account.h"
|
||||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/spy.h"
|
||||
#include "../../test-utils/spy.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
#include "account/account.h"
|
||||
|
||||
#include "../test-utils/output.h"
|
||||
#include "../test-utils/spy.h"
|
||||
|
||||
#include "../../test-utils/spy.h"
|
||||
#include "../../secrets/test-utils/random.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
|
|
@ -7,7 +7,6 @@ set(account_test_lib_SRCS
|
|||
job.cpp
|
||||
output.cpp
|
||||
secret.cpp
|
||||
spy.cpp
|
||||
)
|
||||
|
||||
add_library(account_test_lib STATIC ${account_test_lib_SRCS})
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
# SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
#
|
||||
|
||||
set(test_lib_SRCS
|
||||
spy.cpp
|
||||
)
|
||||
|
||||
add_library(test_lib STATIC ${test_lib_SRCS})
|
||||
target_link_libraries(test_lib Qt5::Core Qt5::Test)
|
||||
|
|
@ -9,7 +9,7 @@ namespace test
|
|||
|
||||
bool signal_eventually_emitted_exactly(QSignalSpy &spy, int times, int timeout)
|
||||
{
|
||||
return (spy.count() > (times - 1) || spy.wait(timeout)) && spy.count() == times;
|
||||
return (spy.count() >= times || spy.wait(timeout)) && spy.count() == times;
|
||||
}
|
||||
|
||||
bool signal_eventually_emitted_once(QSignalSpy &spy, int timeout)
|
|
@ -2,8 +2,8 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
*/
|
||||
#ifndef ACCOUNTS_TEST_UTIL_SPY_H
|
||||
#define ACCOUNTS_TEST_UTIL_SPY_H
|
||||
#ifndef TEST_UTIL_SPY_H
|
||||
#define TEST_UTIL_SPY_H
|
||||
|
||||
#include <QSignalSpy>
|
||||
|
Loading…
Reference in New Issue