OLD | NEW |
| (Empty) |
1 // Copyright 2008-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #include <shlobj.h> | |
17 #include "omaha/base/reg_key.h" | |
18 #include "omaha/base/vistautil.h" | |
19 #include "omaha/testing/unit_test.h" | |
20 | |
21 namespace omaha { | |
22 | |
23 namespace vista_util { | |
24 | |
25 TEST(VistaUtilTest, IsUserAdmin) { | |
26 bool is_admin = !!::IsUserAnAdmin(); | |
27 EXPECT_EQ(is_admin, IsUserAdmin()); | |
28 } | |
29 | |
30 // Tests the code returns true if Vista or later. | |
31 TEST(VistaUtilTest, IsUACMaybeOn) { | |
32 if (!IsVistaOrLater()) { | |
33 std::wcout << _T("\tSkipping test because not running on Vista or later.") | |
34 << std::endl; | |
35 return; | |
36 } | |
37 | |
38 bool is_uac_maybe_on = false; | |
39 | |
40 bool is_split_token = false; | |
41 if (SUCCEEDED(IsUserRunningSplitToken(&is_split_token)) && is_split_token) { | |
42 is_uac_maybe_on = true; | |
43 } else { | |
44 const TCHAR* key_name = _T("HKLM\\SOFTWARE\\Microsoft\\Windows\\") | |
45 _T("CurrentVersion\\Policies\\System"); | |
46 | |
47 DWORD enable_lua = 0; | |
48 is_uac_maybe_on = | |
49 FAILED(RegKey::GetValue(key_name, _T("EnableLUA"), &enable_lua)) || | |
50 enable_lua; | |
51 } | |
52 | |
53 EXPECT_EQ(is_uac_maybe_on, IsUACMaybeOn()); | |
54 } | |
55 | |
56 TEST(VistaUtilTest, IsElevatedWithUACMaybeOn) { | |
57 EXPECT_EQ(IsUserAdmin() && IsVistaOrLater() && IsUACMaybeOn(), | |
58 IsElevatedWithUACMaybeOn()); | |
59 } | |
60 | |
61 } // namespace vista_util | |
62 | |
63 } // namespace omaha | |
64 | |
OLD | NEW |