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

Side by Side Diff: chrome_elf/blacklist/test/blacklist_test.cc

Issue 1858493002: convert //chrome_elf to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory>
8
7 #include "base/environment.h" 9 #include "base/environment.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
10 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/path_service.h" 14 #include "base/path_service.h"
13 #include "base/scoped_native_library.h" 15 #include "base/scoped_native_library.h"
14 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
15 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str())); 111 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str()));
110 112
111 // The blocked dll was removed, so the number of blocked dlls should 113 // The blocked dll was removed, so the number of blocked dlls should
112 // return to what it originally was. 114 // return to what it originally was.
113 int num_blocked_dlls = 0; 115 int num_blocked_dlls = 0;
114 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); 116 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls);
115 EXPECT_EQ(num_initially_blocked_, num_blocked_dlls); 117 EXPECT_EQ(num_initially_blocked_, num_blocked_dlls);
116 } 118 }
117 } 119 }
118 120
119 scoped_ptr<base::win::RegKey> blacklist_registry_key_; 121 std::unique_ptr<base::win::RegKey> blacklist_registry_key_;
120 registry_util::RegistryOverrideManager override_manager_; 122 registry_util::RegistryOverrideManager override_manager_;
121 123
122 // The number of dlls initially blocked by the blacklist. 124 // The number of dlls initially blocked by the blacklist.
123 int num_initially_blocked_; 125 int num_initially_blocked_;
124 126
125 private: 127 private:
126 void SetUp() override { 128 void SetUp() override {
127 // Force an import from blacklist_test_main_dll. 129 // Force an import from blacklist_test_main_dll.
128 InitBlacklistTestDll(); 130 InitBlacklistTestDll();
129 blacklist_registry_key_.reset( 131 blacklist_registry_key_.reset(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 KEY_QUERY_VALUE | KEY_SET_VALUE); 261 KEY_QUERY_VALUE | KEY_SET_VALUE);
260 for (size_t i = 0; i < arraysize(test_data); ++i) { 262 for (size_t i = 0; i < arraysize(test_data); ++i) {
261 finch_blacklist_registry_key.WriteValue(test_data[i].dll_name, 263 finch_blacklist_registry_key.WriteValue(test_data[i].dll_name,
262 test_data[i].dll_name); 264 test_data[i].dll_name);
263 } 265 }
264 266
265 TestDll_AddDllsFromRegistryToBlacklist(); 267 TestDll_AddDllsFromRegistryToBlacklist();
266 CheckBlacklistedDllsNotLoaded(); 268 CheckBlacklistedDllsNotLoaded();
267 } 269 }
268 270
269 void TestResetBeacon(scoped_ptr<base::win::RegKey>& key, 271 void TestResetBeacon(std::unique_ptr<base::win::RegKey>& key,
270 DWORD input_state, 272 DWORD input_state,
271 DWORD expected_output_state) { 273 DWORD expected_output_state) {
272 LONG result = key->WriteValue(blacklist::kBeaconState, input_state); 274 LONG result = key->WriteValue(blacklist::kBeaconState, input_state);
273 EXPECT_EQ(ERROR_SUCCESS, result); 275 EXPECT_EQ(ERROR_SUCCESS, result);
274 276
275 EXPECT_TRUE(blacklist::ResetBeacon()); 277 EXPECT_TRUE(blacklist::ResetBeacon());
276 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX; 278 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX;
277 result = key->ReadValueDW(blacklist::kBeaconState, &blacklist_state); 279 result = key->ReadValueDW(blacklist::kBeaconState, &blacklist_state);
278 EXPECT_EQ(ERROR_SUCCESS, result); 280 EXPECT_EQ(ERROR_SUCCESS, result);
279 EXPECT_EQ(expected_output_state, blacklist_state); 281 EXPECT_EQ(expected_output_state, blacklist_state);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 &blacklist_state); 341 &blacklist_state);
340 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING); 342 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING);
341 343
342 DWORD attempt_count = blacklist::kBeaconMaxAttempts; 344 DWORD attempt_count = blacklist::kBeaconMaxAttempts;
343 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, 345 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount,
344 &attempt_count); 346 &attempt_count);
345 EXPECT_EQ(static_cast<DWORD>(0), attempt_count); 347 EXPECT_EQ(static_cast<DWORD>(0), attempt_count);
346 } 348 }
347 349
348 } // namespace 350 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698