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

« back to all changes in this revision

Viewing changes to tests/unit-tests/client/gbm/test_mesa_native_display_container.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Daniel van Vugt, Ubuntu daily release
  • Date: 2014-01-08 02:04:38 UTC
  • mfrom: (1.1.54)
  • Revision ID: package-import@ubuntu.com-20140108020438-ikbu7qqm9v2l026y
Tags: 0.1.3+14.04.20140108-0ubuntu1
[ Daniel van Vugt ]
* Preparing for release 0.1.3

[ Ubuntu daily release ]
* Automatic snapshot from revision 1170

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: Robert Carr <robert.carr@canonical.com>
17
 
 */
18
 
 
19
 
#include "src/client/gbm/mesa_native_display_container.h"
20
 
 
21
 
#include "mir_toolkit/mir_client_library.h"
22
 
#include "mir_toolkit/mesa/native_display.h"
23
 
 
24
 
#include <gtest/gtest.h>
25
 
#include <gmock/gmock.h>
26
 
 
27
 
#include <memory>
28
 
 
29
 
namespace mclg = mir::client::gbm;
30
 
 
31
 
namespace
32
 
{
33
 
 
34
 
struct MesaNativeDisplayContainerSetup : public testing::Test
35
 
{
36
 
    MesaNativeDisplayContainerSetup()
37
 
        : container(std::make_shared<mclg::MesaNativeDisplayContainer>()),
38
 
          connection(nullptr)
39
 
    {
40
 
    }
41
 
 
42
 
    std::shared_ptr<mclg::MesaNativeDisplayContainer> const container;
43
 
    MirConnection* connection;
44
 
};
45
 
 
46
 
}
47
 
 
48
 
TEST_F(MesaNativeDisplayContainerSetup, valid_displays_come_from_factory)
49
 
{
50
 
    using namespace ::testing;
51
 
 
52
 
    auto display = container->create(connection);
53
 
    EXPECT_TRUE(container->validate(display));
54
 
 
55
 
    MirEGLNativeDisplayType invalid_native_display;
56
 
    EXPECT_FALSE(container->validate(&invalid_native_display));
57
 
}
58
 
 
59
 
TEST_F(MesaNativeDisplayContainerSetup, releasing_displays_invalidates_address)
60
 
{
61
 
    using namespace ::testing;
62
 
 
63
 
    auto display = container->create(connection);
64
 
    EXPECT_TRUE(container->validate(display));
65
 
    container->release(display);
66
 
    EXPECT_FALSE(container->validate(display));
67
 
}