[COMCTL32_APITEST] Add propsheetv6 testcase (#1853)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Sun, 18 Aug 2019 09:53:37 +0000 (18:53 +0900)
committerGitHub <noreply@github.com>
Sun, 18 Aug 2019 09:53:37 +0000 (18:53 +0900)
The proof of #1842. Property sheet does unchange the page after WM_INITDIALOG. CORE-16280

modules/rostests/apitests/comctl32/CMakeLists.txt
modules/rostests/apitests/comctl32/comctl32_apitest.rc
modules/rostests/apitests/comctl32/propsheet.c [new file with mode: 0644]
modules/rostests/apitests/comctl32/testlist.c

index 88f45e9..d3d11b9 100644 (file)
@@ -1,5 +1,5 @@
 
-add_executable(comctl32_apitest button.c toolbar.c testlist.c ../include/msgtrace.c comctl32_apitest.rc)
+add_executable(comctl32_apitest button.c propsheet.c toolbar.c testlist.c ../include/msgtrace.c comctl32_apitest.rc)
 target_link_libraries(comctl32_apitest wine)
 set_module_type(comctl32_apitest win32cui)
 add_importlibs(comctl32_apitest uxtheme comctl32 user32 gdi32 msvcrt kernel32 ntdll)
index 8cfe818..6772306 100644 (file)
@@ -7,3 +7,15 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 #include <reactos/manifest_exe.rc>
 
 5 BITMAP "test.bmp"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+1 DIALOG 0, 0, 171, 82
+CAPTION "propsheet page1"
+STYLE DS_MODALFRAME | WS_POPUPWINDOW | WS_CAPTION
+FONT 9, "MS Shell Dlg"
+{
+    EDITTEXT edt1, 29, 22, 60, 14
+    DEFPUSHBUTTON "OK", IDOK, 25, 60, 60, 14
+    PUSHBUTTON "Cancel", IDCANCEL, 96, 60, 60, 14
+}
diff --git a/modules/rostests/apitests/comctl32/propsheet.c b/modules/rostests/apitests/comctl32/propsheet.c
new file mode 100644 (file)
index 0000000..9daf5b0
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * PROJECT:     ReactOS api tests
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     Test for property sheet
+ * COPYRIGHT:   Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
+ */
+#include "wine/test.h"
+#include <windows.h>
+#include <windowsx.h>
+#include <commctrl.h>
+#include <prsht.h>
+
+#define IDC_APPLY_BUTTON 12321
+
+static BOOL s_bNotified;
+
+static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
+{
+    s_bNotified = FALSE;
+    SetDlgItemTextW(hwnd, edt1, L"text");
+    SetTimer(hwnd, 999, 300, NULL);
+    return TRUE;
+}
+
+static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
+{
+    switch (id)
+    {
+        case IDOK:
+        case IDCANCEL:
+            EndDialog(hwnd, id);
+            break;
+        case edt1:
+            if (codeNotify == EN_CHANGE)
+            {
+                s_bNotified = TRUE;
+                PropSheet_Changed(GetParent(hwnd), hwnd);
+            }
+            break;
+    }
+}
+
+static void OnTimer(HWND hwnd, UINT id)
+{
+    HWND hwndParent, hwndApply;
+
+    KillTimer(hwnd, id);
+
+    ok_int(s_bNotified, TRUE);
+
+    hwndParent = GetParent(hwnd);
+    hwndApply = GetDlgItem(hwndParent, IDC_APPLY_BUTTON);
+    ok_int(IsWindowEnabled(hwndApply), FALSE);
+
+    PropSheet_Changed(hwndParent, hwnd);
+    ok_int(IsWindowEnabled(hwndApply), TRUE);
+
+    PropSheet_UnChanged(hwndParent, hwnd);
+    ok_int(IsWindowEnabled(hwndApply), FALSE);
+
+    PropSheet_PressButton(hwndParent, PSBTN_OK);
+}
+
+static INT_PTR CALLBACK
+Page1DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    switch (uMsg)
+    {
+        HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitDialog);
+        HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
+        HANDLE_MSG(hwnd, WM_TIMER, OnTimer);
+    }
+    return 0;
+}
+
+typedef HPROPSHEETPAGE (WINAPI *FN_CreatePropertySheetPageW)(LPCPROPSHEETPAGEW);
+typedef int (WINAPI *FN_PropertySheetW)(LPCPROPSHEETHEADERW);
+
+START_TEST(propsheet)
+{
+    PROPSHEETPAGEW psp;
+    PROPSHEETHEADERW header;
+    HPROPSHEETPAGE hpsp[1];
+    HMODULE hComCtl32;
+    FN_CreatePropertySheetPageW pCreatePropertySheetPageW;
+    FN_PropertySheetW pPropertySheetW;
+
+    hComCtl32 = LoadLibraryW(L"comctl32.dll");
+    pCreatePropertySheetPageW = (FN_CreatePropertySheetPageW)GetProcAddress(hComCtl32, "CreatePropertySheetPageW");
+    pPropertySheetW = (FN_PropertySheetW)GetProcAddress(hComCtl32, "PropertySheetW");
+
+    ok(pCreatePropertySheetPageW != NULL, "pCreatePropertySheetPageW was NULL.\n");
+    ok(pPropertySheetW != NULL, "pPropertySheetW was NULL.\n");
+
+    if (!pCreatePropertySheetPageW || !pPropertySheetW)
+    {
+        skip("!pCreatePropertySheetPageW || !pPropertySheetW\n");
+        return;
+    }
+
+    ZeroMemory(&psp, sizeof(psp));
+    psp.dwSize = sizeof(psp);
+    psp.dwFlags = PSP_DEFAULT;
+    psp.hInstance = GetModuleHandleW(NULL);
+    psp.pszTemplate = MAKEINTRESOURCEW(1);
+    psp.pfnDlgProc = Page1DlgProc;
+    hpsp[0] = (*pCreatePropertySheetPageW)(&psp);
+    ok(hpsp[0] != NULL, "hpsp[0] was NULL.\n");
+
+    ZeroMemory(&header, sizeof(header));
+    header.dwSize = sizeof(header);
+    header.dwFlags = 0;
+    header.hInstance = GetModuleHandleW(NULL);
+    header.hwndParent = NULL;
+    header.nPages = ARRAYSIZE(hpsp);
+    header.phpage = hpsp;
+    header.pszCaption = L"propsheet";
+    ok((*pPropertySheetW)(&header) > 0, "PropertySheet returned non-positive value.\n");
+
+    FreeLibrary(hComCtl32);
+}
index a1d535d..da44fe7 100644 (file)
@@ -2,11 +2,13 @@
 #include <apitest.h>
 
 extern void func_button(void);
+extern void func_propsheet(void);
 extern void func_toolbar(void);
 
 const struct test winetest_testlist[] =
 {
     { "buttonv6", func_button },
+    { "propsheetv6", func_propsheet },
     { "toolbarv6", func_toolbar },
     { 0, 0 }
 };