~alan-griffiths/mir/dont-trace-forks

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/nested/test_nested_display_buffer.cpp

  • Committer: Tarmac
  • Author(s): Daniel van Vugt
  • Date: 2015-05-18 21:30:28 UTC
  • mfrom: (2456.3.14 consistent-alpha-usage)
  • Revision ID: tarmac-20150518213028-8f4nffe8pc9v7ape
Reduce coupling and simplify: Remove DisplayBuffer::uses_alpha() and
switch back to a trivial colour mask for all targets.

Approved by Kevin DuBois, Alan Griffiths, Alberto Aguirre, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2014 Canonical Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 *
16
 
 * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com>
17
 
 */
18
 
 
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"
22
 
 
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"
27
 
 
28
 
#include <gtest/gtest.h>
29
 
#include <gmock/gmock.h>
30
 
 
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;
38
 
 
39
 
class NullHostSurface : public mgn::HostSurface
40
 
{
41
 
public:
42
 
    EGLNativeWindowType egl_native_window() override { return {}; }
43
 
    void set_event_handler(mir_surface_event_callback, void*) override {}
44
 
};
45
 
 
46
 
struct NestedDisplayBufferTest : testing::Test
47
 
{
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}}
52
 
    {}
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;
61
 
};
62
 
 
63
 
TEST_F(NestedDisplayBufferTest, alpha_enabled_pixel_format_enables_destination_alpha)
64
 
{
65
 
    mgnd::DisplayBuffer db{
66
 
        egl_disp_handle,
67
 
        mt::fake_shared(null_host_surface),
68
 
        default_rect,
69
 
        mt::fake_shared(null_input_dispatcher),
70
 
        cursor,
71
 
        mir_pixel_format_abgr_8888};
72
 
 
73
 
    EXPECT_TRUE(db.uses_alpha());
74
 
}
75
 
 
76
 
TEST_F(NestedDisplayBufferTest, non_alpha_pixel_format_disables_destination_alpha)
77
 
{
78
 
    mgnd::DisplayBuffer db{
79
 
        egl_disp_handle,
80
 
        mt::fake_shared(null_host_surface),
81
 
        default_rect,
82
 
        mt::fake_shared(null_input_dispatcher),
83
 
        cursor,
84
 
        mir_pixel_format_xbgr_8888};
85
 
 
86
 
    EXPECT_FALSE(db.uses_alpha());
87
 
}