~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
ImportĀ upstreamĀ versionĀ 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "mir_test_doubles/mock_fb_hal_device.h"
30
30
#include "mir_test_doubles/mock_egl.h"
31
31
#include "mir_test_doubles/mock_android_native_buffer.h"
32
 
#include "mir_test_doubles/stub_display_device.h"
33
32
#include <system/window.h>
34
33
#include <gtest/gtest.h>
35
34
 
94
93
            .WillByDefault(Return(hw_access_mock.mock_hwc_device));
95
94
        ON_CALL(*mock_resource_factory, create_fb_native_device())
96
95
            .WillByDefault(Return(mt::fake_shared(fb_hal_mock)));
97
 
        mock_display_report = std::make_shared<NiceMock<mtd::MockDisplayReport>>();
98
96
    }
99
97
 
100
98
    testing::NiceMock<mtd::MockEGL> mock_egl;
101
99
    testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock;
102
100
    testing::NiceMock<mtd::MockFBHalDevice> fb_hal_mock;
103
101
    std::shared_ptr<MockResourceFactory> mock_resource_factory;
104
 
    std::shared_ptr<mtd::MockDisplayReport> mock_display_report;
 
102
    testing::NiceMock<mtd::MockDisplayReport> mock_display_report;
105
103
    testing::NiceMock<MockGraphicBufferAllocator> mock_buffer_allocator;
 
104
    mga::GLContext gl_context{mga::to_mir_format(mock_egl.fake_visual_id), mock_display_report};
106
105
};
107
106
}
108
 
 
109
107
TEST_F(OutputBuilder, hwc_version_10_success)
110
108
{
111
109
    using namespace testing;
118
116
        .Times(1);
119
117
    EXPECT_CALL(*mock_resource_factory, create_hwc_fb_device(_,_))
120
118
        .Times(1);
121
 
    EXPECT_CALL(*mock_display_report, report_hwc_composition_in_use(1,0))
 
119
    EXPECT_CALL(mock_display_report, report_hwc_composition_in_use(1,0))
 
120
        .Times(1);
 
121
    EXPECT_CALL(*mock_resource_factory, create_native_window(_))
122
122
        .Times(1);
123
123
 
124
124
    mga::OutputBuilder factory(
125
 
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
126
 
    factory.create_display_device();
 
125
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mt::fake_shared(mock_display_report));
 
126
    factory.create_display_buffer(gl_context);
127
127
}
128
128
 
129
129
TEST_F(OutputBuilder, hwc_version_10_failure_uses_gpu)
139
139
        .Times(1);
140
140
    EXPECT_CALL(*mock_resource_factory, create_fb_device(_))
141
141
        .Times(1);
142
 
    EXPECT_CALL(*mock_display_report, report_gpu_composition_in_use())
 
142
    EXPECT_CALL(mock_display_report, report_gpu_composition_in_use())
 
143
        .Times(1);
 
144
    EXPECT_CALL(*mock_resource_factory, create_native_window(_))
143
145
        .Times(1);
144
146
 
145
147
    mga::OutputBuilder factory(
146
 
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
147
 
    factory.create_display_device();
 
148
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mt::fake_shared(mock_display_report));
 
149
    factory.create_display_buffer(gl_context);
148
150
}
149
151
 
150
152
TEST_F(OutputBuilder, hwc_version_11_success)
157
159
        .Times(1);
158
160
    EXPECT_CALL(*mock_resource_factory, create_hwc_device(_))
159
161
        .Times(1);
160
 
    EXPECT_CALL(*mock_display_report, report_hwc_composition_in_use(1,1))
 
162
    EXPECT_CALL(mock_display_report, report_hwc_composition_in_use(1,1))
 
163
        .Times(1);
 
164
    EXPECT_CALL(*mock_resource_factory, create_native_window(_))
161
165
        .Times(1);
162
166
 
163
167
    mga::OutputBuilder factory(
164
 
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
165
 
    factory.create_display_device();
 
168
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mt::fake_shared(mock_display_report));
 
169
    factory.create_display_buffer(gl_context);
166
170
}
167
171
 
168
172
TEST_F(OutputBuilder, hwc_version_11_hwc_failure)
178
182
        .Times(1);
179
183
    EXPECT_CALL(*mock_resource_factory, create_fb_device(_))
180
184
        .Times(1);
181
 
    EXPECT_CALL(*mock_display_report, report_gpu_composition_in_use())
 
185
    EXPECT_CALL(mock_display_report, report_gpu_composition_in_use())
 
186
        .Times(1);
 
187
    EXPECT_CALL(*mock_resource_factory, create_native_window(_))
182
188
        .Times(1);
183
189
 
184
190
    mga::OutputBuilder factory(
185
 
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
186
 
    factory.create_display_device();
 
191
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mt::fake_shared(mock_display_report));
 
192
    factory.create_display_buffer(gl_context);
187
193
}
188
194
 
189
195
TEST_F(OutputBuilder, hwc_version_11_hwc_and_fb_failure_fatal)
201
207
 
202
208
    EXPECT_THROW({
203
209
        mga::OutputBuilder factory(
204
 
            mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
 
210
            mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mt::fake_shared(mock_display_report));
205
211
    }, std::runtime_error);
206
212
}
207
213
 
215
221
        .Times(1);
216
222
    EXPECT_CALL(*mock_resource_factory, create_hwc_device(_))
217
223
        .Times(1);
218
 
    EXPECT_CALL(*mock_display_report, report_hwc_composition_in_use(1,2))
219
 
        .Times(1);
220
 
 
221
 
    mga::OutputBuilder factory(
222
 
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
223
 
    factory.create_display_device();
224
 
}
225
 
 
226
 
TEST_F(OutputBuilder, db_creation)
227
 
{
228
 
    using namespace testing;
229
 
    mga::GLContext gl_context(mga::to_mir_format(mock_egl.fake_visual_id), *mock_display_report);
230
 
 
231
 
    mtd::StubDisplayDevice stub_device;
232
 
    EXPECT_CALL(*mock_resource_factory, create_native_window(_))
233
 
        .Times(1);
234
 
 
235
 
    mga::OutputBuilder factory(
236
 
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mock_display_report);
237
 
    factory.create_display_buffer(mt::fake_shared(stub_device), gl_context);
 
224
    EXPECT_CALL(mock_display_report, report_hwc_composition_in_use(1,2))
 
225
        .Times(1);
 
226
 
 
227
    mga::OutputBuilder factory(
 
228
        mt::fake_shared(mock_buffer_allocator),mock_resource_factory, mt::fake_shared(mock_display_report));
 
229
    factory.create_display_buffer(gl_context);
238
230
}