[KERNEL32_APITEST] Add test to show that we should not spoil TEB->StaticUnicodeString...
[reactos.git] / rostests / apitests / kernel32 / DefaultActCtx.c
1 /*
2 * Test for the default activation context that is active in every process.
3 *
4 * Copyright 2017 Giannis Adamopoulos
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #include "wine/test.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
29
30 START_TEST(DefaultActCtx)
31 {
32 DWORD buffer[256];
33 BOOL res;
34 PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION details = (PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION)buffer;
35 PACTIVATION_CONTEXT_DETAILED_INFORMATION info = (PACTIVATION_CONTEXT_DETAILED_INFORMATION)buffer;
36 HANDLE h;
37 DWORD i;
38 ACTCTX_SECTION_KEYED_DATA KeyedData = { 0 };
39
40 res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
41 NULL,
42 NULL,
43 ActivationContextDetailedInformation,
44 &buffer,
45 sizeof(buffer),
46 NULL);
47 ok(res == TRUE, "Expected success\n");
48 if(res)
49 {
50 ok(info->lpRootManifestPath == NULL, "Expected null lpRootManifestPath, got %S\n", info->lpRootManifestPath);
51 ok(info->lpRootConfigurationPath == NULL, "Expected null lpRootConfigurationPath, got %S\n", info->lpRootConfigurationPath);
52 ok(info->lpAppDirPath == NULL, "Expected null lpAppDirPath, got %S\n", info->lpAppDirPath);
53 ok(info->ulAssemblyCount == 0, "Expected 0 assemblies\n");
54 }
55 else
56 {
57 skip("ActivationContextDetailedInformation failed\n");
58 }
59
60
61 i = 0;
62 res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
63 NULL,
64 &i,
65 AssemblyDetailedInformationInActivationContext,
66 &buffer,
67 sizeof(buffer),
68 NULL);
69 ok(res == TRUE, "Expected success\n");
70 if (res)
71 {
72 ok(details->lpAssemblyEncodedAssemblyIdentity == NULL, "Expected null lpAssemblyEncodedAssemblyIdentity, got %S\n", details->lpAssemblyEncodedAssemblyIdentity);
73 ok(details->lpAssemblyManifestPath == NULL, "Expected null lpAssemblyManifestPath, got %S\n", details->lpAssemblyManifestPath);
74 ok(details->lpAssemblyPolicyPath == NULL, "Expected null lpAssemblyPolicyPath, got %S\n", details->lpAssemblyPolicyPath);
75 ok(details->lpAssemblyDirectoryName == NULL, "Expected null lpAssemblyDirectoryName, got %S\n", details->lpAssemblyDirectoryName);
76 }
77 else
78 {
79 skip("AssemblyDetailedInformationInActivationContext failed\n");
80 }
81
82 i = 1;
83 res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
84 NULL,
85 &i,
86 AssemblyDetailedInformationInActivationContext,
87 &buffer,
88 sizeof(buffer),
89 NULL);
90 ok(res == TRUE, "Expected success\n"); /* This is FALSE in win10 */
91 if (res)
92 {
93 ok(details->lpAssemblyEncodedAssemblyIdentity == NULL, "Expected null lpAssemblyEncodedAssemblyIdentity, got %S\n", details->lpAssemblyEncodedAssemblyIdentity);
94 ok(details->lpAssemblyManifestPath == NULL, "Expected null lpAssemblyManifestPath, got %S\n", details->lpAssemblyManifestPath);
95 ok(details->lpAssemblyPolicyPath == NULL, "Expected null lpAssemblyPolicyPath, got %S\n", details->lpAssemblyPolicyPath);
96 ok(details->lpAssemblyDirectoryName == NULL, "Expected null lpAssemblyDirectoryName, got %S\n", details->lpAssemblyDirectoryName);
97 }
98 else
99 {
100 skip("AssemblyDetailedInformationInActivationContext failed\n");
101 }
102
103 res = GetCurrentActCtx (&h);
104 ok(res == TRUE, "Expected success\n");
105 ok(h == NULL, "Expected null current context\n");
106
107 KeyedData.cbSize = sizeof(KeyedData);
108 res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
109 NULL,
110 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
111 L"Microsoft.Windows.SysyemCompatible",
112 &KeyedData);
113 ok(res == FALSE, "Expected failure\n");
114
115 KeyedData.cbSize = sizeof(KeyedData);
116 res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
117 NULL,
118 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
119 L"System Default Context",
120 &KeyedData);
121 ok(res == FALSE, "Expected failure\n");
122
123 KeyedData.cbSize = sizeof(KeyedData);
124 res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
125 NULL,
126 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
127 L"Microsoft.Windows.Common-Controls",
128 &KeyedData);
129 ok(res == TRUE, "Expected success\n");
130 if (res)
131 {
132 ok(KeyedData.hActCtx == NULL, "Expected null handle for common control context\n");
133 ok(KeyedData.ulAssemblyRosterIndex != 0, "%lu\n", KeyedData.ulAssemblyRosterIndex);
134 }
135 else
136 {
137 skip("ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION failed\n");
138 }
139
140 }