From 26fc60d30352bb3bbf00f8a392bbc695ff8cf29f Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 23 Nov 2021 00:11:22 +0900 Subject: Removed original test folder and add more manual tests. Signed-off-by: Michele Calgaro --- tests/test_auth_enum_actions.cpp | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/test_auth_enum_actions.cpp (limited to 'tests/test_auth_enum_actions.cpp') 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 + +#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; +} + -- cgit v1.2.3