OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
11 #include "chrome/installer/util/set_reg_value_work_item.h" | 11 #include "chrome/installer/util/set_reg_value_work_item.h" |
12 #include "chrome/installer/util/work_item.h" | 12 #include "chrome/installer/util/work_item.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using base::win::RegKey; | 15 using base::win::RegKey; |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const wchar_t kTestRoot[] = L"TempTemp"; | 19 const wchar_t kTestRoot[] = L"TempTemp"; |
20 const wchar_t kDataStr1[] = L"data_111"; | 20 const wchar_t kDataStr1[] = L"data_111"; |
21 const wchar_t kDataStr2[] = L"data_222"; | 21 const wchar_t kDataStr2[] = L"data_222"; |
22 const wchar_t kNameStr[] = L"name_str"; | 22 const wchar_t kNameStr[] = L"name_str"; |
23 const wchar_t kNameDword[] = L"name_dword"; | 23 const wchar_t kNameDword[] = L"name_dword"; |
24 | 24 |
25 const DWORD dword1 = 0; | 25 const DWORD dword1 = 0; |
26 const DWORD dword2 = 1; | 26 const DWORD dword2 = 1; |
27 | 27 |
28 class SetRegValueWorkItemTest : public testing::Test { | 28 class SetRegValueWorkItemTest : public testing::Test { |
29 protected: | 29 protected: |
30 virtual void SetUp() { | 30 void SetUp() override { |
31 // Create a temporary key for testing | 31 // Create a temporary key for testing |
32 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); | 32 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); |
33 key.DeleteKey(kTestRoot); | 33 key.DeleteKey(kTestRoot); |
34 ASSERT_NE(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, kTestRoot, KEY_READ)); | 34 ASSERT_NE(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, kTestRoot, KEY_READ)); |
35 ASSERT_EQ(ERROR_SUCCESS, | 35 ASSERT_EQ(ERROR_SUCCESS, |
36 key.Create(HKEY_CURRENT_USER, kTestRoot, KEY_READ)); | 36 key.Create(HKEY_CURRENT_USER, kTestRoot, KEY_READ)); |
37 } | 37 } |
38 virtual void TearDown() { | 38 void TearDown() override { |
39 logging::CloseLogFile(); | 39 logging::CloseLogFile(); |
40 // Clean up the temporary key | 40 // Clean up the temporary key |
41 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); | 41 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); |
42 ASSERT_EQ(ERROR_SUCCESS, key.DeleteKey(kTestRoot)); | 42 ASSERT_EQ(ERROR_SUCCESS, key.DeleteKey(kTestRoot)); |
43 } | 43 } |
44 }; | 44 }; |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 // Write a new value without overwrite flag. The value should be set. | 48 // Write a new value without overwrite flag. The value should be set. |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 EXPECT_FALSE(work_item->Do()); | 301 EXPECT_FALSE(work_item->Do()); |
302 | 302 |
303 work_item.reset(WorkItem::CreateSetRegValueWorkItem(HKEY_CURRENT_USER, | 303 work_item.reset(WorkItem::CreateSetRegValueWorkItem(HKEY_CURRENT_USER, |
304 parent_key, | 304 parent_key, |
305 WorkItem::kWow64Default, | 305 WorkItem::kWow64Default, |
306 name, | 306 name, |
307 dword1, | 307 dword1, |
308 false)); | 308 false)); |
309 EXPECT_FALSE(work_item->Do()); | 309 EXPECT_FALSE(work_item->Do()); |
310 } | 310 } |
OLD | NEW |