summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-11-23 00:11:22 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-11-23 00:11:22 +0900
commit26fc60d30352bb3bbf00f8a392bbc695ff8cf29f (patch)
treeebfaffc782da646c5ca5a5547121aeb05b68cdac /tests
parent652c2aea23bd9dea082f5de2c0babe1728ac608f (diff)
downloadpolkit-tqt-26fc60d30352bb3bbf00f8a392bbc695ff8cf29f.tar.gz
polkit-tqt-26fc60d30352bb3bbf00f8a392bbc695ff8cf29f.zip
Removed original test folder and add more manual tests.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/test_auth_enum_actions.cpp56
-rw-r--r--tests/test_check_authorization.cpp1
3 files changed, 57 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index cc2083861..92a8543d0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -50,6 +50,7 @@ set( _test_auto_executables
# ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh <path/to/test_executable_file>
set( _test_manual_executables
test_check_authorization
+ test_auth_enum_actions
)
foreach( _test_name ${_test_auto_executables} )
diff --git a/tests/test_auth_enum_actions.cpp b/tests/test_auth_enum_actions.cpp
new file mode 100644
index 000000000..d7c992a97
--- /dev/null
+++ b/tests/test_auth_enum_actions.cpp
@@ -0,0 +1,56 @@
+
+#include <tqstring.h>
+
+#include "core/polkit-tqt-authority.h"
+#include "core/polkit-tqt-details.h"
+
+#define TEST_PASSED 0
+#define TEST_FAILED 1
+
+using namespace PolkitTQt;
+
+void wait()
+{
+ for (int i = 0; i < 100; i++)
+ {
+ usleep(100);
+ }
+}
+
+int main(void)
+{
+ // This needs the file org.tqt.policykit.examples.policy from examples to be installed
+ ActionDescription::List list = Authority::instance()->enumerateActionsSync();
+ if (Authority::instance()->hasError())
+ {
+ return TEST_FAILED;
+ }
+ // Check whether enumerateAction returns at least example actions
+ int count = 0;
+ ActionDescription::List::const_iterator adIt;
+ for (adIt = list.begin(); adIt != list.end(); ++adIt)
+ {
+ if (((*adIt).actionId() == "org.tqt.policykit.examples.kick") ||
+ ((*adIt).actionId() == "org.tqt.policykit.examples.cry") ||
+ ((*adIt).actionId() == "org.tqt.policykit.examples.bleed"))
+ {
+ count++;
+ }
+ }
+ if (count != 3)
+ {
+ return TEST_FAILED;
+ }
+
+ // Test cancelling the enumeration
+ Authority::instance()->enumerateActions();
+ Authority::instance()->enumerateActionsCancel();
+ wait();
+ if (Authority::instance()->hasError())
+ {
+ return TEST_FAILED;
+ }
+
+ return TEST_PASSED;
+}
+
diff --git a/tests/test_check_authorization.cpp b/tests/test_check_authorization.cpp
index 4fb6674c1..61b836920 100644
--- a/tests/test_check_authorization.cpp
+++ b/tests/test_check_authorization.cpp
@@ -1,5 +1,4 @@
-#include <unistd.h>
#include <tqstring.h>
#include "core/polkit-tqt-authority.h"