2022-07-04 21:14:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
#include <Wallet/WalletApi.h>
|
|
|
|
|
2022-07-15 07:30:16 +00:00
|
|
|
#include <StatusGo/Utils.h>
|
|
|
|
|
2022-07-04 21:14:13 +00:00
|
|
|
#include <string>
|
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class QCoreApplication;
|
|
|
|
|
|
|
|
namespace Status::Onboarding {
|
|
|
|
class OnboardingController;
|
2022-07-15 07:30:16 +00:00
|
|
|
class MultiAccount;
|
2022-07-04 21:14:13 +00:00
|
|
|
}
|
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
namespace Wallet = Status::StatusGo::Wallet;
|
|
|
|
namespace Accounts = Status::StatusGo::Accounts;
|
2022-07-15 07:30:16 +00:00
|
|
|
namespace GoUtils = Status::StatusGo::Utils;
|
2022-07-07 18:16:59 +00:00
|
|
|
|
2022-07-04 21:14:13 +00:00
|
|
|
namespace Status::Testing {
|
|
|
|
|
|
|
|
class AutoCleanTempTestDir;
|
|
|
|
|
|
|
|
class ScopedTestAccount final {
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
* \brief Create and logs in a new test account
|
|
|
|
* \param tempTestSubfolderName subfolder name of the temporary test folder where to initalize user data \see AutoCleanTempTestDir
|
|
|
|
* \todo make it more flexible by splitting into create account, login and wait for events
|
|
|
|
*/
|
|
|
|
explicit ScopedTestAccount(const std::string &tempTestSubfolderName,
|
|
|
|
const QString &accountName = defaultAccountName,
|
2022-07-15 07:30:16 +00:00
|
|
|
const QString &accountPassword = defaultAccountPassword);
|
2022-07-04 21:14:13 +00:00
|
|
|
~ScopedTestAccount();
|
|
|
|
|
|
|
|
void processMessages(size_t millis, std::function<bool()> shouldWaitUntilTimeout);
|
|
|
|
void logOut();
|
|
|
|
|
2022-07-13 16:45:18 +00:00
|
|
|
static Accounts::ChatOrWalletAccount firstChatAccount();
|
|
|
|
static Accounts::ChatOrWalletAccount firstWalletAccount();
|
2022-07-15 07:30:16 +00:00
|
|
|
/// Root account
|
|
|
|
const Status::Onboarding::MultiAccount &loggedInAccount() const;
|
2022-07-07 18:16:59 +00:00
|
|
|
|
|
|
|
QString password() const { return m_accountPassword; };
|
2022-07-15 07:30:16 +00:00
|
|
|
StatusGo::HashedPassword hashedPassword() const { return GoUtils::hashPassword(m_accountPassword); };
|
2022-07-07 18:16:59 +00:00
|
|
|
|
2022-07-04 21:14:13 +00:00
|
|
|
Status::Onboarding::OnboardingController* onboardingController() const;
|
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
const std::filesystem::path& fusedTestFolder() const;
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<AutoCleanTempTestDir> m_fusedTestFolder;
|
|
|
|
std::unique_ptr<QCoreApplication> m_app;
|
|
|
|
std::filesystem::path m_testFolderPath;
|
|
|
|
std::shared_ptr<Status::Onboarding::OnboardingController> m_onboarding;
|
|
|
|
std::function<bool()> m_checkIfShouldContinue;
|
|
|
|
|
|
|
|
QString m_accountName;
|
|
|
|
QString m_accountPassword;
|
|
|
|
|
|
|
|
static constexpr auto defaultAccountName = "test_name";
|
|
|
|
static constexpr auto defaultAccountPassword = "test_pwd*";
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|