467
474
QCOMPARE(launcherModel->get(1)->appId(), QString("abs-icon"));
468
475
QCOMPARE(spy.count(), 2);
478
void testAddSyncsToAS() {
479
// Make sure launcher and AS are in sync when we start the test
480
QCOMPARE(launcherModel->rowCount(), getASConfig().count());
482
int oldCount = launcherModel->rowCount();
483
appManager->addApplication(new MockApp("rel-icon"));
484
QCOMPARE(launcherModel->rowCount(), oldCount + 1);
485
QCOMPARE(launcherModel->rowCount(), getASConfig().count());
488
void testRemoveSyncsToAS() {
489
// Make sure launcher and AS are in sync when we start the test
490
QCOMPARE(launcherModel->rowCount(), getASConfig().count());
492
int oldCount = launcherModel->rowCount();
493
appManager->stopApplication("abs-icon");
494
QCOMPARE(launcherModel->rowCount(), oldCount - 1);
495
QCOMPARE(launcherModel->rowCount(), getASConfig().count());
498
void testMoveSyncsToAS() {
499
// Make sure launcher and AS are in sync when we start the test
500
QCOMPARE(launcherModel->rowCount(), getASConfig().count());
502
for (int i = 0; i < launcherModel->rowCount(); i++) {
503
QString launcherAppId = launcherModel->get(i)->appId();
504
QString asAppId = getASConfig().at(i).value("id").toString();
505
QCOMPARE(launcherAppId, asAppId);
508
launcherModel->move(0, 1);
510
for (int i = 0; i < launcherModel->rowCount(); i++) {
511
QString launcherAppId = launcherModel->get(i)->appId();
512
QString asAppId = getASConfig().at(i).value("id").toString();
513
QCOMPARE(launcherAppId, asAppId);
517
void testCountChangeSyncsToAS() {
518
// Find the index of the abs-icon app
519
int index = launcherModel->findApplication("abs-icon");
521
// Make sure it's invisible and 0 at the beginning
522
QCOMPARE(getASConfig().at(index).value("countVisible").toBool(), false);
523
QCOMPARE(getASConfig().at(index).value("count").toInt(), 0);
525
// Change the count of the abs-icon app through D-Bus
526
QDBusInterface interface("com.canonical.Unity.Launcher", "/com/canonical/Unity/Launcher/abs_2Dicon", "org.freedesktop.DBus.Properties");
527
interface.call("Set", "com.canonical.Unity.Launcher.Item", "count", QVariant::fromValue(QDBusVariant(55)));
528
interface.call("Set", "com.canonical.Unity.Launcher.Item", "countVisible", QVariant::fromValue(QDBusVariant(true)));
530
// Make sure it changed to visible and 55
531
QCOMPARE(getASConfig().at(index).value("countVisible").toBool(), true);
532
QCOMPARE(getASConfig().at(index).value("count").toInt(), 55);
472
536
QTEST_GUILESS_MAIN(LauncherModelTest)