on efbcaa7 help sign in
unity8/tests/plugins/Unity/Launcher/appdrawermodeltest.cpp
68 lines 2.1 kB history raw
1/*
2 * Copyright 2017 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "ualwrapper.h"
18#include "xdgwatcher.h"
19#include "appdrawermodel.h"
21#include <QtTest>
23class AppDrawerModelTest : public QObject
25 Q_OBJECT
27private:
28 AppDrawerModel *appDrawerModel;
30private Q_SLOTS:
32 void initTestCase() {
33 UalWrapper::s_list << QStringLiteral("app1") << QStringLiteral("app2");
34 appDrawerModel = new AppDrawerModel(this);
35 QTRY_VERIFY(!appDrawerModel->refreshing());
37 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 2);
38 }
40 void testUalAppAddedRemoved() {
41 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 2);
43 UalWrapper::instance()->addMockApp("app3");
44 XdgWatcher::instance()->addMockApp("app3");
45 qApp->processEvents(); // ualwrapper is connected Queued
47 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 3);
49 UalWrapper::instance()->removeMockApp("app3");
50 XdgWatcher::instance()->removeMockApp("app3");
51 qApp->processEvents();
53 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 2);
54 }
56 void testRefresh() {
57 QSignalSpy refreshingSpy(appDrawerModel, &AppDrawerModel::refreshingChanged);
59 appDrawerModel->refresh();
60 QTRY_VERIFY(!appDrawerModel->refreshing());
62 QCOMPARE(refreshingSpy.count(), 2);
63 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 2);
64 }
65};
67QTEST_GUILESS_MAIN(AppDrawerModelTest)
68#include "appdrawermodeltest.moc"