aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qtlicensetool/tst_qtlicensetool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtlicensetool/tst_qtlicensetool.cpp')
-rw-r--r--tests/auto/qtlicensetool/tst_qtlicensetool.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qtlicensetool/tst_qtlicensetool.cpp b/tests/auto/qtlicensetool/tst_qtlicensetool.cpp
new file mode 100644
index 0000000..d3e90af
--- /dev/null
+++ b/tests/auto/qtlicensetool/tst_qtlicensetool.cpp
@@ -0,0 +1,36 @@
+/* Copyright (C) 2022 The Qt Company Ltd.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only WITH Qt-GPL-exception-1.0
+*/
+
+#include <catch_amalgamated.hpp>
+
+#include "commonsetup.h"
+
+#include "qtlicensetool.h"
+#include "licdsetup.h"
+#include "licenseservice.h"
+
+using namespace QLicenseService;
+
+TEST_CASE("Version query", "[qtlicensetool]")
+{
+ LicenseService service(0, DAEMON_SETTINGS_FILE_DEFAULT);
+ LicdSetup setup(e_set_type_licensetool, LicdSetup::getQtAppDataLocation() + USER_SETTINGS_FILE);
+
+ int result = setup.initSettings();
+ if (result == e_file_not_present) {
+ // initSettings() creates the file if it does not exist, just call it again to reinit
+ result = setup.initSettings();
+ }
+
+ // 1. Verify settings initialization for license tool
+ REQUIRE(result == e_settings_ok);
+ // 2. Verify starting of license "service" succeeds
+ REQUIRE((service.start() && service.waitForStarted()));
+ // 3. Verify send version command & reply status ok
+ REQUIRE(askStatus(DAEMON_VERSION_CMD, &setup) == 0);
+ // 4. Verify stop service
+ REQUIRE((service.cancel() && service.waitForFinished()));
+ REQUIRE(service.status() == LicenseService::Status::Canceled);
+}