[KERNEL32_APITEST] Improve SetComputerNameExW test a bit (#1580)
[reactos.git] / modules / 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 #include "precomp.h"
22
23 START_TEST(DefaultActCtx)
24 {
25 DWORD buffer[256];
26 BOOL res;
27 PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION details = (PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION)buffer;
28 PACTIVATION_CONTEXT_DETAILED_INFORMATION info = (PACTIVATION_CONTEXT_DETAILED_INFORMATION)buffer;
29 HANDLE h;
30 DWORD i;
31 ACTCTX_SECTION_KEYED_DATA KeyedData = { 0 };
32
33 res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
34 NULL,
35 NULL,
36 ActivationContextDetailedInformation,
37 &buffer,
38 sizeof(buffer),
39 NULL);
40 ok(res == TRUE, "Expected success\n");
41 if(res)
42 {
43 ok(info->lpRootManifestPath == NULL, "Expected null lpRootManifestPath, got %S\n", info->lpRootManifestPath);
44 ok(info->lpRootConfigurationPath == NULL, "Expected null lpRootConfigurationPath, got %S\n", info->lpRootConfigurationPath);
45 ok(info->lpAppDirPath == NULL, "Expected null lpAppDirPath, got %S\n", info->lpAppDirPath);
46 ok(info->ulAssemblyCount == 0, "Expected 0 assemblies\n");
47 }
48 else
49 {
50 skip("ActivationContextDetailedInformation failed\n");
51 }
52
53
54 i = 0;
55 res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
56 NULL,
57 &i,
58 AssemblyDetailedInformationInActivationContext,
59 &buffer,
60 sizeof(buffer),
61 NULL);
62 ok(res == TRUE, "Expected success\n");
63 if (res)
64 {
65 ok(details->lpAssemblyEncodedAssemblyIdentity == NULL, "Expected null lpAssemblyEncodedAssemblyIdentity, got %S\n", details->lpAssemblyEncodedAssemblyIdentity);
66 ok(details->lpAssemblyManifestPath == NULL, "Expected null lpAssemblyManifestPath, got %S\n", details->lpAssemblyManifestPath);
67 ok(details->lpAssemblyPolicyPath == NULL, "Expected null lpAssemblyPolicyPath, got %S\n", details->lpAssemblyPolicyPath);
68 ok(details->lpAssemblyDirectoryName == NULL, "Expected null lpAssemblyDirectoryName, got %S\n", details->lpAssemblyDirectoryName);
69 }
70 else
71 {
72 skip("AssemblyDetailedInformationInActivationContext failed\n");
73 }
74
75 i = 1;
76 res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX,
77 NULL,
78 &i,
79 AssemblyDetailedInformationInActivationContext,
80 &buffer,
81 sizeof(buffer),
82 NULL);
83 ok(res == TRUE, "Expected success\n"); /* This is FALSE in win10 */
84 if (res)
85 {
86 ok(details->lpAssemblyEncodedAssemblyIdentity == NULL, "Expected null lpAssemblyEncodedAssemblyIdentity, got %S\n", details->lpAssemblyEncodedAssemblyIdentity);
87 ok(details->lpAssemblyManifestPath == NULL, "Expected null lpAssemblyManifestPath, got %S\n", details->lpAssemblyManifestPath);
88 ok(details->lpAssemblyPolicyPath == NULL, "Expected null lpAssemblyPolicyPath, got %S\n", details->lpAssemblyPolicyPath);
89 ok(details->lpAssemblyDirectoryName == NULL, "Expected null lpAssemblyDirectoryName, got %S\n", details->lpAssemblyDirectoryName);
90 }
91 else
92 {
93 skip("AssemblyDetailedInformationInActivationContext failed\n");
94 }
95
96 res = GetCurrentActCtx (&h);
97 ok(res == TRUE, "Expected success\n");
98 ok(h == NULL, "Expected null current context\n");
99
100 KeyedData.cbSize = sizeof(KeyedData);
101 res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
102 NULL,
103 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
104 L"Microsoft.Windows.SysyemCompatible",
105 &KeyedData);
106 ok(res == FALSE, "Expected failure\n");
107
108 KeyedData.cbSize = sizeof(KeyedData);
109 res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
110 NULL,
111 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
112 L"System Default Context",
113 &KeyedData);
114 ok(res == FALSE, "Expected failure\n");
115
116 KeyedData.cbSize = sizeof(KeyedData);
117 res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
118 NULL,
119 ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
120 L"Microsoft.Windows.Common-Controls",
121 &KeyedData);
122 ok(res == TRUE, "Expected success\n");
123 if (res)
124 {
125 ok(KeyedData.hActCtx == NULL, "Expected null handle for common control context\n");
126 ok(KeyedData.ulAssemblyRosterIndex != 0, "%lu\n", KeyedData.ulAssemblyRosterIndex);
127 }
128 else
129 {
130 skip("ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION failed\n");
131 }
132
133 }