GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/resources/map/maplayer/draw.cc Lines: 369 369 100.0 %
Date: 2018-11-12 Branches: 1208 3208 37.7 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2016-2018  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
12
TEST_CASE("MapLayer draw", "")
36
{
37
10
    Dirs::initRootDir();
38
10
    Dirs::initHomeDir();
39
40
10
    ConfigManager::initConfiguration();
41
42
10
    Image *const img1 = new Image(32, 32);
43
10
    Image *const img2 = new Image(32, 32);
44
10
    Image *const img3 = new Image(32, 32);
45
10
    Map *map = nullptr;
46
10
    MapLayer *layer = nullptr;
47
10
    MockGraphics *const mock = new MockGraphics;
48
49



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

3
            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
1
        map->addLayer(layer);
453
1
        layer->updateCache(maxX, maxY);
454
455
        layer->draw(mock,
456
            0, 0,
457
            maxX, maxY,
458
1
            0, 0);
459



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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



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

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

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



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



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



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



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



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



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



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



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

13
}