[3/3] shell32: Add test for STARTF_TITLEISAPPID flag.
Vincent Povirk
madewokherd at gmail.com
Thu Apr 5 16:58:37 CDT 2012
-------------- next part --------------
From 83736b323bf173aaa9803ff7ddf1cb16d5fb7fb2 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 5 Apr 2012 13:47:11 -0500
Subject: [PATCH 3/4] shell32: Add test for STARTF_TITLEISAPPID flag.
---
dlls/shell32/tests/appusermodel.c | 104 +++++++++++++++++++++++++++++++++++++
1 files changed, 104 insertions(+), 0 deletions(-)
diff --git a/dlls/shell32/tests/appusermodel.c b/dlls/shell32/tests/appusermodel.c
index b2ff236..4c724fa 100644
--- a/dlls/shell32/tests/appusermodel.c
+++ b/dlls/shell32/tests/appusermodel.c
@@ -26,6 +26,44 @@
static HRESULT (WINAPI *pSetCurrentProcessExplicitAppUserModelID)(PCWSTR);
static HRESULT (WINAPI *pGetCurrentProcessExplicitAppUserModelID)(PWSTR*);
+static LPWSTR strdup_AtoW(LPCSTR str)
+{
+ int size = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+ LPWSTR wstr = CoTaskMemAlloc((size + 1)*sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, size+1);
+ return wstr;
+}
+
+static WCHAR *strcpyW( WCHAR *dst, const WCHAR *src )
+{
+ WCHAR *p = dst;
+ while ((*p++ = *src++));
+ return dst;
+}
+
+static WCHAR *strcatW( WCHAR *dst, const WCHAR *src )
+{
+ while (*dst) dst++;
+ return strcpyW(dst, src);
+}
+
+static int check_id(const char *expectedA)
+{
+ LPWSTR expected;
+ LPWSTR actual=NULL;
+
+ pGetCurrentProcessExplicitAppUserModelID(&actual);
+
+ trace("actual id: %s\n", wine_dbgstr_w(actual));
+
+ if (!expectedA || !actual)
+ return expectedA || actual;
+
+ expected = strdup_AtoW(expectedA);
+
+ return winetest_strcmpW(expected, actual) != 0;
+}
+
static void test_process_appid(void)
{
static const WCHAR winetest[] = {'W','i','n','e','T','e','s','t',0};
@@ -68,9 +106,68 @@ static void test_process_appid(void)
CoTaskMemFree(explicit_id);
}
+static void test_create_process(void)
+{
+ static WCHAR expect_no_id[] = {'"',' ','a','p','p','u','s','e','r','m','o','d','e','l',' ','c','h','e','c','k','i','d',0};
+ static WCHAR expect_winetest_id[] = {'"',' ','a','p','p','u','s','e','r','m','o','d','e','l',' ','c','h','e','c','k','i','d',' ','W','i','n','e','T','e','s','t',0};
+ static WCHAR winetest[] = {'W','i','n','e','T','e','s','t',0};
+ STARTUPINFOW si;
+ PROCESS_INFORMATION pi;
+ WCHAR my_filename[MAX_PATH];
+ WCHAR cmdline[MAX_PATH + 1 + sizeof(expect_winetest_id)/sizeof(WCHAR)];
+ BOOL res;
+ DWORD exit_code;
+
+ GetModuleFileNameW(NULL, my_filename, MAX_PATH);
+
+ memset(&si, 0, sizeof(si));
+ si.cb = sizeof(si);
+
+ cmdline[0] = '"';
+ cmdline[1] = 0;
+ strcatW(cmdline, my_filename);
+ strcatW(cmdline, expect_no_id);
+
+ res = CreateProcessW(my_filename, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
+ ok(res, "CreateProcessW failed, last error=%i\n", GetLastError());
+
+ if (res)
+ {
+ CloseHandle(pi.hThread);
+ WaitForSingleObject(pi.hProcess, 1000);
+ GetExitCodeProcess(pi.hProcess, &exit_code);
+ CloseHandle(pi.hProcess);
+
+ ok(exit_code == 0, "child expecting (null) id returned %x\n", exit_code);
+ }
+
+ si.lpTitle = winetest;
+ si.dwFlags = STARTF_TITLEISAPPID;
+
+ cmdline[0] = '"';
+ cmdline[1] = 0;
+ strcatW(cmdline, my_filename);
+ strcatW(cmdline, expect_winetest_id);
+
+ res = CreateProcessW(my_filename, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
+ ok(res, "CreateProcessW failed, last error=%i\n", GetLastError());
+
+ if (res)
+ {
+ CloseHandle(pi.hThread);
+ WaitForSingleObject(pi.hProcess, 1000);
+ GetExitCodeProcess(pi.hProcess, &exit_code);
+ CloseHandle(pi.hProcess);
+
+ ok(exit_code == 0, "child expecting WineTest id returned %x\n", exit_code);
+ }
+}
+
START_TEST(appusermodel)
{
HMODULE hshell32;
+ int argc;
+ char **argv;
hshell32 = GetModuleHandleA("shell32.dll");
pSetCurrentProcessExplicitAppUserModelID = (void*)GetProcAddress(hshell32, "SetCurrentProcessExplicitAppUserModelID");
@@ -83,5 +180,12 @@ START_TEST(appusermodel)
return;
}
+ argc = winetest_get_mainargs(&argv);
+ if (argc >= 3 && !strcmp(argv[2], "checkid"))
+ {
+ ExitProcess(check_id(argv[3]));
+ }
+
test_process_appid();
+ test_create_process();
}
--
1.7.9.1
More information about the wine-patches
mailing list