2 * Copyright (C) 2015 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#include "globalshortcut.h"
20#include <QtQuick/QQuickView>
21#include <QtQuick/QQuickItem>
26class GlobalShortcutTest: public QObject
34 m_view = new QQuickView();
35 m_view->setSource(QUrl::fromLocalFile(testDataDir() + "/" TEST_DIR "/shortcut.qml"));
36 m_shortcut = dynamic_cast<GlobalShortcut*>(m_view->rootObject()->property("shortcut").value<QObject*>());
38 m_inactiveShortcut = dynamic_cast<GlobalShortcut*>(m_view->rootObject()->property("inactiveShortcut").value<QObject*>());
39 QVERIFY(m_inactiveShortcut);
41 m_view->requestActivate();
42 QTest::qWaitForWindowExposed(m_view);
45 void cleanupTestCase()
50 void testGlobalShortcut()
52 QSignalSpy shortcutSpy(m_shortcut, &GlobalShortcut::triggered);
53 // test pressing "Mute Volume"
54 QTest::keyClick(m_view, Qt::Key_VolumeMute);
55 QTRY_COMPARE(shortcutSpy.count(), 1);
56 const QVariantList args = shortcutSpy.takeFirst();
57 // verify we got the signal back and a non-empty shortcut
58 QCOMPARE(args.count(), 1);
59 QVERIFY(!args.first().toString().isEmpty());
62 void testInactiveGlobalShortcut()
64 QSignalSpy shortcutSpy(m_inactiveShortcut, &GlobalShortcut::triggered);
65 // test pressing Ctrl+Alt+L
66 QTest::keyClick(m_view, Qt::Key_L, Qt::ControlModifier|Qt::AltModifier);
67 // verify we didn't get any signal back, shortcut is not active
68 QTRY_COMPARE(shortcutSpy.count(), 0);
72 QPointer<QQuickView> m_view;
73 GlobalShortcut *m_shortcut = nullptr;
74 GlobalShortcut *m_inactiveShortcut = nullptr;
77QTEST_MAIN(GlobalShortcutTest)
79#include "GlobalShortcutTest.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