Release 1.6-rc2.
[wine/testsucceed.git] / dlls / comctl32 / tests / v6util.h
blob848e95b9225b1ca76b9b97bbc231f2c8ff62457f
1 /*
2 * Utility routines for comctl32 v6 tests
4 * Copyright 2006 Mike McCormack for CodeWeavers
5 * Copyright 2007 George Gov
6 * Copyright 2009 Owen Rudge for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
25 #ifdef __i386__
26 #define ARCH "x86"
27 #elif defined __x86_64__
28 #define ARCH "amd64"
29 #else
30 #define ARCH "none"
31 #endif
33 static const CHAR manifest_name[] = "cc6.manifest";
35 static const CHAR manifest[] =
36 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
37 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n"
38 " <assemblyIdentity\n"
39 " type=\"win32\"\n"
40 " name=\"Wine.ComCtl32.Tests\"\n"
41 " version=\"1.0.0.0\"\n"
42 " processorArchitecture=\"" ARCH "\"\n"
43 " />\n"
44 "<description>Wine comctl32 test suite</description>\n"
45 "<dependency>\n"
46 " <dependentAssembly>\n"
47 " <assemblyIdentity\n"
48 " type=\"win32\"\n"
49 " name=\"microsoft.windows.common-controls\"\n"
50 " version=\"6.0.0.0\"\n"
51 " processorArchitecture=\"" ARCH "\"\n"
52 " publicKeyToken=\"6595b64144ccf1df\"\n"
53 " language=\"*\"\n"
54 " />\n"
55 "</dependentAssembly>\n"
56 "</dependency>\n"
57 "</assembly>\n";
59 static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
61 HANDLE hKernel32;
62 BOOL (WINAPI *pDeactivateActCtx)(DWORD, ULONG_PTR);
63 VOID (WINAPI *pReleaseActCtx)(HANDLE);
65 hKernel32 = GetModuleHandleA("kernel32.dll");
66 pDeactivateActCtx = (void*)GetProcAddress(hKernel32, "DeactivateActCtx");
67 pReleaseActCtx = (void*)GetProcAddress(hKernel32, "ReleaseActCtx");
68 if (!pDeactivateActCtx || !pReleaseActCtx)
70 win_skip("Activation contexts unsupported\n");
71 return;
74 pDeactivateActCtx(0, cookie);
75 pReleaseActCtx(hCtx);
77 DeleteFileA(manifest_name);
80 static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
82 HANDLE hKernel32;
83 HANDLE (WINAPI *pCreateActCtxA)(ACTCTXA*);
84 BOOL (WINAPI *pActivateActCtx)(HANDLE, ULONG_PTR*);
86 ACTCTXA ctx;
87 BOOL ret;
88 HANDLE file;
89 DWORD written;
91 hKernel32 = GetModuleHandleA("kernel32.dll");
92 pCreateActCtxA = (void*)GetProcAddress(hKernel32, "CreateActCtxA");
93 pActivateActCtx = (void*)GetProcAddress(hKernel32, "ActivateActCtx");
94 if (!(pCreateActCtxA && pActivateActCtx))
96 win_skip("Activation contexts unsupported. No version 6 tests possible.\n");
97 return FALSE;
100 /* create manifest */
101 file = CreateFileA( manifest_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL );
102 if (file != INVALID_HANDLE_VALUE)
104 ret = (WriteFile( file, manifest, sizeof(manifest)-1, &written, NULL ) &&
105 written == sizeof(manifest)-1);
106 CloseHandle( file );
107 if (!ret)
109 DeleteFileA( manifest_name );
110 skip("Failed to fill manifest file. Skipping comctl32 V6 tests.\n");
111 return FALSE;
113 else
114 trace("created %s\n", manifest_name);
116 else
118 skip("Failed to create manifest file. Skipping comctl32 V6 tests.\n");
119 return FALSE;
122 memset(&ctx, 0, sizeof(ctx));
123 ctx.cbSize = sizeof(ctx);
124 ctx.lpSource = manifest_name;
126 *hCtx = pCreateActCtxA(&ctx);
127 ok(*hCtx != 0, "Expected context handle\n");
129 ret = pActivateActCtx(*hCtx, pcookie);
130 expect(TRUE, ret);
132 if (!ret)
134 win_skip("A problem during context activation occurred.\n");
135 DeleteFileA(manifest_name);
138 return ret;
141 #undef expect
142 #undef ARCH