Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/installer/util/delete_reg_value_work_item_unittest.cc

Issue 3836005: Move pe_image and registry from base to base/win and use the namespace. It re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/registry.h"
9 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/win/registry.h"
11 #include "chrome/installer/util/delete_reg_value_work_item.h" 11 #include "chrome/installer/util/delete_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;
16
15 namespace { 17 namespace {
16 wchar_t test_root[] = L"DeleteRegValueWorkItemTest"; 18
17 class DeleteRegValueWorkItemTest : public testing::Test { 19 wchar_t test_root[] = L"DeleteRegValueWorkItemTest";
18 protected: 20
19 virtual void SetUp() { 21 class DeleteRegValueWorkItemTest : public testing::Test {
20 // Create a temporary key for testing 22 protected:
21 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); 23 virtual void SetUp() {
22 key.DeleteKey(test_root); 24 // Create a temporary key for testing
23 ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); 25 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS);
24 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); 26 key.DeleteKey(test_root);
25 } 27 ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ));
26 virtual void TearDown() { 28 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ));
27 logging::CloseLogFile(); 29 }
28 // Clean up the temporary key 30 virtual void TearDown() {
29 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); 31 logging::CloseLogFile();
30 ASSERT_TRUE(key.DeleteKey(test_root)); 32 // Clean up the temporary key
31 } 33 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS);
32 }; 34 ASSERT_TRUE(key.DeleteKey(test_root));
35 }
33 }; 36 };
34 37
38 } // namespace
39
35 // Delete a value. The value should get deleted after Do() and should be 40 // Delete a value. The value should get deleted after Do() and should be
36 // recreated after Rollback(). 41 // recreated after Rollback().
37 TEST_F(DeleteRegValueWorkItemTest, DeleteExistingValue) { 42 TEST_F(DeleteRegValueWorkItemTest, DeleteExistingValue) {
38 RegKey key; 43 RegKey key;
39 std::wstring parent_key(test_root); 44 std::wstring parent_key(test_root);
40 file_util::AppendToPath(&parent_key, L"WriteNew"); 45 file_util::AppendToPath(&parent_key, L"WriteNew");
41 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, parent_key.c_str(), 46 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, parent_key.c_str(),
42 KEY_READ | KEY_WRITE)); 47 KEY_READ | KEY_WRITE));
43 std::wstring name_str(L"name_str"); 48 std::wstring name_str(L"name_str");
44 std::wstring data_str(L"data_111"); 49 std::wstring data_str(L"data_111");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 100
96 EXPECT_FALSE(key.ValueExists(name_str.c_str())); 101 EXPECT_FALSE(key.ValueExists(name_str.c_str()));
97 EXPECT_FALSE(key.ValueExists(name_dword.c_str())); 102 EXPECT_FALSE(key.ValueExists(name_dword.c_str()));
98 103
99 work_item1->Rollback(); 104 work_item1->Rollback();
100 work_item2->Rollback(); 105 work_item2->Rollback();
101 106
102 EXPECT_FALSE(key.ValueExists(name_str.c_str())); 107 EXPECT_FALSE(key.ValueExists(name_str.c_str()));
103 EXPECT_FALSE(key.ValueExists(name_dword.c_str())); 108 EXPECT_FALSE(key.ValueExists(name_dword.c_str()));
104 } 109 }
OLDNEW
« no previous file with comments | « chrome/installer/util/delete_reg_value_work_item.cc ('k') | chrome/installer/util/google_chrome_distribution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698