summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test.cpp142
-rw-r--r--test/test.h6
2 files changed, 74 insertions, 74 deletions
diff --git a/test/test.cpp b/test/test.cpp
index afb7f6433..6112dc4f5 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -7,48 +7,48 @@
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusConnection>
-using namespace PolkitQt1;
-using namespace PolkitQt1::Agent;
+#include <TQtDBus/TQDBusMessage>
+#include <TQtDBus/TQDBusConnection>
+using namespace PolkitTQt1;
+using namespace PolkitTQt1::Agent;
void wait()
{
for (int i = 0; i < 100; i++) {
usleep(100);
- QCoreApplication::processEvents();
+ TQCoreApplication::processEvents();
}
}
void TestAuth::test_Auth_checkAuthorization()
{
// This needs the file org.qt.policykit.examples.policy from examples to be installed
- UnixProcessSubject process(QCoreApplication::applicationPid());
+ UnixProcessSubject process(TQCoreApplication::applicationPid());
Authority::Result result;
// Check if this method returns good authorization results
Authority *authority = Authority::instance();
result = authority->checkAuthorizationSync("org.qt.policykit.examples.kick", process, Authority::None);
- QCOMPARE(result, Authority::No);
- QVERIFY(!authority->hasError());
+ TQCOMPARE(result, Authority::No);
+ TQVERIFY(!authority->hasError());
result = authority->checkAuthorizationSync("org.qt.policykit.examples.cry", process, Authority::None);
- QCOMPARE(result, Authority::Yes);
- QVERIFY(!authority->hasError());
+ TQCOMPARE(result, Authority::Yes);
+ TQVERIFY(!authority->hasError());
result = authority->checkAuthorizationSync("org.qt.policykit.examples.bleed", process, Authority::None);
- QCOMPARE(result, Authority::Challenge);
- QVERIFY(!authority->hasError());
+ TQCOMPARE(result, Authority::Challenge);
+ TQVERIFY(!authority->hasError());
// Now we try async methods
- QSignalSpy spy(authority, SIGNAL(checkAuthorizationFinished(PolkitQt1::Authority::Result)));
+ TQSignalSpy spy(authority, SIGNAL(checkAuthorizationFinished(PolkitTQt1::Authority::Result)));
// Call asynchronous checkAuthorization
authority->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None);
// Give the polkit time to obtain the result and emit the signal with it
wait();
// Test if the signal was emitted
- QCOMPARE(spy.count(), 1);
+ TQCOMPARE(spy.count(), 1);
// Test the result
- result = qVariantValue<PolkitQt1::Authority::Result> (spy.takeFirst()[0]);
- QCOMPARE(result, Authority::No);
- QVERIFY(!authority->hasError());
+ result = qVariantValue<PolkitTQt1::Authority::Result> (spy.takeFirst()[0]);
+ TQCOMPARE(result, Authority::No);
+ TQVERIFY(!authority->hasError());
spy.clear();
// Let's test the cancellability
@@ -56,7 +56,7 @@ void TestAuth::test_Auth_checkAuthorization()
authority->checkAuthorizationCancel();
// Wait and check if the signal arrieved
wait();
- QCOMPARE(spy.count(), 0);
+ TQCOMPARE(spy.count(), 0);
// Check if it can cancel user authentication dialog
authority->checkAuthorization("org.qt.policykit.examples.bleed", process, Authority::AllowUserInteraction);
@@ -64,16 +64,16 @@ void TestAuth::test_Auth_checkAuthorization()
sleep(1);
// And now kill it
authority->checkAuthorizationCancel();
- QVERIFY(!authority->hasError());
+ TQVERIFY(!authority->hasError());
// But how to test if it was successful?
- qWarning() << "You should see an authentication dialog for a short period.";
+ tqWarning() << "You should see an authentication dialog for a short period.";
}
void TestAuth::test_Auth_enumerateActions()
{
// This needs the file org.qt.policykit.examples.policy from examples to be installed
ActionDescription::List list = Authority::instance()->enumerateActionsSync();
- QVERIFY(!Authority::instance()->hasError());
+ TQVERIFY(!Authority::instance()->hasError());
// Check whether enumerateAction returns at least example actions
int count = 0;
Q_FOREACH(const ActionDescription &ad, list) {
@@ -82,91 +82,91 @@ void TestAuth::test_Auth_enumerateActions()
(ad.actionId() == "org.qt.policykit.examples.bleed"))
count++;
}
- QCOMPARE(count, 3);
+ TQCOMPARE(count, 3);
// Test asynchronous version as well
list.clear();
count = 0;
- QSignalSpy spy(Authority::instance(), SIGNAL(enumerateActionsFinished(PolkitQt1::ActionDescription::List)));
+ TQSignalSpy spy(Authority::instance(), SIGNAL(enumerateActionsFinished(PolkitTQt1::ActionDescription::List)));
Authority::instance()->enumerateActions();
wait();
- QCOMPARE(spy.count(), 1);
- list = qVariantValue<PolkitQt1::ActionDescription::List> (spy.takeFirst()[0]);
- QVERIFY(!Authority::instance()->hasError());
+ TQCOMPARE(spy.count(), 1);
+ list = qVariantValue<PolkitTQt1::ActionDescription::List> (spy.takeFirst()[0]);
+ TQVERIFY(!Authority::instance()->hasError());
Q_FOREACH(const ActionDescription &ad, list) {
if ((ad.actionId() == "org.qt.policykit.examples.kick") ||
(ad.actionId() == "org.qt.policykit.examples.cry") ||
(ad.actionId() == "org.qt.policykit.examples.bleed"))
count++;
}
- QCOMPARE(count, 3);
+ TQCOMPARE(count, 3);
// Test cancelling the enumeration
spy.clear();
Authority::instance()->enumerateActions();
Authority::instance()->enumerateActionsCancel();
wait();
- QCOMPARE(spy.count(), 0);
- QVERIFY(!Authority::instance()->hasError());
+ TQCOMPARE(spy.count(), 0);
+ TQVERIFY(!Authority::instance()->hasError());
}
void TestAuth::test_Identity()
{
// Get real name and id of current user and group
struct passwd *userinfo = getpwuid(getuid());
- QString userName = userinfo->pw_name;
+ TQString userName = userinfo->pw_name;
unsigned int userId = userinfo->pw_uid;
unsigned int groupId = userinfo->pw_gid;
// Try to create UnixUser from username
UnixUserIdentity user(userName);
- QVERIFY(user.identity());
+ TQVERIFY(user.identity());
// Create generic Identity from UnixUser via string representation
Identity id = Identity::fromString(user.toString());
// Compare obtained uid with real uid
- QCOMPARE(id.toUnixUserIdentity().uid(), userId);
+ TQCOMPARE(id.toUnixUserIdentity().uid(), userId);
// Create generic Identity from UnixGroup via string representation
UnixGroupIdentity group(groupId);
- QVERIFY(group.identity());
+ TQVERIFY(group.identity());
id = Identity::fromString(group.toString());
- QCOMPARE(id.toUnixGroupIdentity().gid(), groupId);
+ TQCOMPARE(id.toUnixGroupIdentity().gid(), groupId);
// Test setting gid to another value
group.setGid(9999U);
id = Identity::fromString(group.toString());
- QCOMPARE(id.toUnixGroupIdentity().gid(), 9999U);
+ TQCOMPARE(id.toUnixGroupIdentity().gid(), 9999U);
}
void TestAuth::test_Authority()
{
Authority *authority = Authority::instance();
- QVERIFY(authority);
- QVERIFY(!authority->hasError());
+ TQVERIFY(authority);
+ TQVERIFY(!authority->hasError());
// Verify emiting of the signals
- QSignalSpy spy(authority, SIGNAL(consoleKitDBChanged()));
- QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.ConsoleKit",
+ TQSignalSpy spy(authority, SIGNAL(consoleKitDBChanged()));
+ TQDBusMessage msg = TQDBusMessage::createMethodCall("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager",
"OpenSession");
- QDBusMessage reply = QDBusConnection::systemBus().call(msg);
- QString cookie;
- cookie = qVariantValue<QString> (reply.arguments()[0]);
+ TQDBusMessage reply = TQDBusConnection::systemBus().call(msg);
+ TQString cookie;
+ cookie = qVariantValue<TQString> (reply.arguments()[0]);
- msg = QDBusMessage::createMethodCall("org.freedesktop.ConsoleKit",
+ msg = TQDBusMessage::createMethodCall("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager",
"CloseSession");
- msg.setArguments(QList<QVariant> () << cookie);
- QDBusConnection::systemBus().call(msg);
+ msg.setArguments(TQList<TQVariant> () << cookie);
+ TQDBusConnection::systemBus().call(msg);
// FIXME: Emitting consoleKitDBChanged is not working now
- qWarning() << "Emitting consoleKitDBChanged is not working now, test will be skipped";
- //QVERIFY(spy.count() > 0);
- QVERIFY(!authority->hasError());
+ tqWarning() << "Emitting consoleKitDBChanged is not working now, test will be skipped";
+ //TQVERIFY(spy.count() > 0);
+ TQVERIFY(!authority->hasError());
// configChanged signal from authority requires changing some policy files
// and it would require user interaction (typing the password)
@@ -176,16 +176,16 @@ void TestAuth::test_Authority()
void TestAuth::test_Subject()
{
// Get pid of this appication
- qint64 pid = QCoreApplication::applicationPid();
+ qint64 pid = TQCoreApplication::applicationPid();
// Create unix process for it
UnixProcessSubject *process = new UnixProcessSubject(pid);
// Test if pid doesn't differ
- QCOMPARE(process->pid(), pid);
+ TQCOMPARE(process->pid(), pid);
// Serialize and deserialize subject
//Subject *subject = Subject::fromString(process->toString());
// and try it
- //QCOMPARE(((UnixProcess *) subject)->pid(), pid);
+ //TQCOMPARE(((UnixProcess *) subject)->pid(), pid);
delete process;
}
@@ -194,23 +194,23 @@ void TestAuth::test_Session()
/*
UnixUser user(getuid());
Session *session = new Session(&user, "/org/freedesktop/ConsoleKit/Session2");
- QSignalSpy spy_completed(session, SIGNAL(completed(bool)));
- QSignalSpy spy_request(session, SIGNAL(request(QString,bool)));
- QSignalSpy spy_error(session, SIGNAL(showError(QString)));
- QSignalSpy spy_info(session, SIGNAL(showInfo(QString)));
+ TQSignalSpy spy_completed(session, SIGNAL(completed(bool)));
+ TQSignalSpy spy_request(session, SIGNAL(request(TQString,bool)));
+ TQSignalSpy spy_error(session, SIGNAL(showError(TQString)));
+ TQSignalSpy spy_info(session, SIGNAL(showInfo(TQString)));
session->initiate();
session->response("aaa");
// Canceling should emit the "completed" signal
session->cancel();
- QCOMPARE(spy_completed.count(), 1);
+ TQCOMPARE(spy_completed.count(), 1);
- //UnixProcess *process = new UnixProcess(QCoreApplication::applicationPid());
+ //UnixProcess *process = new UnixProcess(TQCoreApplication::applicationPid());
//Authority::instance()->checkAuthorization("org.qt.policykit.examples.kick", process, Authority::None);
- qDebug() << "COMPLETED:" << spy_completed.count();
- qDebug() << "REQUEST:" << spy_request.count();
- qDebug() << "ERROR:" << spy_error.count();
- qDebug() << "INFO:" << spy_info.count();
+ tqDebug() << "COMPLETED:" << spy_completed.count();
+ tqDebug() << "REQUEST:" << spy_request.count();
+ tqDebug() << "ERROR:" << spy_error.count();
+ tqDebug() << "INFO:" << spy_info.count();
*/
}
@@ -221,15 +221,15 @@ void TestAuth::test_Details()
details.insert("2", "bbb");
details.insert("3", "ccc");
details.insert("4", "ddd");
- QCOMPARE(details.lookup("1"), QString("aaa"));
- QCOMPARE(details.lookup("2"), QString("bbb"));
- QCOMPARE(details.lookup("3"), QString("ccc"));
- QCOMPARE(details.lookup("4"), QString("ddd"));
- QList<QString> list = details.keys();
- QVERIFY(list.contains("1"));
- QVERIFY(list.contains("2"));
- QVERIFY(list.contains("3"));
- QVERIFY(list.contains("4"));
+ TQCOMPARE(details.lookup("1"), TQString("aaa"));
+ TQCOMPARE(details.lookup("2"), TQString("bbb"));
+ TQCOMPARE(details.lookup("3"), TQString("ccc"));
+ TQCOMPARE(details.lookup("4"), TQString("ddd"));
+ TQList<TQString> list = details.keys();
+ TQVERIFY(list.contains("1"));
+ TQVERIFY(list.contains("2"));
+ TQVERIFY(list.contains("3"));
+ TQVERIFY(list.contains("4"));
}
-QTEST_MAIN(TestAuth)
+TQTEST_MAIN(TestAuth)
diff --git a/test/test.h b/test/test.h
index c9d4dd8ac..4a3579d89 100644
--- a/test/test.h
+++ b/test/test.h
@@ -1,10 +1,10 @@
#ifndef TEST_H
#define TEST_H
-#include <QtCore/QObject>
-#include <QtTest/QtTest>
+#include <TQtCore/TQObject>
+#include <TQtTest/TQtTest>
-class TestAuth : public QObject
+class TestAuth : public TQObject
{
Q_OBJECT
private Q_SLOTS: