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

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/gbm/test_native_gbm_platform.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-01-08 02:04:38 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140108020438-e1npu0pm7qdv5wc4
Tags: upstream-0.1.3+14.04.20140108
Import upstream version 0.1.3+14.04.20140108

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2013 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17
 
 */
18
 
 
19
 
#include "mir/graphics/nested_context.h"
20
 
#include "src/server/graphics/gbm/native_gbm_platform.h"
21
 
 
22
 
#include "mir_test/fake_shared.h"
23
 
#include "mir_test_doubles/mock_drm.h"
24
 
#include "mir_test_doubles/mock_gbm.h"
25
 
 
26
 
#include <gtest/gtest.h>
27
 
#include <gmock/gmock.h>
28
 
 
29
 
namespace mg = mir::graphics;
30
 
namespace mgg = mir::graphics::gbm;
31
 
namespace mt = mir::test;
32
 
namespace mtd = mir::test::doubles;
33
 
 
34
 
namespace
35
 
{
36
 
 
37
 
struct MockNestedContext : public mg::NestedContext
38
 
{
39
 
    MOCK_METHOD0(platform_fd_items, std::vector<int>());
40
 
    MOCK_METHOD1(drm_auth_magic, void(int));
41
 
    MOCK_METHOD1(drm_set_gbm_device, void(struct gbm_device*));
42
 
};
43
 
 
44
 
class NativeGBMPlatformTest : public ::testing::Test
45
 
{
46
 
public:
47
 
    NativeGBMPlatformTest()
48
 
    {
49
 
        using namespace testing;
50
 
 
51
 
        ON_CALL(mock_nested_context, platform_fd_items())
52
 
            .WillByDefault(Return(std::vector<int>{mock_drm.fake_drm.fd()}));
53
 
    }
54
 
 
55
 
protected:
56
 
    ::testing::NiceMock<mtd::MockDRM> mock_drm;
57
 
    ::testing::NiceMock<mtd::MockGBM> mock_gbm;
58
 
    ::testing::NiceMock<MockNestedContext> mock_nested_context;
59
 
};
60
 
 
61
 
}
62
 
 
63
 
TEST_F(NativeGBMPlatformTest, auth_magic_is_delegated_to_nested_context)
64
 
{
65
 
    using namespace testing;
66
 
 
67
 
    mgg::NativeGBMPlatform native;
68
 
 
69
 
    EXPECT_CALL(mock_nested_context, drm_auth_magic(_));
70
 
 
71
 
    native.initialize(mt::fake_shared(mock_nested_context));
72
 
    native.get_ipc_package();
73
 
}
74
 
 
75
 
TEST_F(NativeGBMPlatformTest, sets_gbm_device_during_initialization)
76
 
{
77
 
    using namespace testing;
78
 
 
79
 
    mgg::NativeGBMPlatform native;
80
 
 
81
 
    EXPECT_CALL(mock_nested_context, drm_set_gbm_device(mock_gbm.fake_gbm.device));
82
 
 
83
 
    native.initialize(mt::fake_shared(mock_nested_context));
84
 
}