~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/android/test_hwc_fallback_gl_renderer.cpp

  • Committer: Package Import Robot
  • Author(s): Alexandros Frantzis
  • Date: 2015-10-08 16:12:19 UTC
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: package-import@ubuntu.com-20151008161219-emk4a1ys51yy0wjb
Tags: upstream-0.17.0+15.10.20151008.2
ImportĀ upstreamĀ versionĀ 0.17.0+15.10.20151008.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "src/platforms/android/server/hwc_fallback_gl_renderer.h"
20
20
#include "mir/graphics/gl_context.h"
21
 
#include "mir/graphics/gl_program_factory.h"
22
 
#include "mir/graphics/gl_primitive.h"
23
 
#include "mir/graphics/gl_texture.h"
 
21
#include "mir/gl/program_factory.h"
 
22
#include "mir/gl/primitive.h"
 
23
#include "mir/gl/texture.h"
24
24
#include "mir/test/doubles/mock_gl.h"
25
25
#include "mir/test/doubles/mock_egl.h"
26
26
#include "mir/test/doubles/stub_renderable.h"
37
37
 
38
38
namespace mg=mir::graphics;
39
39
namespace mga=mir::graphics::android;
 
40
namespace mgl=mir::gl;
40
41
namespace mt=mir::test;
41
42
namespace mtd=mir::test::doubles;
42
43
namespace geom=mir::geometry;
43
44
namespace
44
45
{
45
46
 
46
 
class MockGLProgramFactory : public mg::GLProgramFactory
 
47
class MockGLProgramFactory : public mgl::ProgramFactory
47
48
{
48
49
public:
49
50
    MOCK_CONST_METHOD2(create_gl_program,
50
 
        std::unique_ptr<mg::GLProgram>(std::string const&, std::string const&));
51
 
    MOCK_CONST_METHOD0(create_texture_cache, std::unique_ptr<mg::GLTextureCache>());
 
51
        std::unique_ptr<mgl::Program>(std::string const&, std::string const&));
 
52
    MOCK_CONST_METHOD0(create_texture_cache, std::unique_ptr<mgl::TextureCache>());
52
53
};
53
54
 
54
55
class MockContext : public mg::GLContext
58
59
    MOCK_CONST_METHOD0(release_current, void());
59
60
};
60
61
 
61
 
struct MockTextureCache : public mg::GLTextureCache
 
62
struct MockTextureCache : public mgl::TextureCache
62
63
{
63
64
    MockTextureCache()
64
65
    {
65
66
        ON_CALL(*this, load(testing::_))
66
 
            .WillByDefault(testing::Return(std::make_shared<mg::GLTexture>()));
 
67
            .WillByDefault(testing::Return(std::make_shared<mgl::Texture>()));
67
68
    }
68
 
    MOCK_METHOD1(load, std::shared_ptr<mg::GLTexture>(mg::Renderable const&));
 
69
    MOCK_METHOD1(load, std::shared_ptr<mgl::Texture>(mg::Renderable const&));
69
70
    MOCK_METHOD0(invalidate, void());
70
71
    MOCK_METHOD0(drop_unused, void());
71
72
};
72
73
 
73
 
class StubTextureCache : public mg::GLTextureCache
 
74
class StubTextureCache : public mgl::TextureCache
74
75
{
75
 
    std::shared_ptr<mg::GLTexture> load(mg::Renderable const&)
 
76
    std::shared_ptr<mgl::Texture> load(mg::Renderable const&)
76
77
    {
77
 
        return std::make_shared<mg::GLTexture>();
 
78
        return std::make_shared<mgl::Texture>();
78
79
    }
79
80
    void invalidate()
80
81
    {
92
93
        using namespace testing;
93
94
        ON_CALL(mock_gl_program_factory,create_gl_program(_,_))
94
95
            .WillByDefault(Invoke([](std::string const, std::string const)
95
 
                { return std::unique_ptr<mg::GLProgram>(new mtd::StubGLProgram); }));
 
96
                { return std::unique_ptr<mgl::Program>(new mtd::StubGLProgram); }));
96
97
        ON_CALL(mock_gl_program_factory,create_texture_cache())
97
98
            .WillByDefault(Invoke([]()
98
 
                { return std::unique_ptr<mg::GLTextureCache>(new StubTextureCache); }));
 
99
                { return std::unique_ptr<mgl::TextureCache>(new StubTextureCache); }));
99
100
 
100
101
        ON_CALL(mock_gl, glGetShaderiv(_,_,_))
101
102
            .WillByDefault(SetArgPointee<2>(GL_TRUE));
119
120
    GLint const texcoord_attr_loc{3};
120
121
    GLint const tex_uniform_loc{4};
121
122
    GLint const texid{5};
122
 
    size_t const stride{sizeof(mg::GLVertex)};
 
123
    size_t const stride{sizeof(mgl::Vertex)};
123
124
 
124
125
    testing::NiceMock<MockGLProgramFactory> mock_gl_program_factory;
125
126
    testing::NiceMock<mtd::MockSwappingGLContext> mock_swapping_context;