You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
3 years ago
|
|
||
|
#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;
|
||
|
}
|
||
|
|