Author: jgardou
Date: Thu Nov 14 23:11:23 2013
New Revision: 60994
URL:
http://svn.reactos.org/svn/reactos?rev=60994&view=rev
Log:
[USER32_APITEST]
- Add tests for LookupIconIdFromDirectoryEx
- Add a workaround in GetIconInfo tests for a ReactOS bug in EnumDisplaySettings
- Add tests for EnumDisplaySettings demonstrating the bug.
- Add some traces to better follow the test run
Added:
trunk/rostests/apitests/user32/EnumDisplaySettings.c (with props)
trunk/rostests/apitests/user32/LookupIconIdFromDirectoryEx.c (with props)
Modified:
trunk/rostests/apitests/user32/CMakeLists.txt
trunk/rostests/apitests/user32/CreateIconFromResourceEx.c
trunk/rostests/apitests/user32/GetIconInfo.c
trunk/rostests/apitests/user32/LoadImage.c
trunk/rostests/apitests/user32/testlist.c
Modified: trunk/rostests/apitests/user32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/CMakeList…
==============================================================================
--- trunk/rostests/apitests/user32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/user32/CMakeLists.txt [iso-8859-1] Thu Nov 14 23:11:23 2013
@@ -7,12 +7,14 @@
DestroyCursorIcon.c
DrawIconEx.c
desktop.c
+ EnumDisplaySettings.c
GetIconInfo.c
GetKeyState.c
GetPeekMessage.c
GetSystemMetrics.c
InitializeLpkHooks.c
LoadImage.c
+ LookupIconIdFromDirectoryEx.c
RealGetWindowClass.c
ScrollDC.c
ScrollWindowEx.c
Modified: trunk/rostests/apitests/user32/CreateIconFromResourceEx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/CreateIco…
==============================================================================
--- trunk/rostests/apitests/user32/CreateIconFromResourceEx.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/user32/CreateIconFromResourceEx.c [iso-8859-1] Thu Nov 14
23:11:23 2013
@@ -2,6 +2,7 @@
#include <apitest.h>
#include <winuser.h>
+#include <wingdi.h>
START_TEST(CreateIconFromResourceEx)
{
@@ -9,7 +10,9 @@
HMODULE hMod;
HRSRC hResource; // handle to FindResource
HRSRC hMem; // handle to LoadResource
- BYTE *lpResource; // pointer to resource data
+ BYTE *lpResource; // pointer to resource data
+ DWORD err;
+ int wResId;
hMod = GetModuleHandle(NULL);
ok(hMod != NULL, "\n");
@@ -43,6 +46,47 @@
ok(DestroyCursor(hcur1), "\n");
ok(DestroyCursor(hcur2), "\n");
ok(DestroyCursor(hcur2), "\n");
+
+ /* See what happens if we ask for an icon on a cursor resource (directory) */
+ SetLastError(0x0badf00d);
+ hcur1 = CreateIconFromResourceEx(lpResource, SizeofResource(hMod, hResource), TRUE,
0x00030000, 0, 0, 0);
+ ok(hcur1 == NULL, "\n");
+ err = GetLastError();
+ ok(err == 0x0badf00d, "err: %lu\n", err);
+
+ /* Same tests, but for cursor resource (not directory) */
+ wResId = LookupIconIdFromDirectoryEx(lpResource, FALSE, 0, 0, 0);
+ ok(wResId != 0, "\n");
+ FreeResource(hResource);
+
+ hResource = FindResourceA(hMod, MAKEINTRESOURCEA(wResId), RT_CURSOR);
+ ok(hResource != NULL, "\n");
+
+ hMem = LoadResource(hMod, hResource);
+ ok(hMem != NULL, "\n");
+
+ lpResource = LockResource(hMem);
+ ok(lpResource != NULL, "\n");
- FreeResource(hResource);
+ /* MSDN states that LR_SHARED permits to not load twice the same cursor again.
+ * But CreateIconFromResourceEx still returns two different handles */
+ hcur2 = CreateIconFromResourceEx(lpResource, SizeofResource(hMod, hResource), FALSE,
0x00030000, 0, 0, LR_SHARED);
+ ok(hcur2 != NULL, "\n");
+ ok(hcur2 != hcur1, "\n");
+ hcur1 = CreateIconFromResourceEx(lpResource, SizeofResource(hMod, hResource), FALSE,
0x00030000, 0, 0, LR_SHARED);
+ ok(hcur1 != NULL, "\n");
+ ok(hcur2 != hcur1, "\n");
+
+ /* Try to destroy them multiple times (see DestroyCursor test) */
+ ok(DestroyCursor(hcur1), "\n");
+ ok(DestroyCursor(hcur1), "\n");
+ ok(DestroyCursor(hcur2), "\n");
+ ok(DestroyCursor(hcur2), "\n");
+
+ /* See what happens if we ask for an icon on a cursor resource (no directory) */
+ SetLastError(0x0badf00d);
+ hcur1 = CreateIconFromResourceEx(lpResource, SizeofResource(hMod, hResource), TRUE,
0x00030000, 0, 0, 0);
+ ok(hcur1 == NULL, "\n");
+ err = GetLastError();
+ ok(err == 0x0badf00d, "err: %lu\n", err);
}
Added: trunk/rostests/apitests/user32/EnumDisplaySettings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/EnumDispl…
==============================================================================
--- trunk/rostests/apitests/user32/EnumDisplaySettings.c (added)
+++ trunk/rostests/apitests/user32/EnumDisplaySettings.c [iso-8859-1] Thu Nov 14 23:11:23
2013
@@ -0,0 +1,60 @@
+#include <apitest.h>
+
+#include <wingdi.h>
+#include <winuser.h>
+
+#define SIZEOF_DEVMODEW_300 188
+#define SIZEOF_DEVMODEW_400 212
+#define SIZEOF_DEVMODEW_500 220
+
+START_TEST(EnumDisplaySettings)
+{
+ DEVMODEW dm;
+ HDC icDisplay;
+
+ /* TODO: test with a printer driver */
+
+ icDisplay = CreateICW(L"DISPLAY", NULL, NULL, NULL);
+ ok(icDisplay != NULL, "\n");
+
+ dm.dmDriverExtra = 0x7777;
+
+ /* Try ridiculous size */
+ dm.dmSize = 0x8888;
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+ ok(dm.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be
%d.\n", dm.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
+ ok(dm.dmSize == SIZEOF_DEVMODEW_300, "%d\n", dm.dmSize);
+ ok(dm.dmDriverExtra == 0, "%d\n", dm.dmDriverExtra);
+
+ /* Try a tiny size */
+ dm.dmSize = 4;
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+ ok(dm.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be
%d.\n", dm.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
+ ok(dm.dmSize == SIZEOF_DEVMODEW_300, "%d\n", dm.dmSize);
+
+ /* Something in between */
+ dm.dmSize = (SIZEOF_DEVMODEW_300 + SIZEOF_DEVMODEW_400) / 2 ;
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+ ok(dm.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be
%d.\n", dm.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
+ ok(dm.dmSize == SIZEOF_DEVMODEW_300, "%d\n", dm.dmSize);
+
+ /* WINVER < 0x0400 */
+ dm.dmSize = SIZEOF_DEVMODEW_300;
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+ ok(dm.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be
%d.\n", dm.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
+ ok(dm.dmSize == SIZEOF_DEVMODEW_300, "%d\n", dm.dmSize);
+
+ /* WINVER < 0x0500 */
+ dm.dmSize = SIZEOF_DEVMODEW_400;
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+ ok(dm.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be
%d.\n", dm.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
+ ok(dm.dmSize == SIZEOF_DEVMODEW_300, "%d\n", dm.dmSize);
+
+ /* "Modern" windows */
+ dm.dmSize = SIZEOF_DEVMODEW_500;
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+ ok(dm.dmBitsPerPel == GetDeviceCaps(icDisplay, BITSPIXEL), "%lu, should be
%d.\n", dm.dmBitsPerPel, GetDeviceCaps(icDisplay, BITSPIXEL));
+ ok(dm.dmSize == SIZEOF_DEVMODEW_300, "%d\n", dm.dmSize);
+
+ DeleteDC(icDisplay);
+}
Propchange: trunk/rostests/apitests/user32/EnumDisplaySettings.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/user32/GetIconInfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/GetIconIn…
==============================================================================
--- trunk/rostests/apitests/user32/GetIconInfo.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/user32/GetIconInfo.c [iso-8859-1] Thu Nov 14 23:11:23 2013
@@ -99,7 +99,7 @@
ok(bitmap.bmHeight == 16, "\n");
ok(bitmap.bmWidthBytes == 8 * bitmap.bmBitsPixel / 8, "\n");
ok(bitmap.bmPlanes == 1, "\n");
- ok(bitmap.bmBitsPixel == screen_bpp, "\n");
+ ok(bitmap.bmBitsPixel == screen_bpp, "%d\n", bitmap.bmBitsPixel);
ok(bitmap.bmBits == NULL, "\n");
DeleteObject(iconinfo2.hbmMask);
DeleteObject(iconinfo2.hbmColor);
@@ -152,13 +152,20 @@
DWORD data[] = {0, 0, 0, 0, 0, 0};
DWORD bpp, screenbpp, creationbpp;
DEVMODEW dm;
+
+ dm.dmSize = sizeof(dm);
+ dm.dmDriverExtra = 0;
/* Test icons behaviour regarding display settings */
- EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm);
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
screenbpp = dm.dmBitsPerPel;
- Test_GetIconInfo(0, screenbpp);
- Test_GetIconInfo(1, screenbpp);
+ trace("Icon default size: %dx%d.\n", GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON));
+ trace("Cursor default size: %dx%d.\n", GetSystemMetrics(SM_CXCURSOR),
GetSystemMetrics(SM_CYCURSOR));
+
+ trace("Screen bpp: %lu.\n", screenbpp);
+ Test_GetIconInfo(FALSE, screenbpp);
+ Test_GetIconInfo(TRUE, screenbpp);
hcursor = LoadCursor(GetModuleHandle(NULL), "TESTCURSOR");
ok(hcursor != 0, "should not fail, error %ld\n", GetLastError());
@@ -192,6 +199,7 @@
skip("Unable to change bpp to %lu.\n", creationbpp);
continue;
}
+ trace("starting with creationbpp = %lu\n", creationbpp);
hcursor = LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_TEST),
IMAGE_ICON,
@@ -203,6 +211,7 @@
/* If we reverse the loop here (32->16 bpp), then hbmColor.bmBitsPixel is
always 32 */
for(bpp = 16; bpp <=32; bpp += 8)
{
+ trace("testing resetting to %lu\n", bpp);
dm.dmBitsPerPel = bpp;
if(ChangeDisplaySettingsExW(NULL, &dm, NULL, 0, NULL) !=
DISP_CHANGE_SUCCESSFUL)
{
Modified: trunk/rostests/apitests/user32/LoadImage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/LoadImage…
==============================================================================
--- trunk/rostests/apitests/user32/LoadImage.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/user32/LoadImage.c [iso-8859-1] Thu Nov 14 23:11:23 2013
@@ -35,7 +35,7 @@
hCopy = CopyIcon(arg);
ok(hCopy != NULL, "\n");
ok(DestroyIcon(hCopy), "\n");
-
+
hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, 0);
ok(hCopy != NULL, "\n");
ok(DestroyIcon(hCopy), "\n");
Added: trunk/rostests/apitests/user32/LookupIconIdFromDirectoryEx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/LookupIco…
==============================================================================
--- trunk/rostests/apitests/user32/LookupIconIdFromDirectoryEx.c (added)
+++ trunk/rostests/apitests/user32/LookupIconIdFromDirectoryEx.c [iso-8859-1] Thu Nov 14
23:11:23 2013
@@ -0,0 +1,132 @@
+
+#include <apitest.h>
+
+#include <wingdi.h>
+#include <winuser.h>
+
+#include "resource.h"
+
+START_TEST(LookupIconIdFromDirectoryEx)
+{
+ HRSRC hResource;
+ HGLOBAL hMem;
+ HMODULE hMod;
+ int wResId;
+ DEVMODEW dm;
+ DWORD dwOrigBpp;
+ UINT i;
+ BYTE* lpResource;
+
+ /* This tests assumes that default icon size is 32x32 */
+
+ struct
+ {
+ DWORD bpp;
+ int wResId;
+ int cxDesired;
+ int cyDesired;
+ UINT flags;
+ }
+ TestData[] =
+ {
+ {8, 1, 0, 0, 0},
+ {8, 1, 48, 48, 0},
+ {8, 2, 32, 32, 0},
+ {8, 3, 24, 24, 0},
+ {8, 4, 16, 16, 0},
+ {8, 1, 0, 0, LR_MONOCHROME},
+ {8, 1, 48, 48, LR_MONOCHROME},
+ {8, 2, 32, 32, LR_MONOCHROME},
+ {8, 3, 24, 24, LR_MONOCHROME},
+ {8, 4, 16, 16, LR_MONOCHROME},
+ {8, 2, 0, 0, LR_DEFAULTSIZE},
+ {8, 1, 48, 48, LR_DEFAULTSIZE},
+ /* Non exact sizes */
+ {8, 1, 41, 41, 0},
+ {8, 1, 40, 40, 0},
+ /* Non square sizes */
+ {8, 1, 16, 48, 0},
+ {8, 1, 48, 16, 0},
+ {16, 5, 0, 0, 0},
+ {16, 5, 48, 48, 0},
+ {16, 6, 32, 32, 0},
+ {16, 7, 24, 24, 0},
+ {16, 1, 0, 0, LR_MONOCHROME},
+ {16, 1, 48, 48, LR_MONOCHROME},
+ {16, 2, 32, 32, LR_MONOCHROME},
+ {16, 3, 24, 24, LR_MONOCHROME},
+ {16, 4, 16, 16, LR_MONOCHROME},
+ {16, 6, 0, 0, LR_DEFAULTSIZE},
+ {16, 5, 48, 48, LR_DEFAULTSIZE},
+ {24, 5, 0, 0, 0},
+ {24, 5, 48, 48, 0},
+ {24, 6, 32, 32, 0},
+ {24, 7, 24, 24, 0},
+ {24, 8, 16, 16, 0},
+ {16, 8, 16, 16, 0},
+ {24, 1, 0, 0, LR_MONOCHROME},
+ {24, 1, 48, 48, LR_MONOCHROME},
+ {24, 2, 32, 32, LR_MONOCHROME},
+ {24, 3, 24, 24, LR_MONOCHROME},
+ {24, 4, 16, 16, LR_MONOCHROME},
+ {24, 6, 0, 0, LR_DEFAULTSIZE},
+ {24, 5, 48, 48, LR_DEFAULTSIZE},
+ {32, 9, 0, 0, 0},
+ {32, 9, 48, 48, 0},
+ {32, 10, 32, 32, 0},
+ {32, 11, 24, 24, 0},
+ {32, 12, 16, 16, 0},
+ {32, 1, 0, 0, LR_MONOCHROME},
+ {32, 1, 48, 48, LR_MONOCHROME},
+ {32, 2, 32, 32, LR_MONOCHROME},
+ {32, 3, 24, 24, LR_MONOCHROME},
+ {32, 4, 16, 16, LR_MONOCHROME},
+ {32, 10, 0, 0, LR_DEFAULTSIZE},
+ {32, 9, 48, 48, LR_DEFAULTSIZE},
+ };
+
+ hMod = GetModuleHandle(NULL);
+ ok(hMod != NULL, "\n");
+ /* Find our cursor directory resource */
+ hResource = FindResourceA(hMod,
+ MAKEINTRESOURCE(IDI_TEST),
+ RT_GROUP_ICON);
+ ok(hResource != NULL, "\n");
+
+ hMem = LoadResource(hMod, hResource);
+ ok(hMem != NULL, "\n");
+
+ lpResource = LockResource(hMem);
+ ok(lpResource != NULL, "\n");
+
+ dm.dmSize = sizeof(dm);
+ dm.dmDriverExtra = 0;
+
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm), "\n");
+
+ dwOrigBpp = dm.dmBitsPerPel;
+
+ for (i = 0; i < sizeof(TestData)/sizeof(TestData[0]); i++)
+ {
+ dm.dmBitsPerPel = TestData[i].bpp;
+ if (ChangeDisplaySettingsExW(NULL, &dm, NULL, 0, NULL) !=
DISP_CHANGE_SUCCESSFUL)
+ {
+ skip("Unable to change bpp to %lu.\n", dm.dmBitsPerPel);
+ continue;
+ }
+ wResId = LookupIconIdFromDirectoryEx(lpResource, TRUE, TestData[i].cxDesired,
TestData[i].cyDesired, TestData[i].flags);
+ ok(wResId == TestData[i].wResId, "Got %d, expected %d for %dx%dx%lu, flags
%x.\n",
+ wResId,
+ TestData[i].wResId,
+ TestData[i].cxDesired,
+ TestData[i].cyDesired,
+ TestData[i].bpp,
+ TestData[i].flags);
+ }
+
+ /* Restore */
+ dm.dmBitsPerPel = dwOrigBpp;
+ ok(ChangeDisplaySettingsExW(NULL, &dm, NULL, 0, NULL) == DISP_CHANGE_SUCCESSFUL,
"\n");
+
+ FreeResource(hMem);
+}
Propchange: trunk/rostests/apitests/user32/LookupIconIdFromDirectoryEx.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/user32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/testlist.…
==============================================================================
--- trunk/rostests/apitests/user32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/user32/testlist.c [iso-8859-1] Thu Nov 14 23:11:23 2013
@@ -9,12 +9,14 @@
extern void func_DestroyCursorIcon(void);
extern void func_DrawIconEx(void);
extern void func_desktop(void);
+extern void func_EnumDisplaySettings(void);
extern void func_GetIconInfo(void);
extern void func_GetKeyState(void);
extern void func_GetPeekMessage(void);
extern void func_GetSystemMetrics(void);
extern void func_InitializeLpkHooks(void);
extern void func_LoadImage(void);
+extern void func_LookupIconIdFromDirectoryEx(void);
extern void func_RealGetWindowClass(void);
extern void func_ScrollDC(void);
extern void func_ScrollWindowEx(void);
@@ -33,12 +35,14 @@
{ "DestroyCursorIcon", func_DestroyCursorIcon },
{ "DrawIconEx", func_DrawIconEx },
{ "desktop", func_desktop },
+ { "EnumDisplaySettings", func_EnumDisplaySettings },
{ "GetIconInfo", func_GetIconInfo },
{ "GetKeyState", func_GetKeyState },
{ "GetPeekMessage", func_GetPeekMessage },
{ "GetSystemMetrics", func_GetSystemMetrics },
{ "InitializeLpkHooks", func_InitializeLpkHooks },
{ "LoadImage", func_LoadImage },
+ { "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
{ "RealGetWindowClass", func_RealGetWindowClass },
{ "ScrollDC", func_ScrollDC },
{ "ScrollWindowEx", func_ScrollWindowEx },