@@ -0,0 +1,140 @@
2+ * Copyright (C) 2017 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
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 General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17+ * Pete Woods <pete.woods@canonical.com>
22+#include <libqtdbustest/DBusTestRunner.h>
23+#include <libqtdbusmock/DBusMock.h>
28+using namespace QtDBusTest;
29+using namespace QtDBusMock;
31+class PlatformTest: public QObject
48+ QScopedPointer<TestFixture> m_data;
50+ void registerLogin1(bool canMultiSession, bool canGraphical)
52+ m_data->mock.registerLogin1({{"DefaultSeat", QVariantMap
54+ {"CanMultiSession", canMultiSession},
55+ {"CanGraphical", canGraphical}
60+ void registerHostname1(const QString& chassis)
62+ m_data->mock.registerHostname1({
69+ m_data->dbus.startServices();
76+ m_data.reset(new TestFixture);
86+ QTest::addColumn<QString>("chassis");
87+ QTest::addColumn<bool>("result");
89+ QTest::newRow("desktop") << "desktop" << true;
90+ QTest::newRow("laptop") << "laptop" << true;
91+ QTest::newRow("server") << "server" << true;
92+ QTest::newRow("tablet") << "tablet" << false;
93+ QTest::newRow("handset") << "handset" << false;
94+ QTest::newRow("vm") << "vm" << true;
95+ QTest::newRow("container") << "container" << true;
100+ QFETCH(QString, chassis);
101+ QFETCH(bool, result);
103+ registerLogin1(true, true);
104+ registerHostname1(chassis);
108+ QCOMPARE(p.isPC(), result);
109+ QCOMPARE(p.chassis(), chassis);
112+ void testIsMultiSession_data()
114+ QTest::addColumn<bool>("canMultiSession");
115+ QTest::addColumn<bool>("canGraphical");
116+ QTest::addColumn<bool>("result");
118+ QTest::newRow("") << true << true << true;
119+ QTest::newRow("") << true << false << false;
120+ QTest::newRow("") << false << true << false;
121+ QTest::newRow("") << false << false << false;
124+ void testIsMultiSession()
126+ QFETCH(bool, canMultiSession);
127+ QFETCH(bool, canGraphical);
128+ QFETCH(bool, result);
130+ registerLogin1(canMultiSession, canGraphical);
131+ registerHostname1("desktop");
135+ QCOMPARE(p.isMultiSession(), result);
139+QTEST_GUILESS_MAIN(PlatformTest)
140+#include "platformtest.moc"