/*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#ifndef QTMIR_FAKE_SESSION_H
#define QTMIR_FAKE_SESSION_H
namespace qtmir {
class FakeSession : public SessionInterface {
Q_OBJECT
public:
FakeSession()
: SessionInterface(0)
, m_state(Starting)
{
}
// For QML use
void release() override {}
QString name() const override { return QString("foo-session"); }
unity::shell::application::ApplicationInfoInterface* application() const override { return m_application; }
MirSurfaceItemInterface* surface() const override { return nullptr; }
SessionInterface* parentSession() const override { return nullptr; }
SessionModel* childSessions() const override { return nullptr; }
State state() const override { return m_state; }
bool fullscreen() const override { return false; }
bool live() const override { return true; }
std::shared_ptr session() const override { return nullptr; }
// For MirSurfaceItem and MirSurfaceManager use
void setSurface(MirSurfaceItemInterface*) override {}
// For Application use
void setApplication(unity::shell::application::ApplicationInfoInterface* app) override {
if (m_application != app) {
m_application = app;
Q_EMIT applicationChanged(m_application);
}
}
void suspend() override {
if (m_state == Running) {
setState(Suspending);
}
}
void resume() override {
if (m_state == Suspending || m_state == Suspended) {
setState(Running);
}
}
void stop() override {
setState(Stopped);
}
// For SessionManager use
void addChildSession(SessionInterface*) override {}
void insertChildSession(uint, SessionInterface*) override {}
void removeChildSession(SessionInterface*) override {}
void foreachChildSession(std::function) const override {}
std::shared_ptr activePromptSession() const override {
return std::shared_ptr();
}
void foreachPromptSession(std::function&)>) const override {}
void setFullscreen(bool) override {}
void setLive(const bool) override {}
void appendPromptSession(const std::shared_ptr&) override {}
void removePromptSession(const std::shared_ptr&) override {}
// For tests
void setState(State state) {
if (m_state != state) {
m_state = state;
Q_EMIT stateChanged(m_state);
}
}
private:
unity::shell::application::ApplicationInfoInterface* m_application;
State m_state;
};
} // namespace qtmi
#endif // QTMIR_FAKE_SESSION_H