2 * FreeRDP: A Remote Desktop Protocol Client
3 * Drawing Orders Unit Tests
5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <freerdp/freerdp.h>
21 #include <freerdp/utils/hexdump.h>
22 #include <freerdp/utils/stream.h>
24 #include "test_orders.h"
25 #include "libfreerdp-core/orders.h"
26 #include "libfreerdp-core/update.h"
28 ORDER_INFO* orderInfo;
30 int init_orders_suite(void)
32 orderInfo = (ORDER_INFO*) malloc(sizeof(ORDER_INFO));
36 int clean_orders_suite(void)
42 int add_orders_suite(void)
44 add_test_suite(orders);
46 add_test_function(read_dstblt_order);
47 add_test_function(read_patblt_order);
48 add_test_function(read_scrblt_order);
49 add_test_function(read_opaque_rect_order);
50 add_test_function(read_draw_nine_grid_order);
51 add_test_function(read_multi_opaque_rect_order);
52 add_test_function(read_line_to_order);
53 add_test_function(read_polyline_order);
54 add_test_function(read_glyph_index_order);
55 add_test_function(read_fast_index_order);
56 add_test_function(read_fast_glyph_order);
57 add_test_function(read_polygon_cb_order);
59 add_test_function(read_cache_bitmap_order);
60 add_test_function(read_cache_bitmap_v2_order);
61 add_test_function(read_cache_bitmap_v3_order);
62 add_test_function(read_cache_brush_order);
64 add_test_function(read_create_offscreen_bitmap_order);
65 add_test_function(read_switch_surface_order);
67 add_test_function(update_recv_orders);
72 uint8 dstblt_order[] = "\x48\x00\x37\x01";
74 void test_read_dstblt_order(void)
80 s->p = s->data = dstblt_order;
82 memset(orderInfo, 0, sizeof(ORDER_INFO));
83 orderInfo->fieldFlags = 0x0C;
84 memset(&dstblt, 0, sizeof(DSTBLT_ORDER));
86 update_read_dstblt_order(s, orderInfo, &dstblt);
88 CU_ASSERT(dstblt.nLeftRect == 0);
89 CU_ASSERT(dstblt.nTopRect == 0);
90 CU_ASSERT(dstblt.nWidth == 72);
91 CU_ASSERT(dstblt.nHeight == 311);
92 CU_ASSERT(dstblt.bRop == 0);
94 CU_ASSERT(stream_get_length(s) == (sizeof(dstblt_order) - 1));
97 uint8 patblt_order[] = "\x1a\x00\xc3\x01\x0d\x00\x0d\x00\xf0\xff\xff\x00\x5b\xef\x00\x81";
99 void test_read_patblt_order(void)
105 s->p = s->data = patblt_order;
107 memset(orderInfo, 0, sizeof(ORDER_INFO));
108 orderInfo->fieldFlags = 0x027F;
109 memset(&patblt, 0, sizeof(PATBLT_ORDER));
111 update_read_patblt_order(s, orderInfo, &patblt);
113 CU_ASSERT(patblt.nLeftRect == 26);
114 CU_ASSERT(patblt.nTopRect == 451);
115 CU_ASSERT(patblt.nWidth == 13);
116 CU_ASSERT(patblt.nHeight == 13);
117 CU_ASSERT(patblt.bRop == 240);
118 CU_ASSERT(patblt.backColor == 0x00FFFF);
119 CU_ASSERT(patblt.foreColor == 0x00EF5B);
120 CU_ASSERT(patblt.brush.x == 0);
121 CU_ASSERT(patblt.brush.y == 0);
122 CU_ASSERT(patblt.brush.style == (BMF_1BPP | CACHED_BRUSH));
124 CU_ASSERT(stream_get_length(s) == (sizeof(patblt_order) - 1));
127 uint8 scrblt_order[] = "\x07\x00\xa1\x01\xf1\x00\xcc\x2f\x01\x8e\x00";
129 void test_read_scrblt_order(void)
135 s->p = s->data = scrblt_order;
137 memset(orderInfo, 0, sizeof(ORDER_INFO));
138 orderInfo->fieldFlags = 0x7D;
139 memset(&scrblt, 0, sizeof(SCRBLT_ORDER));
141 update_read_scrblt_order(s, orderInfo, &scrblt);
143 CU_ASSERT(scrblt.nLeftRect == 7);
144 CU_ASSERT(scrblt.nTopRect == 0);
145 CU_ASSERT(scrblt.nWidth == 417);
146 CU_ASSERT(scrblt.nHeight == 241);
147 CU_ASSERT(scrblt.bRop == 204);
148 CU_ASSERT(scrblt.nXSrc == 303);
149 CU_ASSERT(scrblt.nYSrc == 142);
151 CU_ASSERT(stream_get_length(s) == (sizeof(scrblt_order) - 1));
154 uint8 opaque_rect_order[] = "\x00\x04\x00\x03\x73\x02\x06";
156 void test_read_opaque_rect_order(void)
159 OPAQUE_RECT_ORDER opaque_rect;
162 s->p = s->data = opaque_rect_order;
164 memset(orderInfo, 0, sizeof(ORDER_INFO));
165 orderInfo->fieldFlags = 0x7C;
166 memset(&opaque_rect, 0, sizeof(OPAQUE_RECT_ORDER));
168 update_read_opaque_rect_order(s, orderInfo, &opaque_rect);
170 CU_ASSERT(opaque_rect.nLeftRect == 0);
171 CU_ASSERT(opaque_rect.nTopRect == 0);
172 CU_ASSERT(opaque_rect.nWidth == 1024);
173 CU_ASSERT(opaque_rect.nHeight == 768);
174 CU_ASSERT(opaque_rect.color == 0x00060273);
176 CU_ASSERT(stream_get_length(s) == (sizeof(opaque_rect_order) - 1));
179 uint8 draw_nine_grid_order[] = "\xfb\xf9\x0d\x00";
181 void test_read_draw_nine_grid_order(void)
184 DRAW_NINE_GRID_ORDER draw_nine_grid;
187 s->p = s->data = draw_nine_grid_order;
189 memset(orderInfo, 0, sizeof(ORDER_INFO));
190 orderInfo->fieldFlags = 0x1C;
191 orderInfo->deltaCoordinates = true;
193 memset(&draw_nine_grid, 0, sizeof(DRAW_NINE_GRID_ORDER));
194 draw_nine_grid.srcRight = 38;
195 draw_nine_grid.srcBottom = 40;
197 update_read_draw_nine_grid_order(s, orderInfo, &draw_nine_grid);
199 CU_ASSERT(draw_nine_grid.srcLeft == 0);
200 CU_ASSERT(draw_nine_grid.srcTop == 0);
201 CU_ASSERT(draw_nine_grid.srcRight == 33);
202 CU_ASSERT(draw_nine_grid.srcBottom == 33);
203 CU_ASSERT(draw_nine_grid.bitmapId == 13);
205 CU_ASSERT(stream_get_length(s) == (sizeof(draw_nine_grid_order) - 1));
209 uint8 multi_opaque_rect_order[] =
210 "\x87\x01\x1c\x01\xf1\x00\x12\x00\x5c\xef\x04\x16\x00\x08\x40\x81"
211 "\x87\x81\x1c\x80\xf1\x01\x01\x01\x10\x80\xf0\x01\x10\xff\x10\x10"
214 void test_read_multi_opaque_rect_order(void)
217 MULTI_OPAQUE_RECT_ORDER multi_opaque_rect;
220 s->p = s->data = multi_opaque_rect_order;
222 memset(orderInfo, 0, sizeof(ORDER_INFO));
223 orderInfo->fieldFlags = 0x01BF;
224 memset(&multi_opaque_rect, 0, sizeof(MULTI_OPAQUE_RECT_ORDER));
226 update_read_multi_opaque_rect_order(s, orderInfo, &multi_opaque_rect);
228 CU_ASSERT(multi_opaque_rect.nLeftRect == 391);
229 CU_ASSERT(multi_opaque_rect.nTopRect == 284);
230 CU_ASSERT(multi_opaque_rect.nWidth == 241);
231 CU_ASSERT(multi_opaque_rect.nHeight == 18);
232 CU_ASSERT(multi_opaque_rect.color == 0x0000EF5C);
233 CU_ASSERT(multi_opaque_rect.cbData == 22);
234 CU_ASSERT(multi_opaque_rect.numRectangles == 4);
236 CU_ASSERT(multi_opaque_rect.rectangles[1].left == 391);
237 CU_ASSERT(multi_opaque_rect.rectangles[1].top == 284);
238 CU_ASSERT(multi_opaque_rect.rectangles[1].width == 241);
239 CU_ASSERT(multi_opaque_rect.rectangles[1].height == 1);
241 CU_ASSERT(multi_opaque_rect.rectangles[2].left == 391);
242 CU_ASSERT(multi_opaque_rect.rectangles[2].top == 285);
243 CU_ASSERT(multi_opaque_rect.rectangles[2].width == 1);
244 CU_ASSERT(multi_opaque_rect.rectangles[2].height == 16);
246 CU_ASSERT(multi_opaque_rect.rectangles[3].left == 631);
247 CU_ASSERT(multi_opaque_rect.rectangles[3].top == 285);
248 CU_ASSERT(multi_opaque_rect.rectangles[3].width == 1);
249 CU_ASSERT(multi_opaque_rect.rectangles[3].height == 16);
251 CU_ASSERT(multi_opaque_rect.rectangles[4].left == 391);
252 CU_ASSERT(multi_opaque_rect.rectangles[4].top == 301);
253 CU_ASSERT(multi_opaque_rect.rectangles[4].width == 241);
254 CU_ASSERT(multi_opaque_rect.rectangles[4].height == 1);
256 CU_ASSERT(stream_get_length(s) == (sizeof(multi_opaque_rect_order) - 1));
259 uint8 line_to_order[] = "\x03\xb1\x0e\xa6\x5b\xef\x00";
261 void test_read_line_to_order(void)
264 LINE_TO_ORDER line_to;
267 s->p = s->data = line_to_order;
269 memset(orderInfo, 0, sizeof(ORDER_INFO));
270 orderInfo->fieldFlags = 0x021E;
271 orderInfo->deltaCoordinates = true;
273 memset(&line_to, 0, sizeof(LINE_TO_ORDER));
274 line_to.nXStart = 826;
275 line_to.nYStart = 350;
279 update_read_line_to_order(s, orderInfo, &line_to);
281 CU_ASSERT(line_to.nXStart == 829);
282 CU_ASSERT(line_to.nYStart == 271);
283 CU_ASSERT(line_to.nXEnd == 843);
284 CU_ASSERT(line_to.nYEnd == 257);
285 CU_ASSERT(line_to.backColor == 0);
286 CU_ASSERT(line_to.bRop2 == 0);
287 CU_ASSERT(line_to.penStyle == 0);
288 CU_ASSERT(line_to.penWidth == 0);
289 CU_ASSERT(line_to.penColor == 0x00EF5B);
291 CU_ASSERT(stream_get_length(s) == (sizeof(line_to_order) - 1));
294 uint8 polyline_order[] =
295 "\xf8\x01\xb8\x02\x00\xc0\x00\x20\x6c\x00\x00\x00\x00\x00\x04\x00"
296 "\x00\xff\x7e\x76\xff\x41\x6c\xff\x24\x62\xff\x2b\x59\xff\x55\x51"
297 "\xff\x9c\x49\x73\x43\x80\x4d\xff\xbe\x80\x99\xff\xba\x80\xcd\xff"
298 "\xb7\x80\xde\xff\xb6\x80\xca\xff\xb6\x80\x96\xff\xb7\x80\x48\xff"
299 "\xba\x6f\xff\xbe\xff\x97\x43\xff\x52\x4a\xff\x2b\x51\xff\x24\x59"
300 "\xff\x44\x63\xff\x81\x6c\x56\x76\x2f\x80\x82\x0a\x80\xbf\x14\x80"
301 "\xdd\x1e\x80\xd4\x27\x80\xab\x2f\x80\x64\x37\x0d\x3d\xff\xb3\x80"
302 "\x42\xff\x67\x80\x46";
304 void test_read_polyline_order(void)
307 POLYLINE_ORDER polyline;
310 s->p = s->data = polyline_order;
312 memset(orderInfo, 0, sizeof(ORDER_INFO));
313 orderInfo->fieldFlags = 0x73;
315 memset(&polyline, 0, sizeof(POLYLINE_ORDER));
317 update_read_polyline_order(s, orderInfo, &polyline);
319 CU_ASSERT(polyline.xStart == 504);
320 CU_ASSERT(polyline.yStart == 696);
321 CU_ASSERT(polyline.bRop2 == 0);
322 CU_ASSERT(polyline.penColor == 0x0000C000);
323 CU_ASSERT(polyline.numPoints == 32);
324 CU_ASSERT(polyline.cbData == 108);
326 CU_ASSERT(polyline.points[0].x == -130);
327 CU_ASSERT(polyline.points[1].x == -191);
328 CU_ASSERT(polyline.points[2].x == -220);
329 CU_ASSERT(polyline.points[3].x == -213);
330 CU_ASSERT(polyline.points[4].x == -171);
331 CU_ASSERT(polyline.points[5].x == -100);
332 CU_ASSERT(polyline.points[6].x == -13);
333 CU_ASSERT(polyline.points[7].x == 77);
334 CU_ASSERT(polyline.points[8].x == 153);
335 CU_ASSERT(polyline.points[9].x == 205);
336 CU_ASSERT(polyline.points[10].x == 222);
337 CU_ASSERT(polyline.points[11].x == 202);
338 CU_ASSERT(polyline.points[12].x == 150);
339 CU_ASSERT(polyline.points[13].x == 72);
340 CU_ASSERT(polyline.points[14].x == -17);
341 CU_ASSERT(polyline.points[15].x == -105);
342 CU_ASSERT(polyline.points[16].x == -174);
343 CU_ASSERT(polyline.points[17].x == -213);
344 CU_ASSERT(polyline.points[18].x == -220);
345 CU_ASSERT(polyline.points[19].x == -188);
346 CU_ASSERT(polyline.points[20].x == -127);
347 CU_ASSERT(polyline.points[21].x == -42);
348 CU_ASSERT(polyline.points[22].x == 47);
349 CU_ASSERT(polyline.points[23].x == 130);
350 CU_ASSERT(polyline.points[24].x == 191);
351 CU_ASSERT(polyline.points[25].x == 221);
352 CU_ASSERT(polyline.points[26].x == 212);
353 CU_ASSERT(polyline.points[27].x == 171);
354 CU_ASSERT(polyline.points[28].x == 100);
355 CU_ASSERT(polyline.points[29].x == 13);
356 CU_ASSERT(polyline.points[30].x == -77);
357 CU_ASSERT(polyline.points[31].x == -153);
358 CU_ASSERT(polyline.points[32].x == 0);
360 CU_ASSERT(stream_get_length(s) == (sizeof(polyline_order) - 1));
363 uint8 glyph_index_order_1[] =
364 "\x6a\x02\x27\x38\x00\x39\x07\x3a\x06\x3b\x07\x3c\x06\x3d\x06\x18"
365 "\x04\x1f\x06\x17\x02\x14\x04\x1b\x06\x19\x06\x45\x05\x18\x06\x1f"
366 "\x06\x1f\x02\x14\x02\x46\x06\xff\x15\x24";
368 uint8 glyph_index_order_2[] =
369 "\x00\xff\xff\xff\x0c\x02\x6e\x01\x4d\x02\x7b\x01\x09\x02\x6e\x01"
370 "\xf6\x02\x7b\x01\x0c\x02\x79\x01\x03\xfe\x04\x00";
372 void test_read_glyph_index_order(void)
375 GLYPH_INDEX_ORDER glyph_index;
378 s->p = s->data = glyph_index_order_1;
380 memset(orderInfo, 0, sizeof(ORDER_INFO));
381 orderInfo->fieldFlags = 0x200100;
382 orderInfo->deltaCoordinates = true;
384 memset(&glyph_index, 0, sizeof(GLYPH_INDEX_ORDER));
386 update_read_glyph_index_order(s, orderInfo, &glyph_index);
388 CU_ASSERT(glyph_index.bkRight == 618);
390 CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_1) - 1));
392 s->p = s->data = glyph_index_order_2;
394 memset(orderInfo, 0, sizeof(ORDER_INFO));
395 orderInfo->fieldFlags = 0x383FE8;
396 orderInfo->deltaCoordinates = true;
398 memset(&glyph_index, 0, sizeof(GLYPH_INDEX_ORDER));
400 update_read_glyph_index_order(s, orderInfo, &glyph_index);
402 CU_ASSERT(glyph_index.fOpRedundant == 0);
403 CU_ASSERT(glyph_index.foreColor == 0x00FFFFFF);
404 CU_ASSERT(glyph_index.bkLeft == 524);
405 CU_ASSERT(glyph_index.bkTop == 366);
406 CU_ASSERT(glyph_index.bkRight == 589);
407 CU_ASSERT(glyph_index.bkBottom == 379);
408 CU_ASSERT(glyph_index.opLeft == 521);
409 CU_ASSERT(glyph_index.opTop == 366);
410 CU_ASSERT(glyph_index.opRight == 758);
411 CU_ASSERT(glyph_index.opBottom == 379);
412 CU_ASSERT(glyph_index.x == 524);
413 CU_ASSERT(glyph_index.y == 377);
415 CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_2) - 1));
418 uint8 fast_index_order[] =
419 "\x07\x00\x03\xff\xff\x00\x74\x3b\x00\x0e\x00\x71\x00\x42\x00\x7e"
420 "\x00\x00\x80\x7c\x00\x15\x00\x00\x01\x06\x02\x04\x03\x08\x05\x09"
421 "\x06\x06\x06\x06\x07\x06\x08\x02\xff\x00\x12";
423 void test_read_fast_index_order(void)
426 FAST_INDEX_ORDER fast_index;
429 s->p = s->data = fast_index_order;
431 memset(orderInfo, 0, sizeof(ORDER_INFO));
432 orderInfo->fieldFlags = 0x70FF;
434 memset(&fast_index, 0, sizeof(FAST_INDEX_ORDER));
435 update_read_fast_index_order(s, orderInfo, &fast_index);
437 CU_ASSERT(fast_index.cacheId == 7);
438 CU_ASSERT(fast_index.flAccel == 3);
439 CU_ASSERT(fast_index.ulCharInc == 0);
440 CU_ASSERT(fast_index.backColor == 0x0000FFFF);
441 CU_ASSERT(fast_index.foreColor == 0x00003B74);
442 CU_ASSERT(fast_index.bkLeft == 14);
443 CU_ASSERT(fast_index.bkTop == 113);
444 CU_ASSERT(fast_index.bkRight == 66);
445 CU_ASSERT(fast_index.bkBottom == 126);
446 CU_ASSERT(fast_index.opLeft == 0);
447 CU_ASSERT(fast_index.opTop == 0);
448 CU_ASSERT(fast_index.opRight == 0);
449 CU_ASSERT(fast_index.opBottom == 0);
450 CU_ASSERT(fast_index.x == -32768);
451 CU_ASSERT(fast_index.y == 124);
453 CU_ASSERT(stream_get_length(s) == (sizeof(fast_index_order) - 1));
456 uint8 fast_glyph_order[] =
457 "\x06\x00\x03\xff\xff\x00\x8b\x00\xb1\x00\x93\x00\xbe\x00\x0d\x00"
458 "\xfe\x7f\x00\x80\x00\x80\xbb\x00\x13\x00\x01\x4a\x06\x0a\x80\x80"
459 "\x80\xb8\xc4\x84\x84\x84\x84\x84\x00\x00\x68\x00";
461 void test_read_fast_glyph_order(void)
464 FAST_GLYPH_ORDER fast_glyph;
467 s->p = s->data = fast_glyph_order;
469 memset(orderInfo, 0, sizeof(ORDER_INFO));
470 orderInfo->fieldFlags = 0x7EFB;
472 memset(&fast_glyph, 0, sizeof(FAST_GLYPH_ORDER));
474 update_read_fast_glyph_order(s, orderInfo, &fast_glyph);
476 CU_ASSERT(fast_glyph.backColor == 0);
477 CU_ASSERT(fast_glyph.foreColor == 0x0000FFFF);
478 CU_ASSERT(fast_glyph.bkLeft == 139);
479 CU_ASSERT(fast_glyph.bkTop == 177);
480 CU_ASSERT(fast_glyph.bkRight == 147);
481 CU_ASSERT(fast_glyph.bkBottom == 190);
482 CU_ASSERT(fast_glyph.opLeft == 0);
483 CU_ASSERT(fast_glyph.opTop == 13);
484 CU_ASSERT(fast_glyph.opRight == 32766);
485 CU_ASSERT(fast_glyph.opBottom == -32768);
486 CU_ASSERT(fast_glyph.x == -32768);
487 CU_ASSERT(fast_glyph.y == 187);
489 CU_ASSERT(stream_get_length(s) == (sizeof(fast_glyph_order) - 1));
492 uint8 polygon_cb_order[] =
493 "\xea\x00\x46\x01\x0d\x01\x08\x00\x00\x04\x03\x81\x08\x03\x05\x88"
496 void test_read_polygon_cb_order(void)
499 POLYGON_CB_ORDER polygon_cb;
502 s->p = s->data = polygon_cb_order;
504 memset(orderInfo, 0, sizeof(ORDER_INFO));
505 orderInfo->fieldFlags = 0x1BEF;
507 memset(&polygon_cb, 0, sizeof(POLYGON_CB_ORDER));
509 update_read_polygon_cb_order(s, orderInfo, &polygon_cb);
511 CU_ASSERT(polygon_cb.xStart == 234);
512 CU_ASSERT(polygon_cb.yStart == 326);
513 CU_ASSERT(polygon_cb.bRop2 == 0x0D);
514 CU_ASSERT(polygon_cb.fillMode == 1);
515 CU_ASSERT(polygon_cb.backColor == 0);
516 CU_ASSERT(polygon_cb.foreColor == 0x00000008);
517 CU_ASSERT(polygon_cb.brush.x == 4);
518 CU_ASSERT(polygon_cb.brush.y == 3);
519 CU_ASSERT(polygon_cb.brush.style == 0x81);
520 CU_ASSERT(polygon_cb.nDeltaEntries == 3);
521 CU_ASSERT(polygon_cb.cbData == 5);
523 CU_ASSERT(stream_get_length(s) == (sizeof(polygon_cb_order) - 1));
526 uint8 cache_bitmap_order[] = "\x00\x00\x10\x01\x08\x01\x00\x00\x00\x10";
528 void test_read_cache_bitmap_order(void)
532 CACHE_BITMAP_ORDER cache_bitmap;
536 s->p = s->data = cache_bitmap_order;
538 memset(&cache_bitmap, 0, sizeof(CACHE_BITMAP_ORDER));
540 update_read_cache_bitmap_order(s, &cache_bitmap, true, extraFlags);
542 CU_ASSERT(cache_bitmap.cacheId == 0);
543 CU_ASSERT(cache_bitmap.bitmapWidth == 16);
544 CU_ASSERT(cache_bitmap.bitmapHeight == 1);
545 CU_ASSERT(cache_bitmap.bitmapBpp == 8);
546 CU_ASSERT(cache_bitmap.bitmapLength == 1);
547 CU_ASSERT(cache_bitmap.cacheIndex == 0);
549 CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_order) - 1));
552 uint8 cache_bitmap_v2_order[] =
553 "\x20\x40\xdc\xff\xff\x85\xff\xff\x99\xd6\x99\xd6\x99\xd6\x99\xd6"
554 "\x06\x8b\x99\xd6\x99\xd6\x99\xd6\x10\x84\x08\x42\x08\x42\x10\x84"
555 "\x99\xd6\x99\xd6\x99\xd6\x99\xd6\x06\x84\x99\xd6\x99\xd6\x99\xd6"
556 "\xff\xff\x16\x69\x99\xd6\x06\x69\x99\xd6\x04\xcc\x89\x52\x03\x6e"
557 "\xff\xff\x02\x6e\x08\x42\x01\x70\x08\x42\x71\xff\xff\xce\x18\xc6"
558 "\x01\x81\x08\x42\xce\x66\x29\x02\xcd\x89\x52\x03\x88\x10\x84\x99"
559 "\xd6\x99\xd6\x99\xd6\x00\x00\x00\x00\x00\x00\x00\x00\xd8\x99\xd6"
560 "\x03\xf8\x01\x00\x00\x00\x00\xf0\x66\x99\xd6\x05\x6a\x99\xd6\x00"
561 "\xc4\xcc\x89\x52\x03\x6e\xff\xff\x02\x6e\x08\x42\x01\x70\x08\x42"
562 "\x71\xff\xff\xce\x18\xc6\x01\x81\x08\x42\xce\x66\x29\x02\xcd\x89"
563 "\x52\x03\x00\x04\xd6\x99\xd6\xc3\x80\x61\x00\xa5\x80\x40\xec\x52"
564 "\x00\x5a\x00\x2d\x00\x24\x00\x12\x00\x24\x00\x12\x00\x5a\x00\x2d"
565 "\x00\xa5\x80\x52\x00\xc3\x80\x61\x00\x00\x00\x00\x00\xcc\x89\x52"
566 "\x03\x6e\xff\xff\x02\xcb\x18\xc6\x84\x08\x42\x08\x42\x08\x42\xff"
569 void test_read_cache_bitmap_v2_order(void)
573 CACHE_BITMAP_V2_ORDER cache_bitmap_v2;
577 s->p = s->data = cache_bitmap_v2_order;
579 memset(&cache_bitmap_v2, 0, sizeof(CACHE_BITMAP_V2_ORDER));
581 update_read_cache_bitmap_v2_order(s, &cache_bitmap_v2, true, extraFlags);
583 CU_ASSERT(cache_bitmap_v2.cacheId == 1);
584 CU_ASSERT(cache_bitmap_v2.bitmapBpp == 16);
585 CU_ASSERT(cache_bitmap_v2.flags == 0x19);
586 CU_ASSERT(cache_bitmap_v2.bitmapWidth == 32);
587 CU_ASSERT(cache_bitmap_v2.bitmapHeight == 32);
588 CU_ASSERT(cache_bitmap_v2.bitmapLength == 220);
589 CU_ASSERT(cache_bitmap_v2.cacheIndex == 32767);
591 CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_v2_order) - 1));
594 uint8 cache_bitmap_v3_order[] =
595 "\xff\x7f\x35\x50\xec\xbc\x74\x52\x65\xb7\x20\x00\x00\x00\x05\x00"
596 "\x02\x00\x28\x00\x00\x00\x5b\x4f\x45\xff\x5b\x4f\x45\xff\x5b\x4f"
597 "\x45\xff\x5b\x4f\x45\xff\x5b\x4f\x45\xff\x5b\x50\x45\xff\x5b\x50"
598 "\x45\xff\x5b\x50\x45\xff\x5b\x50\x45\xff\x5b\x50\x45\xff";
600 void test_read_cache_bitmap_v3_order(void)
604 CACHE_BITMAP_V3_ORDER cache_bitmap_v3;
608 s->p = s->data = cache_bitmap_v3_order;
610 memset(&cache_bitmap_v3, 0, sizeof(CACHE_BITMAP_V3_ORDER));
612 update_read_cache_bitmap_v3_order(s, &cache_bitmap_v3, true, extraFlags);
614 CU_ASSERT(cache_bitmap_v3.cacheIndex == 32767);
615 CU_ASSERT(cache_bitmap_v3.key1 == 0xBCEC5035);
616 CU_ASSERT(cache_bitmap_v3.key2 == 0xB7655274);
617 CU_ASSERT(cache_bitmap_v3.bpp == 32);
619 CU_ASSERT(cache_bitmap_v3.bitmapData.bpp == 32);
620 CU_ASSERT(cache_bitmap_v3.bitmapData.codecID == 0);
621 CU_ASSERT(cache_bitmap_v3.bitmapData.width == 5);
622 CU_ASSERT(cache_bitmap_v3.bitmapData.height == 2);
623 CU_ASSERT(cache_bitmap_v3.bitmapData.length == 40);
625 CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_v3_order) - 1));
628 uint8 cache_brush_order[] = "\x00\x01\x08\x08\x81\x08\xaa\x55\xaa\x55\xaa\x55\xaa\x55";
630 void test_read_cache_brush_order(void)
633 CACHE_BRUSH_ORDER cache_brush;
636 s->p = s->data = cache_brush_order;
638 memset(&cache_brush, 0, sizeof(CACHE_BRUSH_ORDER));
640 update_read_cache_brush_order(s, &cache_brush, 0);
642 CU_ASSERT(cache_brush.index == 0);
643 CU_ASSERT(cache_brush.bpp == 1);
644 CU_ASSERT(cache_brush.cx == 8);
645 CU_ASSERT(cache_brush.cy == 8);
646 CU_ASSERT(cache_brush.style == 0x81);
647 CU_ASSERT(cache_brush.length == 8);
649 CU_ASSERT(stream_get_length(s) == (sizeof(cache_brush_order) - 1));
652 uint8 create_offscreen_bitmap_order[] = "\x00\x80\x60\x01\x10\x00\x01\x00\x02\x00";
654 void test_read_create_offscreen_bitmap_order(void)
657 OFFSCREEN_DELETE_LIST* deleteList;
658 CREATE_OFFSCREEN_BITMAP_ORDER create_offscreen_bitmap;
661 s->p = s->data = create_offscreen_bitmap_order;
663 memset(&create_offscreen_bitmap, 0, sizeof(CREATE_OFFSCREEN_BITMAP_ORDER));
665 deleteList = &(create_offscreen_bitmap.deleteList);
666 deleteList->cIndices = 0;
667 deleteList->sIndices = 16;
668 deleteList->indices = malloc(sizeof(uint16) * deleteList->sIndices);
670 update_read_create_offscreen_bitmap_order(s, &create_offscreen_bitmap);
672 CU_ASSERT(create_offscreen_bitmap.id == 0);
673 CU_ASSERT(create_offscreen_bitmap.cx == 352);
674 CU_ASSERT(create_offscreen_bitmap.cy == 16);
675 CU_ASSERT(create_offscreen_bitmap.deleteList.cIndices == 1);
677 CU_ASSERT(stream_get_length(s) == (sizeof(create_offscreen_bitmap_order) - 1));
680 uint8 switch_surface_order[] = "\xff\xff";
682 void test_read_switch_surface_order(void)
685 SWITCH_SURFACE_ORDER switch_surface;
688 s->p = s->data = switch_surface_order;
690 memset(&switch_surface, 0, sizeof(SWITCH_SURFACE_ORDER));
692 update_read_switch_surface_order(s, &switch_surface);
694 CU_ASSERT(switch_surface.bitmapId == 0xFFFF);
696 CU_ASSERT(stream_get_length(s) == (sizeof(switch_surface_order) - 1));
699 int opaque_rect_count;
703 uint8 orders_update_1[] =
704 "\x00\x00\x33\xd0\x07\x00\x80\xba\x0d\x0a\x7f\x1e\x2c\x4d\x00\x36"
705 "\x02\xd3\x00\x47\x00\x4d\x00\xf0\x01\x87\x00\xc2\xdc\xff\x05\x7f"
706 "\x0f\x67\x01\x90\x01\x8e\x01\xa5\x01\x67\x01\x90\x01\x28\x00\x16"
707 "\x00\xf0\xf0\xf0\x15\x0f\xf0\x2d\x01\x19\xfe\x2d\x01\xec\xfd\x0d"
708 "\x16\x77\xf0\xff\xff\x01\x01\xa8\x01\x90\x01\x0d\xf0\xf0\xf0\x04"
709 "\x05\x66\x6b\x14\x15\x6c\x1d\x0a\x0f\xd0\x16\x64\x01\x15\xff\x50"
710 "\x03\x15\x0f\xf0\x65\x01\x15\xfe\x65\x01\xb0\xfd\x1d\x16\x01\xf0"
711 "\xff\xff\x01\x01\x7a";
713 uint8 orders_update_2[] =
714 "\x00\x00\x45\x62\x03\x00\x93\x14\x55\x01\x50\xff\xff\xff\x55\x01"
715 "\x50\x01\x01\x01\x55\x01\x50\xff\xff\xff\x16\x00\x17\x00\xea\x03"
716 "\xea\x03\x02\x00\x85\x02\x16\x00\x02\x00\x00\x00\x03\x00\x14\xb2";
718 void test_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
723 void test_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
728 void test_patblt(rdpContext* context, PATBLT_ORDER* patblt)
733 void test_update_recv_orders(void)
741 update = update_new(rdp);
743 update->context = malloc(sizeof(rdpContext));
744 update->context->rdp = rdp;
746 opaque_rect_count = 0;
750 update->primary->OpaqueRect = test_opaque_rect;
751 update->primary->Polyline = test_polyline;
752 update->primary->PatBlt = test_patblt;
754 s->p = s->data = orders_update_1;
755 s->size = sizeof(orders_update_1);
757 update_recv(update, s);
759 CU_ASSERT(opaque_rect_count == 5);
760 CU_ASSERT(polyline_count == 2);
762 update->primary->order_info.orderType = ORDER_TYPE_PATBLT;
763 s->p = s->data = orders_update_2;
764 s->size = sizeof(orders_update_2);
766 update_recv(update, s);
768 CU_ASSERT(patblt_count == 3);
770 free(update->context);