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

Side by Side Diff: chrome/browser/supervised_user/experimental/supervised_user_async_url_checker_unittest.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/supervised_user/experimental/supervised_user_async_url_ checker.h" 5 #include "chrome/browser/supervised_user/experimental/supervised_user_async_url_ checker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <utility>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
19 #include "net/url_request/test_url_fetcher_factory.h" 20 #include "net/url_request/test_url_fetcher_factory.h"
20 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
(...skipping 16 matching lines...) Expand all
37 "http://www.randomsite4.com", 38 "http://www.randomsite4.com",
38 "http://www.randomsite5.com", 39 "http://www.randomsite5.com",
39 "http://www.randomsite6.com", 40 "http://www.randomsite6.com",
40 "http://www.randomsite7.com", 41 "http://www.randomsite7.com",
41 "http://www.randomsite8.com", 42 "http://www.randomsite8.com",
42 "http://www.randomsite9.com", 43 "http://www.randomsite9.com",
43 }; 44 };
44 45
45 std::string BuildResponse(bool is_porn) { 46 std::string BuildResponse(bool is_porn) {
46 base::DictionaryValue dict; 47 base::DictionaryValue dict;
47 base::DictionaryValue* classification_dict = new base::DictionaryValue; 48 std::unique_ptr<base::DictionaryValue> classification_dict(
49 new base::DictionaryValue);
48 if (is_porn) 50 if (is_porn)
49 classification_dict->SetBoolean("pornography", is_porn); 51 classification_dict->SetBoolean("pornography", is_porn);
50 base::ListValue* classifications_list = new base::ListValue; 52 base::ListValue* classifications_list = new base::ListValue;
51 classifications_list->Append(classification_dict); 53 classifications_list->Append(std::move(classification_dict));
52 dict.SetWithoutPathExpansion("classifications", classifications_list); 54 dict.SetWithoutPathExpansion("classifications", classifications_list);
53 std::string result; 55 std::string result;
54 base::JSONWriter::Write(dict, &result); 56 base::JSONWriter::Write(dict, &result);
55 return result; 57 return result;
56 } 58 }
57 59
58 } // namespace 60 } // namespace
59 61
60 class SupervisedUserAsyncURLCheckerTest : public testing::Test { 62 class SupervisedUserAsyncURLCheckerTest : public testing::Test {
61 public: 63 public:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ASSERT_FALSE(CheckURL(url)); 214 ASSERT_FALSE(CheckURL(url));
213 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::ALLOW, false)); 215 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::ALLOW, false));
214 SendValidResponse(false); 216 SendValidResponse(false);
215 217
216 // Since the cache timeout is zero, the cache entry should be invalidated 218 // Since the cache timeout is zero, the cache entry should be invalidated
217 // immediately. 219 // immediately.
218 ASSERT_FALSE(CheckURL(url)); 220 ASSERT_FALSE(CheckURL(url));
219 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::BLOCK, false)); 221 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::BLOCK, false));
220 SendValidResponse(true); 222 SendValidResponse(true);
221 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698