OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
10 #include "chrome/installer/util/registry_key_backup.h" | 10 #include "chrome/installer/util/registry_key_backup.h" |
11 #include "chrome/installer/util/registry_test_data.h" | 11 #include "chrome/installer/util/registry_test_data.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 class RegistryKeyBackupTest : public testing::Test { | 17 class RegistryKeyBackupTest : public testing::Test { |
18 protected: | 18 protected: |
19 static void TearDownTestCase() { | 19 static void TearDownTestCase() { |
20 logging::CloseLogFile(); | 20 logging::CloseLogFile(); |
21 } | 21 } |
22 | 22 |
23 virtual void SetUp() { | 23 void SetUp() override { |
24 ASSERT_TRUE(test_data_.Initialize(HKEY_CURRENT_USER, L"SOFTWARE\\TmpTmp")); | 24 ASSERT_TRUE(test_data_.Initialize(HKEY_CURRENT_USER, L"SOFTWARE\\TmpTmp")); |
25 destination_path_.assign(test_data_.base_path()).append(L"\\Destination"); | 25 destination_path_.assign(test_data_.base_path()).append(L"\\Destination"); |
26 } | 26 } |
27 | 27 |
28 RegistryTestData test_data_; | 28 RegistryTestData test_data_; |
29 std::wstring destination_path_; | 29 std::wstring destination_path_; |
30 }; | 30 }; |
31 | 31 |
32 // Test that writing an uninitialized backup does nothing. | 32 // Test that writing an uninitialized backup does nothing. |
33 TEST_F(RegistryKeyBackupTest, Uninitialized) { | 33 TEST_F(RegistryKeyBackupTest, Uninitialized) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Now make sure the one we started with is truly empty. | 87 // Now make sure the one we started with is truly empty. |
88 EXPECT_EQ(ERROR_SUCCESS, | 88 EXPECT_EQ(ERROR_SUCCESS, |
89 RegKey(test_data_.root_key(), L"", KEY_QUERY_VALUE) | 89 RegKey(test_data_.root_key(), L"", KEY_QUERY_VALUE) |
90 .DeleteKey(destination_path_.c_str())); | 90 .DeleteKey(destination_path_.c_str())); |
91 EXPECT_TRUE(backup.WriteTo(test_data_.root_key(), | 91 EXPECT_TRUE(backup.WriteTo(test_data_.root_key(), |
92 destination_path_.c_str(), | 92 destination_path_.c_str(), |
93 WorkItem::kWow64Default)); | 93 WorkItem::kWow64Default)); |
94 EXPECT_FALSE(RegKey(test_data_.root_key(), destination_path_.c_str(), | 94 EXPECT_FALSE(RegKey(test_data_.root_key(), destination_path_.c_str(), |
95 KEY_READ).Valid()); | 95 KEY_READ).Valid()); |
96 } | 96 } |
OLD | NEW |