+/* \r
+ * Unit test suite for comdlg32 API functions: printer dialogs\r
+ *\r
+ * Copyright 2006 Detlef Riekenberg\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA\r
+ *\r
+ */\r
+\r
+#include <stdarg.h>\r
+\r
+#include "windef.h"\r
+#include "winbase.h"\r
+#include "winerror.h"\r
+#include "wingdi.h"\r
+#include "wingdi.h"\r
+#include "winuser.h"\r
+\r
+#include "cderr.h"\r
+#include "commdlg.h"\r
+\r
+#include "wine/test.h"\r
+\r
+\r
+/* ######## */\r
+\r
+static void test_PageSetupDlgA(void)\r
+{\r
+ LPPAGESETUPDLGA pDlg;\r
+ DWORD res;\r
+\r
+ pDlg = HeapAlloc(GetProcessHeap(), 0, (sizeof(PAGESETUPDLGA)) * 2);\r
+ if (!pDlg) return;\r
+\r
+ SetLastError(0xdeadbeef);\r
+ res = PageSetupDlgA(NULL);\r
+ ok( !res && (CommDlgExtendedError() == CDERR_INITIALIZATION),\r
+ "returned %u with %u and 0x%x (expected '0' and "\r
+ "CDERR_INITIALIZATION)\n", res, GetLastError(), CommDlgExtendedError());\r
+\r
+ ZeroMemory(pDlg, sizeof(PAGESETUPDLGA));\r
+ pDlg->lStructSize = sizeof(PAGESETUPDLGA) -1;\r
+ SetLastError(0xdeadbeef);\r
+ res = PageSetupDlgA(pDlg);\r
+ ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),\r
+ "returned %u with %u and 0x%x (expected '0' and "\r
+ "CDERR_STRUCTSIZE)\n", res, GetLastError(), CommDlgExtendedError());\r
+\r
+ ZeroMemory(pDlg, sizeof(PAGESETUPDLGA));\r
+ pDlg->lStructSize = sizeof(PAGESETUPDLGA) +1;\r
+ pDlg->Flags = PSD_RETURNDEFAULT;\r
+ SetLastError(0xdeadbeef);\r
+ res = PageSetupDlgA(pDlg);\r
+ ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),\r
+ "returned %u with %u and 0x%x (expected '0' and CDERR_STRUCTSIZE)\n",\r
+ res, GetLastError(), CommDlgExtendedError());\r
+\r
+\r
+ ZeroMemory(pDlg, sizeof(PAGESETUPDLGA));\r
+ pDlg->lStructSize = sizeof(PAGESETUPDLGA);\r
+ pDlg->Flags = PSD_RETURNDEFAULT;\r
+ SetLastError(0xdeadbeef);\r
+ res = PageSetupDlgA(pDlg);\r
+ trace("after pagesetupdlga res = %d, le %d, ext error 0x%x\n",\r
+ res, GetLastError(), CommDlgExtendedError());\r
+ ok( res || (CommDlgExtendedError() == PDERR_NODEFAULTPRN),\r
+ "returned %u with %u and 0x%x (expected '!= 0' or '0' and "\r
+ "PDERR_NODEFAULTPRN)\n", res, GetLastError(), CommDlgExtendedError());\r
+ if (!res && (CommDlgExtendedError() == PDERR_NODEFAULTPRN)) {\r
+ skip("No printer configured.\n");\r
+ HeapFree(GetProcessHeap(), 0, pDlg);\r
+ return;\r
+ }\r
+ ok( pDlg->hDevMode && pDlg->hDevNames,\r
+ "got %p and %p (expected '!= NULL' for both)\n",\r
+ pDlg->hDevMode, pDlg->hDevNames);\r
+\r
+ GlobalFree(pDlg->hDevMode);\r
+ GlobalFree(pDlg->hDevNames);\r
+\r
+ HeapFree(GetProcessHeap(), 0, pDlg);\r
+\r
+}\r
+\r
+/* ##### */\r
+\r
+static void test_PrintDlgA(void)\r
+{\r
+ DWORD res;\r
+ LPPRINTDLGA pDlg;\r
+\r
+\r
+ pDlg = HeapAlloc(GetProcessHeap(), 0, (sizeof(PRINTDLGA)) * 2);\r
+ if (!pDlg) return;\r
+\r
+\r
+ /* will crash with unpatched wine */\r
+ SetLastError(0xdeadbeef);\r
+ res = PrintDlgA(NULL);\r
+ ok( !res && (CommDlgExtendedError() == CDERR_INITIALIZATION),\r
+ "returned %d with 0x%x and 0x%x (expected '0' and "\r
+ "CDERR_INITIALIZATION)\n", res, GetLastError(), CommDlgExtendedError());\r
+\r
+ ZeroMemory(pDlg, sizeof(PRINTDLGA));\r
+ pDlg->lStructSize = sizeof(PRINTDLGA) - 1;\r
+ SetLastError(0xdeadbeef);\r
+ res = PrintDlgA(pDlg);\r
+ ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),\r
+ "returned %d with 0x%x and 0x%x (expected '0' and "\r
+ "CDERR_STRUCTSIZE)\n", res, GetLastError(), CommDlgExtendedError());\r
+\r
+ ZeroMemory(pDlg, sizeof(PRINTDLGA));\r
+ pDlg->lStructSize = sizeof(PRINTDLGA) + 1;\r
+ pDlg->Flags = PD_RETURNDEFAULT;\r
+ SetLastError(0xdeadbeef);\r
+ res = PrintDlgA(pDlg);\r
+ ok( !res && (CommDlgExtendedError() == CDERR_STRUCTSIZE),\r
+ "returned %u with %u and 0x%x (expected '0' and "\r
+ "CDERR_STRUCTSIZE)\n", res, GetLastError(), CommDlgExtendedError());\r
+\r
+\r
+ ZeroMemory(pDlg, sizeof(PRINTDLGA));\r
+ pDlg->lStructSize = sizeof(PRINTDLGA);\r
+ pDlg->Flags = PD_RETURNDEFAULT;\r
+ SetLastError(0xdeadbeef);\r
+ res = PrintDlgA(pDlg);\r
+ ok( res || (CommDlgExtendedError() == PDERR_NODEFAULTPRN),\r
+ "returned %d with 0x%x and 0x%x (expected '!= 0' or '0' and "\r
+ "PDERR_NODEFAULTPRN)\n", res, GetLastError(), CommDlgExtendedError());\r
+\r
+ HeapFree(GetProcessHeap(), 0, pDlg);\r
+\r
+}\r
+\r
+\r
+START_TEST(printdlg)\r
+{\r
+ test_PageSetupDlgA();\r
+ test_PrintDlgA();\r
+\r
+}\r