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

Side by Side Diff: base/test/test_reg_util_win_unittest.cc

Issue 93903011: Remove 'using base::string16;' from base/strings/string16.h and remove temporary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/test_reg_util_win.h" 9 #include "base/test/test_reg_util_win.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 19 matching lines...) Expand all
30 base::win::RegKey key(HKEY_CURRENT_USER); 30 base::win::RegKey key(HKEY_CURRENT_USER);
31 key.DeleteKey(fake_test_key_root_.c_str()); 31 key.DeleteKey(fake_test_key_root_.c_str());
32 key.DeleteKey(kTestKeyPath); 32 key.DeleteKey(kTestKeyPath);
33 } 33 }
34 34
35 virtual ~RegistryOverrideManagerTest() { 35 virtual ~RegistryOverrideManagerTest() {
36 base::win::RegKey key(HKEY_CURRENT_USER); 36 base::win::RegKey key(HKEY_CURRENT_USER);
37 key.DeleteKey(fake_test_key_root_.c_str()); 37 key.DeleteKey(fake_test_key_root_.c_str());
38 } 38 }
39 39
40 void AssertKeyExists(const string16& key_path) { 40 void AssertKeyExists(const base::string16& key_path) {
41 base::win::RegKey key; 41 base::win::RegKey key;
42 ASSERT_EQ(ERROR_SUCCESS, 42 ASSERT_EQ(ERROR_SUCCESS,
43 key.Open(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ)) 43 key.Open(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ))
44 << key_path << " does not exist."; 44 << key_path << " does not exist.";
45 } 45 }
46 46
47 void AssertKeyAbsent(const string16& key_path) { 47 void AssertKeyAbsent(const base::string16& key_path) {
48 base::win::RegKey key; 48 base::win::RegKey key;
49 ASSERT_NE(ERROR_SUCCESS, 49 ASSERT_NE(ERROR_SUCCESS,
50 key.Open(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ)) 50 key.Open(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ))
51 << key_path << " exists but it should not."; 51 << key_path << " exists but it should not.";
52 } 52 }
53 53
54 void CreateKey(const string16& key_path) { 54 void CreateKey(const base::string16& key_path) {
55 base::win::RegKey key; 55 base::win::RegKey key;
56 EXPECT_EQ(ERROR_SUCCESS, 56 EXPECT_EQ(ERROR_SUCCESS,
57 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS)); 57 key.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS));
58 } 58 }
59 59
60 string16 FakeOverrideManagerPath(const base::Time& time) { 60 base::string16 FakeOverrideManagerPath(const base::Time& time) {
61 return fake_test_key_root_ + L"\\" + 61 return fake_test_key_root_ + L"\\" +
62 base::Int64ToString16(time.ToInternalValue()); 62 base::Int64ToString16(time.ToInternalValue());
63 } 63 }
64 64
65 void CreateManager(const base::Time& timestamp) { 65 void CreateManager(const base::Time& timestamp) {
66 manager_.reset(new RegistryOverrideManager(timestamp, fake_test_key_root_)); 66 manager_.reset(new RegistryOverrideManager(timestamp, fake_test_key_root_));
67 manager_->OverrideRegistry(HKEY_CURRENT_USER, L"override_manager_unittest"); 67 manager_->OverrideRegistry(HKEY_CURRENT_USER, L"override_manager_unittest");
68 } 68 }
69 69
70 string16 fake_test_key_root_; 70 base::string16 fake_test_key_root_;
71 scoped_ptr<RegistryOverrideManager> manager_; 71 scoped_ptr<RegistryOverrideManager> manager_;
72 }; 72 };
73 73
74 TEST_F(RegistryOverrideManagerTest, Basic) { 74 TEST_F(RegistryOverrideManagerTest, Basic) {
75 CreateManager(base::Time::Now()); 75 CreateManager(base::Time::Now());
76 76
77 base::win::RegKey create_key; 77 base::win::RegKey create_key;
78 EXPECT_EQ(ERROR_SUCCESS, 78 EXPECT_EQ(ERROR_SUCCESS,
79 create_key.Create(HKEY_CURRENT_USER, kTestKeyPath, KEY_ALL_ACCESS)); 79 create_key.Create(HKEY_CURRENT_USER, kTestKeyPath, KEY_ALL_ACCESS));
80 EXPECT_TRUE(create_key.Valid()); 80 EXPECT_TRUE(create_key.Valid());
(...skipping 13 matching lines...) Expand all
94 94
95 manager_.reset(); 95 manager_.reset();
96 96
97 AssertKeyAbsent(kTestKeyPath); 97 AssertKeyAbsent(kTestKeyPath);
98 } 98 }
99 99
100 TEST_F(RegistryOverrideManagerTest, DeleteStaleKeys) { 100 TEST_F(RegistryOverrideManagerTest, DeleteStaleKeys) {
101 base::Time::Exploded kTestTimeExploded = {2013, 11, 1, 4, 0, 0, 0, 0}; 101 base::Time::Exploded kTestTimeExploded = {2013, 11, 1, 4, 0, 0, 0, 0};
102 base::Time kTestTime = base::Time::FromUTCExploded(kTestTimeExploded); 102 base::Time kTestTime = base::Time::FromUTCExploded(kTestTimeExploded);
103 103
104 string16 path_garbage = fake_test_key_root_ + L"\\Blah"; 104 base::string16 path_garbage = fake_test_key_root_ + L"\\Blah";
105 string16 path_very_stale = 105 base::string16 path_very_stale =
106 FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromDays(100)); 106 FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromDays(100));
107 string16 path_stale = 107 base::string16 path_stale =
108 FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromDays(5)); 108 FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromDays(5));
109 string16 path_current = 109 base::string16 path_current =
110 FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromMinutes(1)); 110 FakeOverrideManagerPath(kTestTime - base::TimeDelta::FromMinutes(1));
111 string16 path_future = 111 base::string16 path_future =
112 FakeOverrideManagerPath(kTestTime + base::TimeDelta::FromMinutes(1)); 112 FakeOverrideManagerPath(kTestTime + base::TimeDelta::FromMinutes(1));
113 113
114 CreateKey(path_garbage); 114 CreateKey(path_garbage);
115 CreateKey(path_very_stale); 115 CreateKey(path_very_stale);
116 CreateKey(path_stale); 116 CreateKey(path_stale);
117 CreateKey(path_current); 117 CreateKey(path_current);
118 CreateKey(path_future); 118 CreateKey(path_future);
119 119
120 CreateManager(kTestTime); 120 CreateManager(kTestTime);
121 manager_.reset(); 121 manager_.reset();
122 122
123 AssertKeyAbsent(path_garbage); 123 AssertKeyAbsent(path_garbage);
124 AssertKeyAbsent(path_very_stale); 124 AssertKeyAbsent(path_very_stale);
125 AssertKeyAbsent(path_stale); 125 AssertKeyAbsent(path_stale);
126 AssertKeyExists(path_current); 126 AssertKeyExists(path_current);
127 AssertKeyExists(path_future); 127 AssertKeyExists(path_future);
128 } 128 }
129 129
130 } // namespace registry_util 130 } // namespace registry_util
OLDNEW
« no previous file with comments | « base/test/test_reg_util_win.cc ('k') | chrome/browser/autocomplete/history_url_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698