File indexing completed on 2024-12-22 05:13:37
0001 /* 0002 SPDX-FileCopyrightText: 2013 Ivan Cukic <ivan.cukic(at)kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "CleanOnlineTest.h" 0008 0009 #include <QDBusConnection> 0010 #include <QDBusConnectionInterface> 0011 #include <QDebug> 0012 #include <QString> 0013 #include <QTest> 0014 0015 QString CleanOnlineSetup::id1; 0016 QString CleanOnlineSetup::id2; 0017 0018 CleanOnlineTest::CleanOnlineTest(QObject *parent) 0019 : Test(parent) 0020 { 0021 activities.reset(new KActivities::Controller()); 0022 } 0023 0024 CleanOnlineSetup::CleanOnlineSetup(QObject *parent) 0025 : Test(parent) 0026 { 0027 activities.reset(new KActivities::Controller()); 0028 } 0029 0030 OnlineTest::OnlineTest(QObject *parent) 0031 : Test(parent) 0032 { 0033 activities.reset(new KActivities::Controller()); 0034 } 0035 0036 void CleanOnlineTest::testCleanOnlineActivityListing() 0037 { 0038 // Waiting for the service to start, and for us to sync 0039 TEST_WAIT_UNTIL(activities->serviceStatus() == KActivities::Consumer::Running); 0040 0041 QCOMPARE(activities->activities(), QStringList()); 0042 QCOMPARE(activities->serviceStatus(), KActivities::Consumer::Running); 0043 QCOMPARE(activities->currentActivity(), QString()); 0044 0045 QCOMPARE(activities->activities(), QStringList()); 0046 QCOMPARE(activities->activities(KActivities::Info::Running), QStringList()); 0047 QCOMPARE(activities->activities(KActivities::Info::Stopped), QStringList()); 0048 } 0049 0050 void CleanOnlineSetup::testCleanOnlineActivityControl() 0051 { 0052 // Waiting for the service to start, and for us to sync 0053 TEST_WAIT_UNTIL(activities->serviceStatus() == KActivities::Consumer::Running); 0054 0055 auto activity1 = activities->addActivity(QStringLiteral("The first one")); 0056 TEST_WAIT_UNTIL(activity1.isFinished()); 0057 id1 = activity1.result(); 0058 0059 auto activity2 = activities->addActivity(QStringLiteral("The second one")); 0060 TEST_WAIT_UNTIL(activity2.isFinished()); 0061 id2 = activity2.result(); 0062 0063 TEST_WAIT_UNTIL(activities->currentActivity() == id1); 0064 0065 auto f1 = activities->setCurrentActivity(activity2.result()); 0066 TEST_WAIT_UNTIL(f1.isFinished()); 0067 TEST_WAIT_UNTIL(activities->currentActivity() == id2); 0068 0069 auto f2 = activities->setCurrentActivity(id1); 0070 TEST_WAIT_UNTIL(f2.isFinished()); 0071 TEST_WAIT_UNTIL(activities->currentActivity() == id1); 0072 0073 auto f3 = activities->setActivityName(id1, QStringLiteral("Renamed activity")); 0074 TEST_WAIT_UNTIL(f3.isFinished()); 0075 0076 KActivities::Info ac(id1); 0077 TEST_WAIT_UNTIL(ac.name() == QLatin1String("Renamed activity")); 0078 0079 TEST_WAIT_UNTIL(activities->activities().size() == 2); 0080 } 0081 0082 void OnlineTest::testOnlineActivityListing() 0083 { 0084 // Waiting for the service to start, and for us to sync 0085 TEST_WAIT_UNTIL(activities->serviceStatus() == KActivities::Consumer::Running); 0086 0087 KActivities::Info i1(CleanOnlineSetup::id1); 0088 KActivities::Info i2(CleanOnlineSetup::id2); 0089 0090 TEST_WAIT_UNTIL(i1.name() == QLatin1String("Renamed activity")); 0091 TEST_WAIT_UNTIL(i2.name() == QLatin1String("The second one")); 0092 0093 qDebug() << CleanOnlineSetup::id1 << i1.name(); 0094 qDebug() << CleanOnlineSetup::id2 << i2.name(); 0095 } 0096 0097 void CleanOnlineTest::cleanupTestCase() 0098 { 0099 Q_EMIT testFinished(); 0100 } 0101 0102 void CleanOnlineSetup::cleanupTestCase() 0103 { 0104 Q_EMIT testFinished(); 0105 } 0106 0107 void OnlineTest::cleanupTestCase() 0108 { 0109 Q_EMIT testFinished(); 0110 } 0111 0112 #include "moc_CleanOnlineTest.cpp"