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/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/test/test_reg_util_win.h" | 12 #include "base/test/test_reg_util_win.h" |
13 #include "base/win/registry.h" | 13 #include "base/win/registry.h" |
14 #include "chrome/installer/util/conditional_work_item_list.h" | 14 #include "chrome/installer/util/conditional_work_item_list.h" |
15 #include "chrome/installer/util/work_item.h" | 15 #include "chrome/installer/util/work_item.h" |
16 #include "chrome/installer/util/work_item_list.h" | 16 #include "chrome/installer/util/work_item_list.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using base::win::RegKey; | 19 using base::win::RegKey; |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 const wchar_t kTestRoot[] = L"ListList"; | 23 const wchar_t kTestRoot[] = L"ListList"; |
24 const wchar_t kDataStr[] = L"data_111"; | 24 const wchar_t kDataStr[] = L"data_111"; |
25 const wchar_t kName[] = L"name"; | 25 const wchar_t kName[] = L"name"; |
26 | 26 |
27 class WorkItemListTest : public testing::Test { | 27 class WorkItemListTest : public testing::Test { |
28 protected: | 28 protected: |
29 virtual void SetUp() { | 29 void SetUp() override { |
30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
31 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 31 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
32 } | 32 } |
33 | 33 |
34 virtual void TearDown() { | 34 void TearDown() override { logging::CloseLogFile(); } |
35 logging::CloseLogFile(); | |
36 } | |
37 | 35 |
38 base::ScopedTempDir temp_dir_; | 36 base::ScopedTempDir temp_dir_; |
39 registry_util::RegistryOverrideManager registry_override_manager_; | 37 registry_util::RegistryOverrideManager registry_override_manager_; |
40 }; | 38 }; |
41 | 39 |
42 } // namespace | 40 } // namespace |
43 | 41 |
44 // Execute a WorkItem list successfully and then rollback. | 42 // Execute a WorkItem list successfully and then rollback. |
45 TEST_F(WorkItemListTest, ExecutionSuccess) { | 43 TEST_F(WorkItemListTest, ExecutionSuccess) { |
46 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); | 44 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 276 |
279 work_item_list->Rollback(); | 277 work_item_list->Rollback(); |
280 | 278 |
281 // Verify everything is rolled back. | 279 // Verify everything is rolled back. |
282 // The value must have been deleted first in roll back otherwise the key | 280 // The value must have been deleted first in roll back otherwise the key |
283 // can not be deleted. | 281 // can not be deleted. |
284 EXPECT_NE(ERROR_SUCCESS, | 282 EXPECT_NE(ERROR_SUCCESS, |
285 key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); | 283 key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); |
286 EXPECT_FALSE(base::PathExists(top_dir_to_create)); | 284 EXPECT_FALSE(base::PathExists(top_dir_to_create)); |
287 } | 285 } |
OLD | NEW |