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

Side by Side Diff: chrome/installer/util/set_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
« no previous file with comments | « chrome/installer/util/set_reg_value_work_item.cc ('k') | chrome/installer/util/shell_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/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;
16
15 namespace { 17 namespace {
16 wchar_t test_root[] = L"TempTemp"; 18
17 wchar_t data_str_1[] = L"data_111"; 19 wchar_t test_root[] = L"TempTemp";
18 wchar_t data_str_2[] = L"data_222"; 20 wchar_t data_str_1[] = L"data_111";
19 DWORD dword1 = 0; 21 wchar_t data_str_2[] = L"data_222";
20 DWORD dword2 = 1; 22 DWORD dword1 = 0;
21 class SetRegValueWorkItemTest : public testing::Test { 23 DWORD dword2 = 1;
22 protected: 24 class SetRegValueWorkItemTest : public testing::Test {
23 virtual void SetUp() { 25 protected:
24 // Create a temporary key for testing 26 virtual void SetUp() {
25 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); 27 // Create a temporary key for testing
26 key.DeleteKey(test_root); 28 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS);
27 ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ)); 29 key.DeleteKey(test_root);
28 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ)); 30 ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, test_root, KEY_READ));
29 } 31 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, test_root, KEY_READ));
30 virtual void TearDown() { 32 }
31 logging::CloseLogFile(); 33 virtual void TearDown() {
32 // Clean up the temporary key 34 logging::CloseLogFile();
33 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); 35 // Clean up the temporary key
34 ASSERT_TRUE(key.DeleteKey(test_root)); 36 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS);
35 } 37 ASSERT_TRUE(key.DeleteKey(test_root));
36 }; 38 }
37 }; 39 };
38 40
41 } // namespace
42
39 // Write a new value without overwrite flag. The value should be set. 43 // Write a new value without overwrite flag. The value should be set.
40 TEST_F(SetRegValueWorkItemTest, WriteNewNonOverwrite) { 44 TEST_F(SetRegValueWorkItemTest, WriteNewNonOverwrite) {
41 RegKey key; 45 RegKey key;
42 46
43 std::wstring parent_key(test_root); 47 std::wstring parent_key(test_root);
44 file_util::AppendToPath(&parent_key, L"WriteNewNonOverwrite"); 48 file_util::AppendToPath(&parent_key, L"WriteNewNonOverwrite");
45 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, parent_key.c_str(), KEY_READ)); 49 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, parent_key.c_str(), KEY_READ));
46 50
47 std::wstring name_str(L"name_str"); 51 std::wstring name_str(L"name_str");
48 std::wstring data_str(data_str_1); 52 std::wstring data_str(data_str_1);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 std::wstring data(data_str_1); 221 std::wstring data(data_str_1);
218 scoped_ptr<SetRegValueWorkItem> work_item( 222 scoped_ptr<SetRegValueWorkItem> work_item(
219 WorkItem::CreateSetRegValueWorkItem(HKEY_CURRENT_USER, parent_key, 223 WorkItem::CreateSetRegValueWorkItem(HKEY_CURRENT_USER, parent_key,
220 name, data, false)); 224 name, data, false));
221 EXPECT_FALSE(work_item->Do()); 225 EXPECT_FALSE(work_item->Do());
222 226
223 work_item.reset(WorkItem::CreateSetRegValueWorkItem(HKEY_CURRENT_USER, 227 work_item.reset(WorkItem::CreateSetRegValueWorkItem(HKEY_CURRENT_USER,
224 parent_key, name, dword1, false)); 228 parent_key, name, dword1, false));
225 EXPECT_FALSE(work_item->Do()); 229 EXPECT_FALSE(work_item->Do());
226 } 230 }
OLDNEW
« no previous file with comments | « chrome/installer/util/set_reg_value_work_item.cc ('k') | chrome/installer/util/shell_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698