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: Alberto Aguirre <alberto.aguirre@canonical.com>
19
#include "src/server/graphics/nested/display_buffer.h"
20
#include "src/server/graphics/nested/host_connection.h"
21
#include "src/server/input/null_input_dispatcher.h"
23
#include "mir_test_doubles/mock_egl.h"
24
#include "mir_test_doubles/stub_gl_config.h"
25
#include "mir_test_doubles/stub_cursor_listener.h"
26
#include "mir_test/fake_shared.h"
28
#include <gtest/gtest.h>
29
#include <gmock/gmock.h>
31
namespace geom = mir::geometry;
32
namespace mg = mir::graphics;
33
namespace mgn = mg::nested;
34
namespace mgnd = mg::nested::detail;
35
namespace mi = mir::input;
36
namespace mt = mir::test;
37
namespace mtd = mir::test::doubles;
39
class NullHostSurface : public mgn::HostSurface
42
EGLNativeWindowType egl_native_window() override { return {}; }
43
void set_event_handler(mir_surface_event_callback, void*) override {}
46
struct NestedDisplayBufferTest : testing::Test
48
NestedDisplayBufferTest()
49
: egl_disp_handle{mock_egl.fake_egl_display,
50
mt::fake_shared(stub_gl_config)},
51
default_rect{{100,100}, {800,600}}
53
testing::NiceMock<mtd::MockEGL> mock_egl;
54
mtd::StubGLConfig stub_gl_config;
55
NullHostSurface null_host_surface;
56
mi::NullInputDispatcher null_input_dispatcher;
57
std::shared_ptr<mi::CursorListener> cursor =
58
std::make_shared<mtd::StubCursorListener>();
59
mgnd::EGLDisplayHandle egl_disp_handle;
60
geom::Rectangle const default_rect;
63
TEST_F(NestedDisplayBufferTest, alpha_enabled_pixel_format_enables_destination_alpha)
65
mgnd::DisplayBuffer db{
67
mt::fake_shared(null_host_surface),
69
mt::fake_shared(null_input_dispatcher),
71
mir_pixel_format_abgr_8888};
73
EXPECT_TRUE(db.uses_alpha());
76
TEST_F(NestedDisplayBufferTest, non_alpha_pixel_format_disables_destination_alpha)
78
mgnd::DisplayBuffer db{
80
mt::fake_shared(null_host_surface),
82
mt::fake_shared(null_input_dispatcher),
84
mir_pixel_format_xbgr_8888};
86
EXPECT_FALSE(db.uses_alpha());