[SHLWAPI_APITEST]: Use the 'add_rostests_file' command from Colin ;)
[reactos.git] / rostests / dxtest / ddraw / Surface / private_data.cpp
1 BOOL CreateSurface(LPDIRECTDRAWSURFACE7* pSurface);
2
3 BOOL Test_PrivateData (INT* passed, INT* failed)
4 {
5 LPDIRECTDRAWSURFACE7 Surface;
6 DWORD size, dummy = 0xBAADF00D;
7 GUID guid = { 0 };
8 GUID guid2 = { 0x1 };
9
10 if(!CreateSurface(&Surface))
11 return FALSE;
12
13 // General test
14 TEST(Surface->SetPrivateData(guid, NULL, 0, 0) == DDERR_INVALIDPARAMS);
15 TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, 0, 0) == DDERR_INVALIDPARAMS);
16 TEST(Surface->SetPrivateData(guid, (LPVOID)0xdeadbeef, sizeof(DWORD), 0) == DDERR_INVALIDPARAMS);
17 TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), 0) == DD_OK);
18
19 TEST(Surface->GetPrivateData(guid, NULL, 0) == DDERR_INVALIDPARAMS);
20 TEST(Surface->GetPrivateData(guid, &dummy, 0) == DDERR_INVALIDPARAMS);
21 size = 0;
22 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
23 size = 2;
24 TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
25 TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_INVALIDPARAMS);
26 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
27 TEST(Surface->GetPrivateData(guid2, NULL, 0) == DDERR_NOTFOUND);
28
29 TEST(Surface->FreePrivateData(guid) == DD_OK);
30 TEST(Surface->FreePrivateData(guid) == DDERR_NOTFOUND);
31
32 // Test for DDSPD_VOLATILE flag
33 TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), DDSPD_VOLATILE) == DD_OK);
34 size = 0;
35 TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
36 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
37
38 DDBLTFX bltfx;
39 bltfx.dwSize = sizeof(DDBLTFX);
40 bltfx.dwFillColor = RGB(0, 0, 0);
41 if(Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx) != DD_OK)
42 printf("ERROR: Failed to draw to surface !");
43 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_EXPIRED);
44
45 // TODO: Test for DDSPD_IUNKNOWNPOINTER (see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_5qyf.asp)
46
47 Surface->Release();
48 return TRUE;
49 }