~hikiko/mir/mir.unity8-desktop-session

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/offscreen/test_offscreen_display.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Kevin Gunn, Ubuntu daily release
  • Date: 2013-11-28 10:05:20 UTC
  • mfrom: (1.1.53)
  • Revision ID: package-import@ubuntu.com-20131128100520-nm0l2ltdr2nj0q4w
Tags: 0.1.2+14.04.20131128.1-0ubuntu1
[ Kevin Gunn ]
* New upstream release 0.1.2
  - graphics: android: improve interface for mga::DisplayDevice so its
    just concerned with rendering and posting.
  - surfaces: rename "surfaces" component to "scene".
  - surfaces, shell: Migrate Session data model from shell to surfaces.
  - graphics: change fill_ipc_package() to use real pointers.
  - mir_client_library.h: Fix typo "do and locking" should be "do any
    locking".
  - API enumerations cleanup: Remove slightly misleading *_enum_max_
    values, and replace them with more accurate plural forms.
  - test_android_communication_package: Do not expect opened fd to be >0,
    we may have closed stdin making this a valid value (LP: #1247718).
  - Update docs about running Mir on the desktop to mention new package
    ubuntu-desktop-mir.
  - offscreen: Add a display that renders its output to offscreen buffers
  - graphics: android: fix regression for hwc1.0 devices introduced in r1228
    (LP: #1252433).
  - OffscreenPlatform provides the services that the offscreen display
    needs from the Platform.
  - graphics: android: consolidate the GLContexts classes in use.
  - Fix uninitialized variable causing random drm_auth_magic test
    failures. (LP: #1252144).
  - Add a fullyish functional Udev wrapper. This currently sits in
    graphics/gbm, but will be moved to the top-level when input device
    detection migrates.
  - Add resizing support to example code; demo-shell and clients.
  - eglapp: Clarify messages about pixel formats (LP: #1168304).
  - Adds support to the MirMotionEvent under pointer_coordinates called
    tool_type. This will allow clients to tell what type of tool is
    being used, from mouse/finger/etc. (LP: #1252498)
  - client,frontend: Report the real available surface pixel formats to
    clients. (LP: #1240833)
  - graphics: android: 1) change hwc1.1 to make use of sync fences during
    the compositor's gl renderloop. Note that we no longer wait for the
    render to complete, we pass this responsibility to the driver and the
    kernel. 2) support nexus 10. (LP: #1252173) (LP: #1203268)
  - shell: don't publish SurfacesContainer - it can be private to shell.
  - gbm: Don't mess up the VT mode on setup failure Only restore the
    previous VT mode during shutdown if it was VT_AUTO.
  - Fix a crash due to a failed eglMakeCurrent() call when in nested mode.
  - shell: unity-mir uses shell::FocusSetter - make the header public again
  - Add resize support to client surfaces (mir::client::MirSurface).
  - graphics: android: support 'old aka 2012' nexus 7 hwc (nvidia tegra3
    SoC) better. (LP: #1231917)
  - Add resize support to *ClientBuffer classes. Now always get dimensions
    from the latest buffer package.
  - android: support driver hooks for the Mali T604 (present in nexus 10)
  - Add width and height to the protocol Buffer messages, in preparation
    for resizable surfaces.
  - surfaces, shell, logging, tests: don't publish headers
    that can be private to surfaces. surfaces/basic_surface.h,
    surfaces/surface_controller.h and shell/surface_builder.h
  - examples: Restore GL framebuffer binding when destroying the render
    target
  - examples, surfaces, shell: remove render_surfaces dependency on
    BasicSurface
  - geometry: remove implementation of streaming operators from headers
    (LP: #1247820)
  - Eliminate the registration order focus sequence, folding it's
    functionality in to the session container.
  - Ensure the session mediator releases acquired buffer resources before
    attempting to acquire a new buffer on behalf of the client. This fixes
    performance regression (LP: #1249210).
  - Some cleanups to test_client_input.cpp.
  - Factor out a bunch of "ClientConfigCommon".
  - Small cleanup to session container test to increase encapsulation.
  - shell, surfaces: Another step in "fixing" the surfaces hierarchies -
    only publish interfaces and putting the data model into surfaces.
  - graphics: android: HWC1.1 use EGL to get further information about
    the framebuffer pixel format.
  - Fix FTBS using use_debflags=ON (building for android-armhf).
    (LP: #1248014)
  - Add a client input receiver report.
  - doc: doxygen 1.8.4 complains about an obsolete config so ran "doxygen
    u Doxyfile.in".
  - Implement resize() for the server-side Surface classes.
  - android: clean up mga::DisplayBuffer and mga::DisplayBufferFactory
  - Add resize() support to BufferStream, in preparation for resizable
    surfaces.
  - Merge metadata changes from the newly reconstructed lp:mir
  - tests: Deduplicate mg::GraphicBufferAllocator stubs.
  - examples: Remove spurious use of mir/shell/surface.h.
  - frontend: remove ClientTrackingSurface from the Surface class
    hierarchy
  - Bumping ABI on server to libmirserver11.
  - Don't mention "Renderable". That interface hasn't existed for quite
    some time now.
  - android-input: Assign more unique touch ids

[ Ubuntu daily release ]
* Automatic snapshot from revision 1167

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "mir/graphics/basic_platform.h"
 
2
#include "src/server/graphics/offscreen/display.h"
 
3
#include "mir/graphics/null_display_report.h"
 
4
#include "src/server/graphics/default_display_configuration_policy.h"
 
5
#include "mir/graphics/display_buffer.h"
 
6
 
 
7
#include "mir_test_doubles/mock_egl.h"
 
8
#include "mir_test_doubles/mock_gl.h"
 
9
 
 
10
#include <gmock/gmock.h>
 
11
#include <gtest/gtest.h>
 
12
 
 
13
#include <stdexcept>
 
14
 
 
15
namespace mg=mir::graphics;
 
16
namespace mgo=mir::graphics::offscreen;
 
17
namespace mtd=mir::test::doubles;
 
18
 
 
19
namespace
 
20
{
 
21
 
 
22
class StubBasicPlatform : public mg::BasicPlatform
 
23
{
 
24
public:
 
25
    StubBasicPlatform(EGLNativeDisplayType native_display)
 
26
        : native_display{native_display}
 
27
    {
 
28
    }
 
29
 
 
30
    EGLNativeDisplayType egl_native_display() const
 
31
    {
 
32
        return native_display;
 
33
    }
 
34
 
 
35
private:
 
36
    EGLNativeDisplayType const native_display;
 
37
};
 
38
 
 
39
class OffscreenDisplayTest : public ::testing::Test
 
40
{
 
41
public:
 
42
    OffscreenDisplayTest()
 
43
    {
 
44
        using namespace ::testing;
 
45
 
 
46
        ON_CALL(mock_egl, eglChooseConfig(_,_,_,1,_))
 
47
            .WillByDefault(DoAll(SetArgPointee<2>(mock_egl.fake_configs[0]),
 
48
                                 SetArgPointee<4>(1),
 
49
                                 Return(EGL_TRUE)));
 
50
 
 
51
        const char* const egl_exts = "EGL_KHR_image EGL_KHR_image_base";
 
52
        const char* const gl_exts = "GL_OES_EGL_image";
 
53
 
 
54
        ON_CALL(mock_egl, eglQueryString(_,EGL_EXTENSIONS))
 
55
            .WillByDefault(Return(egl_exts));
 
56
        ON_CALL(mock_gl, glGetString(GL_EXTENSIONS))
 
57
            .WillByDefault(Return(reinterpret_cast<const GLubyte*>(gl_exts)));
 
58
        ON_CALL(mock_gl, glCheckFramebufferStatus(_))
 
59
            .WillByDefault(Return(GL_FRAMEBUFFER_COMPLETE));
 
60
    }
 
61
 
 
62
    ::testing::NiceMock<mtd::MockEGL> mock_egl;
 
63
    ::testing::NiceMock<mtd::MockGL> mock_gl;
 
64
};
 
65
 
 
66
}
 
67
 
 
68
TEST_F(OffscreenDisplayTest, uses_basic_platform_egl_native_display)
 
69
{
 
70
    using namespace ::testing;
 
71
 
 
72
    EGLNativeDisplayType const native_display{
 
73
        reinterpret_cast<EGLNativeDisplayType>(0x12345)};
 
74
 
 
75
    InSequence s;
 
76
    EXPECT_CALL(mock_egl, eglGetDisplay(native_display));
 
77
    EXPECT_CALL(mock_egl, eglInitialize(mock_egl.fake_egl_display, _, _));
 
78
    EXPECT_CALL(mock_egl, eglTerminate(mock_egl.fake_egl_display));
 
79
 
 
80
    mgo::Display display{
 
81
        std::make_shared<StubBasicPlatform>(native_display),
 
82
        std::make_shared<mg::DefaultDisplayConfigurationPolicy>(),
 
83
        std::make_shared<mg::NullDisplayReport>()};
 
84
}
 
85
 
 
86
TEST_F(OffscreenDisplayTest, makes_fbo_current_rendering_target)
 
87
{
 
88
    using namespace ::testing;
 
89
 
 
90
    GLuint const fbo{66};
 
91
    EGLNativeDisplayType const native_display{
 
92
        reinterpret_cast<EGLNativeDisplayType>(0x12345)};
 
93
 
 
94
    /* Creates GL framebuffer objects */
 
95
    EXPECT_CALL(mock_gl, glGenFramebuffers(1,_))
 
96
        .Times(AtLeast(1))
 
97
        .WillRepeatedly(SetArgPointee<1>(fbo));
 
98
 
 
99
    mgo::Display display{
 
100
        std::make_shared<StubBasicPlatform>(native_display),
 
101
        std::make_shared<mg::DefaultDisplayConfigurationPolicy>(),
 
102
        std::make_shared<mg::NullDisplayReport>()};
 
103
 
 
104
    Mock::VerifyAndClearExpectations(&mock_gl);
 
105
 
 
106
    /* Binds the GL framebuffer objects */
 
107
    display.for_each_display_buffer(
 
108
        [this](mg::DisplayBuffer& db)
 
109
        {
 
110
            EXPECT_CALL(mock_egl, eglMakeCurrent(_,_,_,Ne(EGL_NO_CONTEXT)));
 
111
            EXPECT_CALL(mock_gl, glBindFramebuffer(_,Ne(0)));
 
112
 
 
113
            db.make_current();
 
114
 
 
115
            Mock::VerifyAndClearExpectations(&mock_egl);
 
116
            Mock::VerifyAndClearExpectations(&mock_gl);
 
117
        });
 
118
}
 
119
 
 
120
TEST_F(OffscreenDisplayTest, restores_previous_state_on_fbo_setup_failure)
 
121
{
 
122
    using namespace ::testing;
 
123
 
 
124
    GLuint const old_fbo{66};
 
125
    GLuint const new_fbo{67};
 
126
    EGLNativeDisplayType const native_display{
 
127
        reinterpret_cast<EGLNativeDisplayType>(0x12345)};
 
128
 
 
129
    EXPECT_CALL(mock_gl, glGetIntegerv(GL_FRAMEBUFFER_BINDING, _))
 
130
        .WillOnce(SetArgPointee<1>(old_fbo));
 
131
    EXPECT_CALL(mock_gl, glGetIntegerv(GL_VIEWPORT, _));
 
132
 
 
133
    InSequence s;
 
134
    EXPECT_CALL(mock_gl, glGenFramebuffers(1,_))
 
135
        .WillOnce(SetArgPointee<1>(new_fbo));
 
136
    EXPECT_CALL(mock_gl, glBindFramebuffer(_,new_fbo));
 
137
    EXPECT_CALL(mock_gl, glCheckFramebufferStatus(_))
 
138
        .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT));
 
139
    EXPECT_CALL(mock_gl, glBindFramebuffer(_,old_fbo));
 
140
 
 
141
    EXPECT_THROW({
 
142
        mgo::Display display(
 
143
            std::make_shared<StubBasicPlatform>(native_display),
 
144
            std::make_shared<mg::DefaultDisplayConfigurationPolicy>(),
 
145
            std::make_shared<mg::NullDisplayReport>());
 
146
    }, std::runtime_error);
 
147
}