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

Side by Side Diff: ios/chrome/browser/web_resource/web_resource_util_unittest.cc

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/web_resource/web_resource_util.h" 5 #include "ios/chrome/browser/web_resource/web_resource_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 15 matching lines...) Expand all
26 return base::Bind(&WebResourceUtilTest::OnParseSuccess, 26 return base::Bind(&WebResourceUtilTest::OnParseSuccess,
27 base::Unretained(this)); 27 base::Unretained(this));
28 } 28 }
29 29
30 WebResourceService::ErrorCallback GetErrorCallback() { 30 WebResourceService::ErrorCallback GetErrorCallback() {
31 return base::Bind(&WebResourceUtilTest::OnParseError, 31 return base::Bind(&WebResourceUtilTest::OnParseError,
32 base::Unretained(this)); 32 base::Unretained(this));
33 } 33 }
34 34
35 // Called on success. 35 // Called on success.
36 void OnParseSuccess(scoped_ptr<base::Value> value) { 36 void OnParseSuccess(std::unique_ptr<base::Value> value) {
37 success_called_ = true; 37 success_called_ = true;
38 value_ = std::move(value); 38 value_ = std::move(value);
39 } 39 }
40 40
41 // Called on error. 41 // Called on error.
42 void OnParseError(const std::string& error) { 42 void OnParseError(const std::string& error) {
43 error_called_ = true; 43 error_called_ = true;
44 error_ = error; 44 error_ = error;
45 } 45 }
46 46
47 void FlushBackgroundTasks() { 47 void FlushBackgroundTasks() {
48 // The function is not synchronous, callbacks are not called before flushing 48 // The function is not synchronous, callbacks are not called before flushing
49 // the tasks. 49 // the tasks.
50 EXPECT_FALSE(success_called_); 50 EXPECT_FALSE(success_called_);
51 EXPECT_FALSE(error_called_); 51 EXPECT_FALSE(error_called_);
52 52
53 web::WebThread::GetBlockingPool()->FlushForTesting(); 53 web::WebThread::GetBlockingPool()->FlushForTesting();
54 loop_.RunUntilIdle(); 54 loop_.RunUntilIdle();
55 } 55 }
56 56
57 base::MessageLoop loop_; 57 base::MessageLoop loop_;
58 std::string error_; 58 std::string error_;
59 scoped_ptr<base::Value> value_; 59 std::unique_ptr<base::Value> value_;
60 bool error_called_; 60 bool error_called_;
61 bool success_called_; 61 bool success_called_;
62 }; 62 };
63 63
64 TEST_F(WebResourceUtilTest, Success) { 64 TEST_F(WebResourceUtilTest, Success) {
65 const std::string kExpectedKey("foo"); 65 const std::string kExpectedKey("foo");
66 const std::string kExpectedValue("bar"); 66 const std::string kExpectedValue("bar");
67 std::string json = base::StringPrintf("{\"%s\":\"%s\"}", kExpectedKey.c_str(), 67 std::string json = base::StringPrintf("{\"%s\":\"%s\"}", kExpectedKey.c_str(),
68 kExpectedValue.c_str()); 68 kExpectedValue.c_str());
69 GetIOSChromeParseJSONCallback().Run(json, GetSuccessCallback(), 69 GetIOSChromeParseJSONCallback().Run(json, GetSuccessCallback(),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 FlushBackgroundTasks(); 119 FlushBackgroundTasks();
120 120
121 // The error callback is called. 121 // The error callback is called.
122 EXPECT_TRUE(error_called_); 122 EXPECT_TRUE(error_called_);
123 EXPECT_FALSE(success_called_); 123 EXPECT_FALSE(success_called_);
124 EXPECT_FALSE(error_.empty()); 124 EXPECT_FALSE(error_.empty());
125 } 125 }
126 126
127 } // namespace web_resource 127 } // namespace web_resource
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698