GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/resources/map/maplayer/draw.cc Lines: 369 369 100.0 %
Date: 2017-11-29 Branches: 1241 3274 37.9 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2016-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "unittests/unittests.h"
22
23
#include "configmanager.h"
24
#include "dirs.h"
25
26
#include "unittests/render/mockgraphics.h"
27
28
#include "resources/image/image.h"
29
30
#include "resources/map/map.h"
31
#include "resources/map/maplayer.h"
32
33
#include "debug.h"
34
35
24
TEST_CASE("MapLayer draw", "")
36
{
37
20
    Dirs::initRootDir();
38
20
    Dirs::initHomeDir();
39
40
20
    ConfigManager::initConfiguration();
41
42
20
    Image *const img1 = new Image(32, 32);
43
20
    Image *const img2 = new Image(32, 32);
44
20
    Image *const img3 = new Image(32, 32);
45
20
    Map *map = nullptr;
46
20
    MapLayer *layer = nullptr;
47
20
    MockGraphics *const mock = new MockGraphics;
48
49



140
    SECTION("simple 1")
50
    {
51
10
        map = new Map("map",
52
            1, 1,
53

2
            32, 32);
54
10
        layer = new MapLayer("test",
55
            0, 0,
56
            1, 1,
57
            false,
58
            0,
59

2
            0);
60
2
        layer->setTile(0, 0, img1);
61
2
        map->addLayer(layer);
62
2
        layer->updateCache(1, 1);
63
64
2
        layer->draw(mock,
65
            0, 0,
66
            1, 1,
67
            0, 0);
68



10
        REQUIRE(mock->mDraws.size() == 1);
69



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
70



8
        REQUIRE(mock->mDraws[0].x == 0);
71



8
        REQUIRE(mock->mDraws[0].y == 0);
72



8
        REQUIRE(mock->mDraws[0].image == img1);
73
74
4
        mock->mDraws.clear();
75
2
        layer->draw(mock,
76
            0, 0,
77
            1, 1,
78
            10, 5);
79



10
        REQUIRE(mock->mDraws.size() == 1);
80



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
81



8
        REQUIRE(mock->mDraws[0].x == -10);
82



8
        REQUIRE(mock->mDraws[0].y == -5);
83



8
        REQUIRE(mock->mDraws[0].image == img1);
84
85
4
        mock->mDraws.clear();
86
2
        layer->draw(mock,
87
            0, 0,
88
            1, 1,
89
            -10, -5);
90



10
        REQUIRE(mock->mDraws.size() == 1);
91



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
92



8
        REQUIRE(mock->mDraws[0].x == 10);
93



8
        REQUIRE(mock->mDraws[0].y == 5);
94



8
        REQUIRE(mock->mDraws[0].image == img1);
95
    }
96
97



140
    SECTION("simple 2")
98
    {
99
10
        map = new Map("map",
100
            2, 1,
101

2
            32, 32);
102
10
        layer = new MapLayer("test",
103
            0, 0,
104
            2, 1,
105
            false,
106
            0,
107

2
            0);
108
2
        layer->setTile(0, 0, img1);
109
2
        map->addLayer(layer);
110
2
        layer->updateCache(2, 1);
111
112
2
        layer->draw(mock,
113
            0, 0,
114
            2, 1,
115
            0, 0);
116
117



10
        REQUIRE(mock->mDraws.size() == 1);
118



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
119



8
        REQUIRE(mock->mDraws[0].x == 0);
120



8
        REQUIRE(mock->mDraws[0].y == 0);
121



8
        REQUIRE(mock->mDraws[0].image == img1);
122
123
4
        mock->mDraws.clear();
124
2
        layer->draw(mock,
125
            0, 0,
126
            2, 1,
127
            10, 5);
128



10
        REQUIRE(mock->mDraws.size() == 1);
129



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
130



8
        REQUIRE(mock->mDraws[0].x == -10);
131



8
        REQUIRE(mock->mDraws[0].y == -5);
132



8
        REQUIRE(mock->mDraws[0].image == img1);
133
134
4
        mock->mDraws.clear();
135
2
        layer->draw(mock,
136
            0, 0,
137
            2, 1,
138
            -10, -5);
139



10
        REQUIRE(mock->mDraws.size() == 1);
140



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
141



8
        REQUIRE(mock->mDraws[0].x == 10);
142



8
        REQUIRE(mock->mDraws[0].y == 5);
143



8
        REQUIRE(mock->mDraws[0].image == img1);
144
    }
145
146



140
    SECTION("simple 3")
147
    {
148
10
        map = new Map("map",
149
            2, 1,
150

2
            32, 32);
151
10
        layer = new MapLayer("test",
152
            0, 0,
153
            2, 1,
154
            false,
155
            0,
156

2
            0);
157
2
        layer->setTile(0, 0, img1);
158
2
        layer->setTile(1, 0, img2);
159
2
        map->addLayer(layer);
160
2
        layer->updateCache(2, 1);
161
162
2
        layer->draw(mock,
163
            0, 0,
164
            2, 1,
165
            0, 0);
166



10
        REQUIRE(mock->mDraws.size() == 2);
167



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
168



8
        REQUIRE(mock->mDraws[0].x == 0);
169



8
        REQUIRE(mock->mDraws[0].y == 0);
170



8
        REQUIRE(mock->mDraws[0].image == img1);
171



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
172



8
        REQUIRE(mock->mDraws[1].x == 32);
173



8
        REQUIRE(mock->mDraws[1].y == 0);
174



8
        REQUIRE(mock->mDraws[1].image == img2);
175
176
4
        mock->mDraws.clear();
177
2
        layer->draw(mock,
178
            0, 0,
179
            2, 1,
180
            -10, -20);
181



10
        REQUIRE(mock->mDraws.size() == 2);
182



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
183



8
        REQUIRE(mock->mDraws[0].x == 10);
184



8
        REQUIRE(mock->mDraws[0].y == 20);
185



8
        REQUIRE(mock->mDraws[0].image == img1);
186



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
187



8
        REQUIRE(mock->mDraws[1].x == 42);
188



8
        REQUIRE(mock->mDraws[1].y == 20);
189



8
        REQUIRE(mock->mDraws[1].image == img2);
190
    }
191
192



140
    SECTION("simple 4")
193
    {
194
10
        map = new Map("map",
195
            2, 1,
196

2
            32, 32);
197
10
        layer = new MapLayer("test",
198
            0, 0,
199
            2, 1,
200
            false,
201
            0,
202

2
            0);
203
2
        layer->setTile(0, 0, img1);
204
2
        layer->setTile(1, 0, img1);
205
2
        map->addLayer(layer);
206
2
        layer->updateCache(2, 1);
207
208
2
        layer->draw(mock,
209
            0, 0,
210
            2, 1,
211
            0, 0);
212



10
        REQUIRE(mock->mDraws.size() == 1);
213



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
214



8
        REQUIRE(mock->mDraws[0].x == 0);
215



8
        REQUIRE(mock->mDraws[0].y == 0);
216



8
        REQUIRE(mock->mDraws[0].width == 64);
217



8
        REQUIRE(mock->mDraws[0].height == 32);
218



8
        REQUIRE(mock->mDraws[0].image == img1);
219
220
4
        mock->mDraws.clear();
221
2
        layer->draw(mock,
222
            0, 0,
223
            2, 1,
224
            -10, 20);
225



10
        REQUIRE(mock->mDraws.size() == 1);
226



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
227



8
        REQUIRE(mock->mDraws[0].x == 10);
228



8
        REQUIRE(mock->mDraws[0].y == -20);
229



8
        REQUIRE(mock->mDraws[0].width == 64);
230



8
        REQUIRE(mock->mDraws[0].height == 32);
231



8
        REQUIRE(mock->mDraws[0].image == img1);
232
    }
233
234



140
    SECTION("simple 4.2")
235
    {
236
10
        map = new Map("map",
237
            3, 1,
238

2
            32, 32);
239
10
        layer = new MapLayer("test",
240
            0, 0,
241
            3, 1,
242
            false,
243
            0,
244

2
            0);
245
2
        layer->setTile(0, 0, img1);
246
2
        layer->setTile(2, 0, img1);
247
2
        map->addLayer(layer);
248
2
        layer->updateCache(3, 1);
249
250
2
        layer->draw(mock,
251
            0, 0,
252
            3, 1,
253
            0, 0);
254



10
        REQUIRE(mock->mDraws.size() == 2);
255



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
256



8
        REQUIRE(mock->mDraws[0].x == 0);
257



8
        REQUIRE(mock->mDraws[0].y == 0);
258



8
        REQUIRE(mock->mDraws[0].image == img1);
259



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
260



8
        REQUIRE(mock->mDraws[1].x == 64);
261



8
        REQUIRE(mock->mDraws[1].y == 0);
262



8
        REQUIRE(mock->mDraws[1].image == img1);
263
264
4
        mock->mDraws.clear();
265
2
        layer->draw(mock,
266
            0, 0,
267
            3, 1,
268
            10, -20);
269



10
        REQUIRE(mock->mDraws.size() == 2);
270



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
271



8
        REQUIRE(mock->mDraws[0].x == -10);
272



8
        REQUIRE(mock->mDraws[0].y == 20);
273



8
        REQUIRE(mock->mDraws[0].image == img1);
274



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
275



8
        REQUIRE(mock->mDraws[1].x == 54);
276



8
        REQUIRE(mock->mDraws[1].y == 20);
277



8
        REQUIRE(mock->mDraws[1].image == img1);
278
    }
279
280



140
    SECTION("simple 5")
281
    {
282
10
        map = new Map("map",
283
            3, 1,
284

2
            32, 32);
285
10
        layer = new MapLayer("test",
286
            0, 0,
287
            3, 1,
288
            false,
289
            0,
290

2
            0);
291
2
        layer->setTile(0, 0, img1);
292
2
        layer->setTile(1, 0, img1);
293
2
        map->addLayer(layer);
294
2
        layer->updateCache(3, 1);
295
296
2
        layer->draw(mock,
297
            0, 0,
298
            3, 1,
299
            0, 0);
300



10
        REQUIRE(mock->mDraws.size() == 1);
301



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
302



8
        REQUIRE(mock->mDraws[0].x == 0);
303



8
        REQUIRE(mock->mDraws[0].y == 0);
304



8
        REQUIRE(mock->mDraws[0].width == 64);
305



8
        REQUIRE(mock->mDraws[0].height == 32);
306



8
        REQUIRE(mock->mDraws[0].image == img1);
307
308
4
        mock->mDraws.clear();
309
2
        layer->draw(mock,
310
            0, 0,
311
            3, 1,
312
            -10, 20);
313



10
        REQUIRE(mock->mDraws.size() == 1);
314



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
315



8
        REQUIRE(mock->mDraws[0].x == 10);
316



8
        REQUIRE(mock->mDraws[0].y == -20);
317



8
        REQUIRE(mock->mDraws[0].width == 64);
318



8
        REQUIRE(mock->mDraws[0].height == 32);
319



8
        REQUIRE(mock->mDraws[0].image == img1);
320
    }
321
322



140
    SECTION("simple 6")
323
    {
324
10
        map = new Map("map",
325
            3, 1,
326

2
            32, 32);
327
10
        layer = new MapLayer("test",
328
            0, 0,
329
            3, 1,
330
            false,
331
            0,
332

2
            0);
333
2
        layer->setTile(0, 0, img1);
334
2
        layer->setTile(1, 0, img1);
335
2
        layer->setTile(2, 0, img2);
336
2
        map->addLayer(layer);
337
2
        layer->updateCache(3, 1);
338
339
2
        layer->draw(mock,
340
            0, 0,
341
            3, 1,
342
            0, 0);
343



10
        REQUIRE(mock->mDraws.size() == 2);
344



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
345



8
        REQUIRE(mock->mDraws[0].x == 0);
346



8
        REQUIRE(mock->mDraws[0].y == 0);
347



8
        REQUIRE(mock->mDraws[0].width == 64);
348



8
        REQUIRE(mock->mDraws[0].height == 32);
349



8
        REQUIRE(mock->mDraws[0].image == img1);
350



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
351



8
        REQUIRE(mock->mDraws[1].x == 64);
352



8
        REQUIRE(mock->mDraws[1].y == 0);
353



8
        REQUIRE(mock->mDraws[1].image == img2);
354
355
4
        mock->mDraws.clear();
356
2
        layer->draw(mock,
357
            0, 0,
358
            3, 1,
359
            -10, 20);
360



10
        REQUIRE(mock->mDraws.size() == 2);
361



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
362



8
        REQUIRE(mock->mDraws[0].x == 10);
363



8
        REQUIRE(mock->mDraws[0].y == -20);
364



8
        REQUIRE(mock->mDraws[0].width == 64);
365



8
        REQUIRE(mock->mDraws[0].height == 32);
366



8
        REQUIRE(mock->mDraws[0].image == img1);
367



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
368



8
        REQUIRE(mock->mDraws[1].x == 74);
369



8
        REQUIRE(mock->mDraws[1].y == -20);
370



8
        REQUIRE(mock->mDraws[1].image == img2);
371
    }
372
373



140
    SECTION("simple 7")
374
    {
375
10
        map = new Map("map",
376
            3, 1,
377

2
            32, 32);
378
10
        layer = new MapLayer("test",
379
            0, 0,
380
            3, 1,
381
            false,
382
            0,
383

2
            0);
384
2
        layer->setTile(0, 0, img1);
385
2
        layer->setTile(1, 0, img1);
386
2
        layer->setTile(2, 0, img2);
387
2
        map->addLayer(layer);
388
2
        TileInfo *const tiles = layer->getTiles();
389
2
        tiles[0].isEnabled = false;
390
2
        layer->updateCache(3, 1);
391
392
2
        layer->draw(mock,
393
            0, 0,
394
            3, 1,
395
            0, 0);
396



10
        REQUIRE(mock->mDraws.size() == 2);
397



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
398



8
        REQUIRE(mock->mDraws[0].x == 32);
399



8
        REQUIRE(mock->mDraws[0].y == 0);
400



8
        REQUIRE(mock->mDraws[0].image == img1);
401



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
402



8
        REQUIRE(mock->mDraws[1].x == 64);
403



8
        REQUIRE(mock->mDraws[1].y == 0);
404



8
        REQUIRE(mock->mDraws[1].image == img2);
405
406
4
        mock->mDraws.clear();
407
2
        layer->draw(mock,
408
            0, 0,
409
            3, 1,
410
            -10, 20);
411



10
        REQUIRE(mock->mDraws.size() == 2);
412



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
413



8
        REQUIRE(mock->mDraws[0].x == 42);
414



8
        REQUIRE(mock->mDraws[0].y == -20);
415



8
        REQUIRE(mock->mDraws[0].image == img1);
416



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
417



8
        REQUIRE(mock->mDraws[1].x == 74);
418



8
        REQUIRE(mock->mDraws[1].y == -20);
419



8
        REQUIRE(mock->mDraws[1].image == img2);
420
    }
421
422



140
    SECTION("normal 1")
423
    {
424
2
        const int maxX = 100;
425
2
        const int maxY = 100;
426
10
        map = new Map("map",
427
            maxX, maxY,
428

2
            32, 32);
429
10
        layer = new MapLayer("test",
430
            0, 0,
431
            maxX, maxY,
432
            false,
433
            0,
434

2
            0);
435
2
        layer->setTile(1, 10, img1);
436
2
        layer->setTile(2, 10, img1);
437
2
        layer->setTile(3, 10, img1);
438
2
        layer->setTile(4, 10, img2);
439
2
        layer->setTile(5, 10, nullptr);
440
2
        layer->setTile(6, 10, img2);
441
2
        layer->setTile(7, 10, nullptr);
442
2
        layer->setTile(8, 10, nullptr);
443
2
        layer->setTile(9, 10, img2);
444
2
        layer->setTile(10, 10, img2);
445
2
        layer->setTile(11, 10, img3);
446
2
        layer->setTile(12, 10, nullptr);
447
2
        layer->setTile(13, 10, nullptr);
448
2
        layer->setTile(14, 10, nullptr);
449
2
        layer->setTile(15, 10, img1);
450
2
        layer->setTile(16, 10, img1);
451
2
        layer->setTile(17, 10, img1);
452
2
        map->addLayer(layer);
453
2
        layer->updateCache(maxX, maxY);
454
455
2
        layer->draw(mock,
456
            0, 0,
457
            maxX, maxY,
458
            0, 0);
459



10
        REQUIRE(mock->mDraws.size() == 6);
460



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
461



8
        REQUIRE(mock->mDraws[0].x == 32 * 1);
462



8
        REQUIRE(mock->mDraws[0].y == 32 * 10);
463



8
        REQUIRE(mock->mDraws[0].width == 96);
464



8
        REQUIRE(mock->mDraws[0].height == 32);
465



8
        REQUIRE(mock->mDraws[0].image == img1);
466



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
467



8
        REQUIRE(mock->mDraws[1].x == 32 * 4);
468



8
        REQUIRE(mock->mDraws[1].y == 32 * 10);
469



8
        REQUIRE(mock->mDraws[1].image == img2);
470



8
        REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
471



8
        REQUIRE(mock->mDraws[2].x == 32 * 6);
472



8
        REQUIRE(mock->mDraws[2].y == 32 * 10);
473



8
        REQUIRE(mock->mDraws[2].image == img2);
474



8
        REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
475



8
        REQUIRE(mock->mDraws[3].x == 32 * 9);
476



8
        REQUIRE(mock->mDraws[3].y == 32 * 10);
477



8
        REQUIRE(mock->mDraws[3].width == 64);
478



8
        REQUIRE(mock->mDraws[3].height == 32);
479



8
        REQUIRE(mock->mDraws[3].image == img2);
480



8
        REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
481



8
        REQUIRE(mock->mDraws[4].x == 32 * 11);
482



8
        REQUIRE(mock->mDraws[4].y == 32 * 10);
483



8
        REQUIRE(mock->mDraws[4].image == img3);
484



8
        REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
485



8
        REQUIRE(mock->mDraws[5].x == 32 * 15);
486



8
        REQUIRE(mock->mDraws[5].y == 32 * 10);
487



8
        REQUIRE(mock->mDraws[5].width == 96);
488



8
        REQUIRE(mock->mDraws[5].height == 32);
489



8
        REQUIRE(mock->mDraws[5].image == img1);
490
491
4
        mock->mDraws.clear();
492
2
        layer->draw(mock,
493
            0, 0,
494
            maxX, maxY,
495
            -10, 20);
496



10
        REQUIRE(mock->mDraws.size() == 6);
497



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
498



8
        REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
499



8
        REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
500



8
        REQUIRE(mock->mDraws[0].width == 96);
501



8
        REQUIRE(mock->mDraws[0].height == 32);
502



8
        REQUIRE(mock->mDraws[0].image == img1);
503



8
        REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
504



8
        REQUIRE(mock->mDraws[1].x == 32 * 4 + 10);
505



8
        REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
506



8
        REQUIRE(mock->mDraws[1].image == img2);
507



8
        REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
508



8
        REQUIRE(mock->mDraws[2].x == 32 * 6 + 10);
509



8
        REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
510



8
        REQUIRE(mock->mDraws[2].image == img2);
511



8
        REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
512



8
        REQUIRE(mock->mDraws[3].x == 32 * 9 + 10);
513



8
        REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
514



8
        REQUIRE(mock->mDraws[3].width == 64);
515



8
        REQUIRE(mock->mDraws[3].height == 32);
516



8
        REQUIRE(mock->mDraws[3].image == img2);
517



8
        REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
518



8
        REQUIRE(mock->mDraws[4].x == 32 * 11 + 10);
519



8
        REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
520



8
        REQUIRE(mock->mDraws[4].image == img3);
521



8
        REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
522



8
        REQUIRE(mock->mDraws[5].x == 32 * 15 + 10);
523



8
        REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
524



8
        REQUIRE(mock->mDraws[5].width == 96);
525



8
        REQUIRE(mock->mDraws[5].height == 32);
526



8
        REQUIRE(mock->mDraws[5].image == img1);
527
    }
528
529



140
    SECTION("normal2")
530
    {
531
2
        const int maxX = 100;
532
2
        const int maxY = 100;
533
10
        map = new Map("map",
534
            maxX, maxY,
535

2
            32, 32);
536
10
        layer = new MapLayer("test",
537
            0, 0,
538
            maxX, maxY,
539
            false,
540
            0,
541

2
            0);
542
2
        TileInfo *const tiles = layer->getTiles();
543
2
        map->addLayer(layer);
544
402
        for (int x = 0; x < maxX; x ++)
545
        {
546
40200
            for (int y = 0; y < maxY; y ++)
547
            {
548
20000
                layer->setTile(x, y, img1);
549
20000
                tiles[y * maxX + x].isEnabled = false;
550
            }
551
        }
552
2
        tiles[10 * maxX + 41].isEnabled = true;
553
2
        layer->updateCache(maxX, maxY);
554
555
2
        layer->draw(mock,
556
            0, 0,
557
            maxX, maxY,
558
            0, 0);
559



10
        REQUIRE(mock->mDraws.size() == 1);
560



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
561



8
        REQUIRE(mock->mDraws[0].x == 32 * 41);
562



8
        REQUIRE(mock->mDraws[0].y == 32 * 10);
563
564
4
        mock->mDraws.clear();
565
2
        layer->draw(mock,
566
            0, 0,
567
            maxX, maxY,
568
            -10, 20);
569



10
        REQUIRE(mock->mDraws.size() == 1);
570



8
        REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
571



8
        REQUIRE(mock->mDraws[0].x == 32 * 41 + 10);
572



8
        REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
573
    }
574
575
20
    delete map;
576
20
    delete img1;
577
20
    delete img2;
578
20
    delete img3;
579
20
    delete mock;
580

26
}