ReactOS 0.4.15-dev-7918-g2a2556c
animate.c
Go to the documentation of this file.
1/* Unit tests for the animate control.
2 *
3 * Copyright 2016 Bruno Jesus
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdarg.h>
21
22#include "windef.h"
23#include "winbase.h"
24#include "wingdi.h"
25#include "winuser.h"
26#include "commctrl.h"
27
28#include "wine/test.h"
29
30#define SEARCHING_AVI_INDEX 151 /* From shell32 resource library */
31#define INVALID_AVI_INDEX 0xffff
32
34static const char animateTestClass[] = "AnimateTestClass";
37
38/* try to make sure pending X events have been processed before continuing */
39static void flush_events(void)
40{
41 MSG msg;
42 int diff = 100;
43 DWORD time = GetTickCount() + diff;
44
45 while (diff > 0)
46 {
47 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min(10,diff), QS_ALLINPUT ) == WAIT_TIMEOUT) break;
48 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
49 diff = time - GetTickCount();
50 }
51}
52
54{
55 switch(msg)
56 {
57 case WM_DESTROY:
59 break;
60
61 default:
63 }
64 return 0L;
65}
66
68{
70 ok(!GetUpdateRect(hWnd, NULL, FALSE), "GetUpdateRect must return zero after UpdateWindow\n");
71}
72
73static void create_animate(DWORD parent_style, DWORD animate_style)
74{
75 WNDCLASSA wc;
76 RECT rect;
77 BOOL ret;
78
80 wc.cbClsExtra = 0;
81 wc.cbWndExtra = 0;
83 wc.hIcon = NULL;
86 wc.lpszMenuName = NULL;
89 RegisterClassA(&wc);
90
91 SetRect(&rect, 0, 0, 200, 200);
93 ok(ret, "got %d\n", ret);
94
95 hAnimateParentWnd = CreateWindowExA(0, animateTestClass, "Animate Test", WS_OVERLAPPEDWINDOW | parent_style,
96 CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, GetModuleHandleA(NULL), 0);
97 ok(hAnimateParentWnd != NULL, "failed to create parent wnd\n");
98
101 0, 0, rect.right, rect.bottom, hAnimateParentWnd, NULL, shell32, 0);
102 ok(hAnimateWnd != NULL, "failed to create parent wnd\n");
104
106 ok(GetUpdateRect(hAnimateParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
107 flush_events();
109}
110
111static void destroy_animate(void)
112{
113 MSG msg;
114
116 while (GetMessageA(&msg,0,0,0))
117 {
120 }
122}
123
124static void cleanup(void)
125{
127}
128
129static void test_play(void)
130{
131 LONG res;
132 DWORD err;
133
134 create_animate(0, 0);
135 SetLastError(0xdeadbeef);
137 err = GetLastError();
138 ok(res == 0, "Invalid video should have failed\n");
139 ok(err == ERROR_RESOURCE_NAME_NOT_FOUND, "Expected 1814, got %u\n", err);
140
141 SetLastError(0xdeadbeef);
143 err = GetLastError();
144 ok(res == 0, "Play should have failed\n");
145 ok(err == 0xdeadbeef, "Expected 0xdeadbeef, got %u\n", err);
147
148 create_animate(0, 0);
150 ok(res != 0, "Load AVI resource failed\n");
152 ok(res != 0, "Play should have worked\n");
154}
155
157{
158 shell32 = LoadLibraryA("Shell32.dll");
159
160 test_play();
161
162 cleanup();
163}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
static void update_window(void)
Definition: wordpad.c:651
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
__u16 time
Definition: mkdosfs.c:8
static HWND hAnimateParentWnd
Definition: animate.c:33
#define SEARCHING_AVI_INDEX
Definition: animate.c:30
static HANDLE shell32
Definition: animate.c:36
static void destroy_animate(void)
Definition: animate.c:111
static void cleanup(void)
Definition: animate.c:124
static WNDPROC animate_wndproc
Definition: animate.c:35
static void test_play(void)
Definition: animate.c:129
static void flush_events(void)
Definition: animate.c:39
#define INVALID_AVI_INDEX
Definition: animate.c:31
static LRESULT CALLBACK animate_test_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: animate.c:53
static void create_animate(DWORD parent_style, DWORD animate_style)
Definition: animate.c:73
static HWND hAnimateWnd
Definition: animate.c:33
static const char animateTestClass[]
Definition: animate.c:34
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define ACM_OPENA
Definition: commctrl.h:4151
#define ANIMATE_CLASSA
Definition: commctrl.h:4142
#define ACM_PLAY
Definition: commctrl.h:4156
#define err(...)
& rect
Definition: startmenu.cpp:1413
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
#define GWLP_WNDPROC
Definition: treelist.c:66
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define MAKELONG(a, b)
Definition: typedefs.h:249
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_RESOURCE_NAME_NOT_FOUND
Definition: winerror.h:1121
#define SW_SHOWNORMAL
Definition: winuser.h:770
#define CS_VREDRAW
Definition: winuser.h:658
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define SetWindowLongPtrA
Definition: winuser.h:5345
#define WM_CLOSE
Definition: winuser.h:1621
BOOL WINAPI TranslateMessage(_In_ const MSG *)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define QS_ALLINPUT
Definition: winuser.h:903
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define PM_REMOVE
Definition: winuser.h:1196
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define WM_DESTROY
Definition: winuser.h:1609
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2090
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
const char * LPCSTR
Definition: xmlstorage.h:183