2 * Copyright (C) 2014 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
22#include <QTemporaryDir>
25class SystemTest: public QObject
35 void testNoticeChanges();
40 void enableUpdateOnly();
43 bool updateIsEnabled();
47 QFile enableUpdateWizardFile;
50SystemTest::SystemTest()
53 qputenv("HOME", dir.path().toUtf8());
54 enableDir.setPath(dir.path() + "/.config/ubuntu-system-settings/wizard-has-run/");
55 QString updateFileName = enableDir.filePath(QString::number(system.CURRENT_VERSION));
56 enableUpdateWizardFile.setFileName(updateFileName);
59void SystemTest::enable()
61 enableDir.removeRecursively();
62 QCOMPARE(isEnabled(), true);
65void SystemTest::disable()
67 enableDir.mkpath(".");
68 enableUpdateWizardFile.open(QIODevice::WriteOnly);
69 enableUpdateWizardFile.close();
70 QCOMPARE(isEnabled(), false);
71 QCOMPARE(updateIsEnabled(), false);
74bool SystemTest::isEnabled()
76 return !enableDir.exists();
79void SystemTest::enableUpdateOnly()
82 enableUpdateWizardFile.remove();
83 QCOMPARE(updateIsEnabled(), true);
86bool SystemTest::updateIsEnabled()
88 return !enableUpdateWizardFile.exists();
91void SystemTest::testEnable()
96 QVERIFY(!system.wizardEnabled());
98 system.setWizardEnabled(true);
99 QVERIFY(system.wizardEnabled());
100 QVERIFY(isEnabled());
103void SystemTest::testDisable()
108 QVERIFY(system.wizardEnabled());
110 system.setWizardEnabled(false);
111 QVERIFY(!system.wizardEnabled());
112 QVERIFY(!isEnabled());
115void SystemTest::testUpdate()
120 QVERIFY(system.wizardEnabled());
121 QVERIFY(system.versionToShow() == system.CURRENT_VERSION);
123 system.setWizardEnabled(false);
124 QVERIFY(!system.wizardEnabled());
125 QVERIFY(!isEnabled());
126 QVERIFY(!updateIsEnabled());
129void SystemTest::testNoticeChanges()
134 QSignalSpy spy(&system, SIGNAL(wizardEnabledChanged()));
136 // System only guarantees its signals work correcty when using its own set
137 // methods (i.e. it won't necessarily notice if we modify the file behind
138 // the scenes). This is because watching all parent directories of the
139 // wizard-has-run file with QFileSystemWatcher is a nightmare and waste of
140 // resources for the corner case it is. So we'll just test the set method.
142 system.setWizardEnabled(false);
143 QTRY_COMPARE(spy.count(), 1);
145 system.setWizardEnabled(true);
146 QTRY_COMPARE(spy.count(), 2);
148 system.setWizardEnabled(false);
149 QTRY_COMPARE(spy.count(), 3);
151 system.setWizardEnabled(true);
152 QTRY_COMPARE(spy.count(), 4);
155QTEST_MAIN(SystemTest)
156#include "tst_system.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list