2
* Copyright © 2012 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 version 3 as
6
* published by the Free Software Foundation.
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/>.
16
* Authored By: Robert Carr <racarr@canonical.com>
19
#include "mir/compositor/buffer_bundle.h"
20
#include "mir/frontend/application_session.h"
21
#include "mir/frontend/application_session_model.h"
22
#include "mir/frontend/registration_order_focus_selection_strategy.h"
23
#include "mir/frontend/single_visibility_focus_mechanism.h"
24
#include "mir/surfaces/surface.h"
25
#include "mir_test/mock_buffer_bundle.h"
26
#include "mir_test/empty_deleter.h"
27
#include "mir_test/mock_application_surface_organiser.h"
29
#include <gmock/gmock.h>
30
#include <gtest/gtest.h>
33
namespace mc = mir::compositor;
34
namespace mf = mir::frontend;
35
namespace ms = mir::surfaces;
40
struct MockApplicationSession : public mf::ApplicationSession
42
MockApplicationSession(std::shared_ptr<ms::ApplicationSurfaceOrganiser> organiser,
43
std::string name) : ApplicationSession(organiser, name)
46
MOCK_METHOD0(hide,void());
47
MOCK_METHOD0(show,void());
52
TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)
54
using namespace ::testing;
55
std::shared_ptr<ms::ApplicationSurfaceOrganiser> organiser(new ms::MockApplicationSurfaceOrganiser);
56
std::shared_ptr<mf::ApplicationSessionModel> model(new mf::ApplicationSessionModel);
58
MockApplicationSession m1(organiser, "Visual Studio 7");
59
MockApplicationSession m2(organiser, "Visual Studio 8");
60
MockApplicationSession m3(organiser, "Visual Studio 9");
62
std::shared_ptr<mf::ApplicationSession> app1(&m1, mir::EmptyDeleter());
63
std::shared_ptr<mf::ApplicationSession> app2(&m2, mir::EmptyDeleter());
64
std::shared_ptr<mf::ApplicationSession> app3(&m3, mir::EmptyDeleter());
66
mf::SingleVisibilityFocusMechanism focus_mechanism(model);
68
EXPECT_CALL(m1, show()).Times(1);
69
EXPECT_CALL(m2, hide()).Times(1);
70
EXPECT_CALL(m3, hide()).Times(1);
72
model->insert_session(app1);
73
model->insert_session(app2);
74
model->insert_session(app3);
76
focus_mechanism.set_focus_to(app1);