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

Side by Side Diff: chrome/browser/profile_resetter/profile_resetter_unittest.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/profile_resetter/profile_resetter.h" 5 #include "chrome/browser/profile_resetter/profile_resetter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility>
8 9
9 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/test/scoped_path_override.h" 15 #include "base/test/scoped_path_override.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
17 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 EXPECT_CALL(*this, Callback()); 257 EXPECT_CALL(*this, Callback());
257 scoped_ptr<BrandcodeConfigFetcher> fetcher( 258 scoped_ptr<BrandcodeConfigFetcher> fetcher(
258 new BrandcodeConfigFetcher(base::Bind(&ConfigParserTest::Callback, 259 new BrandcodeConfigFetcher(base::Bind(&ConfigParserTest::Callback,
259 base::Unretained(this)), 260 base::Unretained(this)),
260 url, 261 url,
261 "ABCD")); 262 "ABCD"));
262 base::MessageLoop::current()->RunUntilIdle(); 263 base::MessageLoop::current()->RunUntilIdle();
263 EXPECT_FALSE(fetcher->IsActive()); 264 EXPECT_FALSE(fetcher->IsActive());
264 // Look for the brand code in the request. 265 // Look for the brand code in the request.
265 EXPECT_NE(std::string::npos, request_listener_.upload_data.find("ABCD")); 266 EXPECT_NE(std::string::npos, request_listener_.upload_data.find("ABCD"));
266 return fetcher.Pass(); 267 return fetcher;
267 } 268 }
268 269
269 scoped_ptr<net::FakeURLFetcher> ConfigParserTest::CreateFakeURLFetcher( 270 scoped_ptr<net::FakeURLFetcher> ConfigParserTest::CreateFakeURLFetcher(
270 const GURL& url, 271 const GURL& url,
271 net::URLFetcherDelegate* fetcher_delegate, 272 net::URLFetcherDelegate* fetcher_delegate,
272 const std::string& response_data, 273 const std::string& response_data,
273 net::HttpStatusCode response_code, 274 net::HttpStatusCode response_code,
274 net::URLRequestStatus::Status status) { 275 net::URLRequestStatus::Status status) {
275 request_listener_.real_delegate = fetcher_delegate; 276 request_listener_.real_delegate = fetcher_delegate;
276 scoped_ptr<net::FakeURLFetcher> fetcher( 277 scoped_ptr<net::FakeURLFetcher> fetcher(
277 new net::FakeURLFetcher( 278 new net::FakeURLFetcher(
278 url, &request_listener_, response_data, response_code, status)); 279 url, &request_listener_, response_data, response_code, status));
279 scoped_refptr<net::HttpResponseHeaders> download_headers = 280 scoped_refptr<net::HttpResponseHeaders> download_headers =
280 new net::HttpResponseHeaders(""); 281 new net::HttpResponseHeaders("");
281 download_headers->AddHeader("Content-Type: text/xml"); 282 download_headers->AddHeader("Content-Type: text/xml");
282 fetcher->set_response_headers(download_headers); 283 fetcher->set_response_headers(download_headers);
283 return fetcher.Pass(); 284 return fetcher;
284 } 285 }
285 286
286 // A helper class to create/delete/check a Chrome desktop shortcut on Windows. 287 // A helper class to create/delete/check a Chrome desktop shortcut on Windows.
287 class ShortcutHandler { 288 class ShortcutHandler {
288 public: 289 public:
289 ShortcutHandler(); 290 ShortcutHandler();
290 ~ShortcutHandler(); 291 ~ShortcutHandler();
291 292
292 static bool IsSupported(); 293 static bool IsSupported();
293 ShortcutCommand CreateWithArguments(const base::string16& name, 294 ShortcutCommand CreateWithArguments(const base::string16& name,
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 report->enabled_extensions_size() > 0); 1031 report->enabled_extensions_size() > 0);
1031 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::SHORTCUTS) && 1032 EXPECT_EQ(!!(field_mask & ResettableSettingsSnapshot::SHORTCUTS) &&
1032 ShortcutHandler::IsSupported(), 1033 ShortcutHandler::IsSupported(),
1033 report->shortcuts_size() > 0); 1034 report->shortcuts_size() > 0);
1034 } 1035 }
1035 } 1036 }
1036 1037
1037 struct FeedbackCapture { 1038 struct FeedbackCapture {
1038 void SetFeedback(Profile* profile, 1039 void SetFeedback(Profile* profile,
1039 const ResettableSettingsSnapshot& snapshot) { 1040 const ResettableSettingsSnapshot& snapshot) {
1040 list_ = GetReadableFeedbackForSnapshot(profile, snapshot).Pass(); 1041 list_ = GetReadableFeedbackForSnapshot(profile, snapshot);
1041 OnUpdatedList(); 1042 OnUpdatedList();
1042 } 1043 }
1043 1044
1044 void Fail() { 1045 void Fail() {
1045 ADD_FAILURE() << "This method shouldn't be called."; 1046 ADD_FAILURE() << "This method shouldn't be called.";
1046 } 1047 }
1047 1048
1048 MOCK_METHOD0(OnUpdatedList, void(void)); 1049 MOCK_METHOD0(OnUpdatedList, void(void));
1049 1050
1050 scoped_ptr<base::ListValue> list_; 1051 scoped_ptr<base::ListValue> list_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 ResettableSettingsSnapshot snapshot(profile()); 1084 ResettableSettingsSnapshot snapshot(profile());
1084 snapshot.RequestShortcuts(base::Bind(&FeedbackCapture::SetFeedback, 1085 snapshot.RequestShortcuts(base::Bind(&FeedbackCapture::SetFeedback,
1085 base::Unretained(&capture), 1086 base::Unretained(&capture),
1086 profile(), 1087 profile(),
1087 base::ConstRef(snapshot))); 1088 base::ConstRef(snapshot)));
1088 // Let it enumerate shortcuts on the FILE thread. 1089 // Let it enumerate shortcuts on the FILE thread.
1089 base::MessageLoop::current()->RunUntilIdle(); 1090 base::MessageLoop::current()->RunUntilIdle();
1090 ::testing::Mock::VerifyAndClearExpectations(&capture); 1091 ::testing::Mock::VerifyAndClearExpectations(&capture);
1091 // The homepage and the startup page are in punycode. They are unreadable. 1092 // The homepage and the startup page are in punycode. They are unreadable.
1092 // Trying to find the extension name. 1093 // Trying to find the extension name.
1093 scoped_ptr<base::ListValue> list = capture.list_.Pass(); 1094 scoped_ptr<base::ListValue> list = std::move(capture.list_);
1094 ASSERT_TRUE(list); 1095 ASSERT_TRUE(list);
1095 bool checked_extensions = false; 1096 bool checked_extensions = false;
1096 bool checked_shortcuts = false; 1097 bool checked_shortcuts = false;
1097 for (size_t i = 0; i < list->GetSize(); ++i) { 1098 for (size_t i = 0; i < list->GetSize(); ++i) {
1098 base::DictionaryValue* dict = NULL; 1099 base::DictionaryValue* dict = NULL;
1099 ASSERT_TRUE(list->GetDictionary(i, &dict)); 1100 ASSERT_TRUE(list->GetDictionary(i, &dict));
1100 std::string value; 1101 std::string value;
1101 ASSERT_TRUE(dict->GetString("key", &value)); 1102 ASSERT_TRUE(dict->GetString("key", &value));
1102 if (value == "Extensions") { 1103 if (value == "Extensions") {
1103 base::string16 extensions; 1104 base::string16 extensions;
(...skipping 18 matching lines...) Expand all
1122 new ResettableSettingsSnapshot(profile())); 1123 new ResettableSettingsSnapshot(profile()));
1123 deleted_snapshot->RequestShortcuts(base::Bind(&FeedbackCapture::Fail, 1124 deleted_snapshot->RequestShortcuts(base::Bind(&FeedbackCapture::Fail,
1124 base::Unretained(&capture))); 1125 base::Unretained(&capture)));
1125 deleted_snapshot.reset(); 1126 deleted_snapshot.reset();
1126 // Running remaining tasks shouldn't trigger the callback to be called as 1127 // Running remaining tasks shouldn't trigger the callback to be called as
1127 // |deleted_snapshot| was deleted before it could run. 1128 // |deleted_snapshot| was deleted before it could run.
1128 base::MessageLoop::current()->RunUntilIdle(); 1129 base::MessageLoop::current()->RunUntilIdle();
1129 } 1130 }
1130 1131
1131 } // namespace 1132 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698