2 * Copyright (C) 2014,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 "ApplicationInfo.h"
18#include "ApplicationTestInterface.h"
19#include "ApplicationManager.h"
20#include "SessionManager.h"
21#include "SurfaceManager.h"
23#include "MirSurface.h"
27#include <QtDBus/QtDBus>
31ApplicationTestInterface::ApplicationTestInterface(QObject* parent)
32 : QDBusAbstractAdaptor(parent)
34 QDBusConnection connection = QDBusConnection::sessionBus();
35 connection.registerService("com.canonical.Unity8");
36 connection.registerObject("/com/canonical/Unity8/Mocks", parent);
39Session* ApplicationTestInterface::addChildSession(Session* existingSession, const QString& surfaceImage)
41 if (!existingSession) return nullptr;
43 QUrl screenshotUrl = QString("qrc:///Unity/Application/screenshots/%2@12.png")
47 Session* session = SessionManager::singleton()->createSession(
48 QString("%1-Child%2").arg(existingSession->name())
49 .arg(existingSession->childSessions()->count()),
51 existingSession->addChildSession(session);
52 session->createSurface();
57void ApplicationTestInterface::removeSession(Session* existingSession)
59 qDebug() << "ApplicationTestInterface::removeSession - " << existingSession;
62 existingSession->setLive(false);
65void ApplicationTestInterface::removeSurface(MirSurface* existingSurface)
67 qDebug() << "ApplicationTestInterface::removeSurface - " << existingSurface;
70 existingSurface->setLive(false);
73quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage)
75 qDebug() << "ApplicationTestInterface::addChildSession to " << appId;
77 ApplicationInfo* application = ApplicationManager::singleton()->findApplication(appId);
79 qDebug() << "ApplicationTestInterface::addChildSession - No application found for " << appId;
83 Session* parentSession = nullptr;
84 if (m_childSessions.contains(existingSessionId)) {
85 parentSession = m_childSessions[existingSessionId];
86 } else if (application->session()) {
87 parentSession = application->session();
89 qDebug() << "ApplicationTestInterface::addChildSession - No session for " << appId << ":" << existingSessionId;
93 QUrl screenshotUrl = QString("qrc:///Unity/Application/screenshots/%2@12.png")
97 quint32 sessionId = ++nextId;
98 Session* session = SessionManager::singleton()->createSession(
99 QString("%1-Child%2").arg(parentSession->name())
100 .arg(parentSession->childSessions()->count()),
102 parentSession->addChildSession(session);
103 session->createSurface();
104 m_childSessions[sessionId] = session;
109void ApplicationTestInterface::removeSession(quint32 sessionId)
111 if (!m_childSessions.contains(sessionId)) {
112 qDebug() << "ApplicationTestInterface::removeSession - No added session for " << sessionId;
115 Session* session = m_childSessions.take(sessionId);
116 removeSession(session);
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