2
* Copyright © 2014 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
19
#include "examples/demo-shell/demo_compositor.h"
21
#include "mir/geometry/rectangle.h"
22
#include "src/server/scene/surface_stack.h"
23
#include "src/server/scene/basic_surface.h"
24
#include "src/server/report/null_report_factory.h"
26
#include "mir_test_doubles/mock_gl.h"
27
#include "mir_test_doubles/stub_display_buffer.h"
28
#include "mir_test_doubles/stub_gl_program_factory.h"
29
#include "mir_test_doubles/stub_buffer_stream.h"
30
#include "mir_test_doubles/null_surface_configurator.h"
31
#include "mir_test/fake_shared.h"
33
#include <gtest/gtest.h>
34
#include <gmock/gmock.h>
36
namespace mtd = mir::test::doubles;
37
namespace geom = mir::geometry;
38
namespace me = mir::examples;
39
namespace mt = mir::test;
40
namespace ms = mir::scene;
45
struct DemoCompositor : testing::Test
49
using namespace testing;
51
surface_stack.add_surface(
52
mt::fake_shared(stub_surface),
54
mir::input::InputReceptionMode::normal);
56
post_surface_buffer();
59
void post_surface_buffer()
61
mir::graphics::Buffer* old_buffer;
63
stub_surface.swap_buffers(
65
[&old_buffer] (mir::graphics::Buffer* buffer)
70
stub_surface.swap_buffers(
72
[] (mir::graphics::Buffer*) {});
75
testing::NiceMock<mtd::MockGL> mock_gl;
76
mtd::StubDisplayBuffer stub_display_buffer{
77
geom::Rectangle{{0,0}, {1000,1000}}};
78
mir::scene::SurfaceStack surface_stack{mir::report::null_scene_report()};
79
mtd::StubGLProgramFactory stub_factory;
80
ms::BasicSurface stub_surface{
82
geom::Rectangle{{0,0},{100,100}},
84
std::make_shared<mtd::StubBufferStream>(),
85
std::shared_ptr<mir::input::InputChannel>(),
86
std::shared_ptr<mir::input::InputSender>(),
87
std::make_shared<mtd::NullSurfaceConfigurator>(),
88
std::shared_ptr<mir::graphics::CursorImage>(),
89
mir::report::null_scene_report()};
91
me::DemoCompositor demo_compositor{
93
mt::fake_shared(surface_stack),
95
mir::report::null_compositor_report()};
100
// Regression test for https://bugs.launchpad.net/mir/+bug/1359487
101
TEST_F(DemoCompositor, sets_surface_visibility)
103
using namespace testing;
105
demo_compositor.composite();
108
stub_surface.query(mir_surface_attrib_visibility),
109
Eq(mir_surface_visibility_exposed));
113
demo_compositor.composite();
116
stub_surface.query(mir_surface_attrib_visibility),
117
Eq(mir_surface_visibility_occluded));