2
* Copyright © 2013 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
19
#include "mir/graphics/nested_context.h"
20
#include "src/server/graphics/gbm/native_gbm_platform.h"
22
#include "mir_test/fake_shared.h"
23
#include "mir_test_doubles/mock_drm.h"
24
#include "mir_test_doubles/mock_gbm.h"
26
#include <gtest/gtest.h>
27
#include <gmock/gmock.h>
29
namespace mg = mir::graphics;
30
namespace mgg = mir::graphics::gbm;
31
namespace mt = mir::test;
32
namespace mtd = mir::test::doubles;
37
struct MockNestedContext : public mg::NestedContext
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*));
44
class NativeGBMPlatformTest : public ::testing::Test
47
NativeGBMPlatformTest()
49
using namespace testing;
51
ON_CALL(mock_nested_context, platform_fd_items())
52
.WillByDefault(Return(std::vector<int>{mock_drm.fake_drm.fd()}));
56
::testing::NiceMock<mtd::MockDRM> mock_drm;
57
::testing::NiceMock<mtd::MockGBM> mock_gbm;
58
::testing::NiceMock<MockNestedContext> mock_nested_context;
63
TEST_F(NativeGBMPlatformTest, auth_magic_is_delegated_to_nested_context)
65
using namespace testing;
67
mgg::NativeGBMPlatform native;
69
EXPECT_CALL(mock_nested_context, drm_auth_magic(_));
71
native.initialize(mt::fake_shared(mock_nested_context));
72
native.get_ipc_package();
75
TEST_F(NativeGBMPlatformTest, sets_gbm_device_during_initialization)
77
using namespace testing;
79
mgg::NativeGBMPlatform native;
81
EXPECT_CALL(mock_nested_context, drm_set_gbm_device(mock_gbm.fake_gbm.device));
83
native.initialize(mt::fake_shared(mock_nested_context));