55e173ac291bd546334bb6cfee3d5414d1240dd0
[reactos.git] / rostests / apitests / uxtheme / DrawThemeParentBackground.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for DrawThemeParentBackground
5 * PROGRAMMERS: Giannis Adamopoulos
6 */
7
8 #include <apitest.h>
9 #include <stdio.h>
10 #include <windows.h>
11 #include <uxtheme.h>
12 #include <undocuser.h>
13 #include <msgtrace.h>
14 #include <user32testhelpers.h>
15
16 HWND hWnd1, hWnd2;
17
18 static int get_iwnd(HWND hWnd)
19 {
20 if(hWnd == hWnd1) return 1;
21 else if(hWnd == hWnd2) return 2;
22 else return 0;
23 }
24
25 static LRESULT CALLBACK TestProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
26 {
27 int iwnd = get_iwnd(hwnd);
28
29 if(message > WM_USER || !iwnd || message == WM_GETICON)
30 return DefWindowProc(hwnd, message, wParam, lParam);
31
32 RECORD_MESSAGE(iwnd, message, SENT, 0,0);
33 return DefWindowProc(hwnd, message, wParam, lParam);
34 }
35
36 static void FlushMessages()
37 {
38 MSG msg;
39
40 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
41 {
42 int iwnd = get_iwnd(msg.hwnd);
43 if(iwnd && msg.message <= WM_USER)
44 RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
45 DispatchMessageW( &msg );
46 }
47 }
48
49 MSG_ENTRY draw_parent_chain[]={{1, WM_ERASEBKGND},
50 {1, WM_PRINTCLIENT},
51 {0,0}};
52
53 void Test_Messages()
54 {
55 HDC hdc;
56 RECT rc;
57
58 RegisterSimpleClass(TestProc, L"testClass");
59
60 hWnd1 = CreateWindowW(L"testClass", L"Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);
61 ok (hWnd1 != NULL, "Expected CreateWindowW to succeed\n");
62 ShowWindow(hWnd1, SW_SHOW);
63 UpdateWindow(hWnd1);
64
65 hWnd2 = CreateWindowW(L"testClass", L"test window", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hWnd1, NULL, NULL, NULL);
66 ok (hWnd2 != NULL, "Expected CreateWindowW to succeed\n");
67 ShowWindow(hWnd2, SW_SHOW);
68 UpdateWindow(hWnd2);
69
70 FlushMessages();
71 EMPTY_CACHE();
72
73 DrawThemeParentBackground(hWnd2, NULL, NULL);
74 FlushMessages();
75 COMPARE_CACHE(empty_chain);
76
77 DrawThemeParentBackground(hWnd1, NULL, NULL);
78 FlushMessages();
79 COMPARE_CACHE(empty_chain);
80
81 hdc = GetDC(hWnd1);
82
83 DrawThemeParentBackground(hWnd2, hdc, NULL);
84 FlushMessages();
85 COMPARE_CACHE(draw_parent_chain);
86
87 DrawThemeParentBackground(hWnd1, hdc, NULL);
88 FlushMessages();
89 COMPARE_CACHE(empty_chain);
90
91 memset(&rc, 0, sizeof(rc));
92
93 DrawThemeParentBackground(hWnd2, hdc, &rc);
94 FlushMessages();
95 COMPARE_CACHE(draw_parent_chain);
96
97 DrawThemeParentBackground(hWnd1, hdc, &rc);
98 FlushMessages();
99 COMPARE_CACHE(empty_chain);
100 }
101
102 START_TEST(DrawThemeParentBackground)
103 {
104 Test_Messages();
105 }