[1/3] shell32: Add test for GetCurrentProcessExplicitAppUserModelID.

Vincent Povirk madewokherd at gmail.com
Thu Apr 5 16:49:56 CDT 2012


-------------- next part --------------
From 81f9cca41d8d5c1fd9d9fe943b10e18c979b8385 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 5 Apr 2012 11:33:59 -0500
Subject: [PATCH 1/4] shell32: Add test for
 GetCurrentProcessExplicitAppUserModelID.

---
 dlls/shell32/tests/Makefile.in    |    1 +
 dlls/shell32/tests/appusermodel.c |   87 +++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
 create mode 100644 dlls/shell32/tests/appusermodel.c

diff --git a/dlls/shell32/tests/Makefile.in b/dlls/shell32/tests/Makefile.in
index 4a361e4..bd6d007 100644
--- a/dlls/shell32/tests/Makefile.in
+++ b/dlls/shell32/tests/Makefile.in
@@ -3,6 +3,7 @@ IMPORTS   = shell32 ole32 oleaut32 user32 advapi32
 
 C_SRCS = \
 	appbar.c \
+	appusermodel.c \
 	assoc.c \
 	autocomplete.c \
 	brsfolder.c \
diff --git a/dlls/shell32/tests/appusermodel.c b/dlls/shell32/tests/appusermodel.c
new file mode 100644
index 0000000..b2ff236
--- /dev/null
+++ b/dlls/shell32/tests/appusermodel.c
@@ -0,0 +1,87 @@
+/* Unit tests for AppUserModelID's and related API's
+ *
+ * Copyright 2012 Vincent Povirk for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include <windows.h>
+
+#include "wine/test.h"
+
+static HRESULT (WINAPI *pSetCurrentProcessExplicitAppUserModelID)(PCWSTR);
+static HRESULT (WINAPI *pGetCurrentProcessExplicitAppUserModelID)(PWSTR*);
+
+static void test_process_appid(void)
+{
+    static const WCHAR winetest[] = {'W','i','n','e','T','e','s','t',0};
+    static const WCHAR winetest_full[] = {'W','i','n','e','.','W','i','n','e','T','e','s','t',0};
+    PWSTR explicit_id;
+    HRESULT hr;
+
+    if (0)
+    {
+        /* Crashes on Windows 7 */
+        hr = pGetCurrentProcessExplicitAppUserModelID(NULL);
+        ok(hr == E_INVALIDARG, "got %x, expected E_INVALIDARG\n", hr);
+
+        hr = pSetCurrentProcessExplicitAppUserModelID(NULL);
+        ok(hr == E_INVALIDARG, "got %x, expected E_INVALIDARG\n", hr);
+    }
+
+    explicit_id = (LPWSTR)0xda;
+    hr = pGetCurrentProcessExplicitAppUserModelID(&explicit_id);
+    ok(hr == E_FAIL, "got %x, expected E_FAIL\n", hr);
+    ok(explicit_id == NULL, "got %s, expected (null)\n", wine_dbgstr_w(explicit_id));
+    CoTaskMemFree(explicit_id);
+
+    hr = pSetCurrentProcessExplicitAppUserModelID(winetest);
+    ok(hr == S_OK, "got %x, expected S_OK\n", hr);
+
+    explicit_id = (LPWSTR)0xda;
+    hr = pGetCurrentProcessExplicitAppUserModelID(&explicit_id);
+    ok(hr == S_OK, "got %x, expected S_OK\n", hr);
+    ok(explicit_id && !winetest_strcmpW(explicit_id, winetest), "got %s, expected WineTest\n", wine_dbgstr_w(explicit_id));
+    CoTaskMemFree(explicit_id);
+
+    hr = pSetCurrentProcessExplicitAppUserModelID(winetest_full);
+    ok(hr == S_OK, "got %x, expected S_OK\n", hr);
+
+    explicit_id = (LPWSTR)0xda;
+    hr = pGetCurrentProcessExplicitAppUserModelID(&explicit_id);
+    ok(hr == S_OK, "got %x, expected S_OK\n", hr);
+    ok(explicit_id && !winetest_strcmpW(explicit_id, winetest_full), "got %s, expected Wine.WineTest\n", wine_dbgstr_w(explicit_id));
+    CoTaskMemFree(explicit_id);
+}
+
+START_TEST(appusermodel)
+{
+    HMODULE hshell32;
+
+    hshell32 = GetModuleHandleA("shell32.dll");
+    pSetCurrentProcessExplicitAppUserModelID = (void*)GetProcAddress(hshell32, "SetCurrentProcessExplicitAppUserModelID");
+    pGetCurrentProcessExplicitAppUserModelID = (void*)GetProcAddress(hshell32, "GetCurrentProcessExplicitAppUserModelID");
+
+    if (!pSetCurrentProcessExplicitAppUserModelID ||
+        !pGetCurrentProcessExplicitAppUserModelID)
+    {
+        todo_wine win_skip("missing AppUserModel functions\n");
+        return;
+    }
+
+    test_process_appid();
+}
-- 
1.7.9.1


More information about the wine-patches mailing list