~alan-griffiths/mir/knee-jerk-mir_surface_state_automatic

« back to all changes in this revision

Viewing changes to tests/unit-tests/client/test_client_android_registrar.cpp

  • Committer: Kevin DuBois
  • Date: 2012-11-13 01:36:29 UTC
  • mfrom: (245 trunk)
  • mto: This revision was merged to the branch mainline in revision 246.
  • Revision ID: kevin.dubois@canonical.com-20121113013629-q4496w4mp5e33auk
merge in base branch. move the demo clients to a new directory, examples/

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <gmock/gmock.h>
28
28
 
29
29
namespace mcl=mir::client;
 
30
namespace mcla=mir::client::android;
30
31
namespace geom=mir::geometry;
31
32
 
32
33
class ICSRegistrarInterface
121
122
TEST_F(ClientAndroidRegistrarTest, registrar_registers_using_module)
122
123
{
123
124
    using namespace testing;
124
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
125
    mcla::AndroidRegistrarGralloc registrar(mock_module);
125
126
 
126
127
    EXPECT_CALL(*mock_module, registerBuffer_interface(mock_addr, _))
127
128
        .Times(1);
132
133
TEST_F(ClientAndroidRegistrarTest, registrar_registers_buffer_given)
133
134
{
134
135
    using namespace testing;
135
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
136
    mcla::AndroidRegistrarGralloc registrar(mock_module);
136
137
 
137
138
    EXPECT_CALL(*mock_module, registerBuffer_interface(_, fake_handle.get()))
138
139
        .Times(1);
143
144
TEST_F(ClientAndroidRegistrarTest, registrar_unregisters_using_module)
144
145
{
145
146
    using namespace testing;
146
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
147
    mcla::AndroidRegistrarGralloc registrar(mock_module);
147
148
 
148
149
    EXPECT_CALL(*mock_module, unregisterBuffer_interface(mock_addr, _))
149
150
        .Times(1);
154
155
TEST_F(ClientAndroidRegistrarTest, registrar_unregisters_buffer_given)
155
156
{
156
157
    using namespace testing;
157
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
158
    mcla::AndroidRegistrarGralloc registrar(mock_module);
158
159
 
159
160
    EXPECT_CALL(*mock_module, unregisterBuffer_interface(_, fake_handle.get()))
160
161
        .Times(1);
165
166
TEST_F(ClientAndroidRegistrarTest, region_is_cleaned_up_correctly)
166
167
{
167
168
    using namespace testing;
168
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
169
    mcla::AndroidRegistrarGralloc registrar(mock_module);
169
170
 
170
171
    const gralloc_module_t *gralloc_dev_alloc, *gralloc_dev_freed;
171
172
    const native_handle_t *handle_alloc, *handle_freed;
192
193
TEST_F(ClientAndroidRegistrarTest, region_lock_usage_set_correctly)
193
194
{
194
195
    using namespace testing;
195
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
196
    mcla::AndroidRegistrarGralloc registrar(mock_module);
196
197
 
197
198
    int usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
198
199
 
206
207
TEST_F(ClientAndroidRegistrarTest, region_locks_from_top_corner)
207
208
{
208
209
    using namespace testing;
209
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
210
    mcla::AndroidRegistrarGralloc registrar(mock_module);
210
211
 
211
212
    EXPECT_CALL(*mock_module, lock_interface(_,_,_,top,_,_,_,_))
212
213
        .Times(1);
217
218
TEST_F(ClientAndroidRegistrarTest, region_locks_from_left_corner)
218
219
{
219
220
    using namespace testing;
220
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
221
    mcla::AndroidRegistrarGralloc registrar(mock_module);
221
222
 
222
223
    EXPECT_CALL(*mock_module, lock_interface(_,_,_,_,left,_,_,_))
223
224
        .Times(1);
228
229
TEST_F(ClientAndroidRegistrarTest, region_locks_with_right_width)
229
230
{
230
231
    using namespace testing;
231
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
232
    mcla::AndroidRegistrarGralloc registrar(mock_module);
232
233
 
233
234
    EXPECT_CALL(*mock_module, lock_interface(_,_,_,_,_,width,_,_))
234
235
        .Times(1);
239
240
TEST_F(ClientAndroidRegistrarTest, region_locks_with_right_height)
240
241
{
241
242
    using namespace testing;
242
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
243
    mcla::AndroidRegistrarGralloc registrar(mock_module);
243
244
 
244
245
    EXPECT_CALL(*mock_module, lock_interface(_,_,_,_,_,_,height,_))
245
246
        .Times(1);
255
256
        .Times(1)
256
257
        .WillOnce(Return(-1));
257
258
    
258
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
259
    mcla::AndroidRegistrarGralloc registrar(mock_module);
259
260
    EXPECT_THROW({
260
261
        registrar.register_buffer(fake_handle.get());
261
262
    }, std::runtime_error);
269
270
        .Times(1)
270
271
        .WillOnce(Return(-1));
271
272
 
272
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
273
    mcla::AndroidRegistrarGralloc registrar(mock_module);
273
274
 
274
275
    EXPECT_THROW({
275
276
        registrar.secure_for_cpu(fake_handle, rect );
284
285
        .Times(1)
285
286
        .WillOnce(Return(-1));
286
287
 
287
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
288
    mcla::AndroidRegistrarGralloc registrar(mock_module);
288
289
 
289
290
    EXPECT_NO_THROW({
290
291
        registrar.unregister_buffer(fake_handle.get());
299
300
        .Times(1)
300
301
        .WillOnce(Return(-1));
301
302
 
302
 
    mcl::AndroidRegistrarGralloc registrar(mock_module);
 
303
    mcla::AndroidRegistrarGralloc registrar(mock_module);
303
304
 
304
305
    auto region = registrar.secure_for_cpu(fake_handle, rect );
305
306