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

Side by Side Diff: chrome/browser/safe_search_api/safe_search_url_checker_unittest.cc

Issue 2743923002: Network traffic annotation added to safe_search_url_checker. (Closed)
Patch Set: Annotation updated. Created 3 years, 9 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/safe_search_api/safe_search_url_checker.h" 5 #include "chrome/browser/safe_search_api/safe_search_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 #include <utility>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
20 #include "net/url_request/test_url_fetcher_factory.h" 21 #include "net/url_request/test_url_fetcher_factory.h"
21 #include "net/url_request/url_request_test_util.h" 22 #include "net/url_request/url_request_test_util.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 using Classification = SafeSearchURLChecker::Classification; 27 using Classification = SafeSearchURLChecker::Classification;
27 using testing::_; 28 using testing::_;
28 29
29 namespace { 30 namespace {
(...skipping 29 matching lines...) Expand all
59 } 60 }
60 61
61 } // namespace 62 } // namespace
62 63
63 class SafeSearchURLCheckerTest : public testing::Test { 64 class SafeSearchURLCheckerTest : public testing::Test {
64 public: 65 public:
65 SafeSearchURLCheckerTest() 66 SafeSearchURLCheckerTest()
66 : next_url_(0), 67 : next_url_(0),
67 request_context_(new net::TestURLRequestContextGetter( 68 request_context_(new net::TestURLRequestContextGetter(
68 base::ThreadTaskRunnerHandle::Get())), 69 base::ThreadTaskRunnerHandle::Get())),
69 checker_(request_context_.get(), kCacheSize) {} 70 checker_(request_context_.get(),
71 TRAFFIC_ANNOTATION_FOR_TESTS,
72 kCacheSize) {}
70 73
71 MOCK_METHOD3(OnCheckDone, 74 MOCK_METHOD3(OnCheckDone,
72 void(const GURL& url, 75 void(const GURL& url,
73 Classification classification, 76 Classification classification,
74 bool uncertain)); 77 bool uncertain));
75 78
76 protected: 79 protected:
77 GURL GetNewURL() { 80 GURL GetNewURL() {
78 CHECK(next_url_ < arraysize(kURLs)); 81 CHECK(next_url_ < arraysize(kURLs));
79 return GURL(kURLs[next_url_++]); 82 return GURL(kURLs[next_url_++]);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 ASSERT_FALSE(CheckURL(url)); 187 ASSERT_FALSE(CheckURL(url));
185 EXPECT_CALL(*this, OnCheckDone(url, Classification::SAFE, false)); 188 EXPECT_CALL(*this, OnCheckDone(url, Classification::SAFE, false));
186 SendValidResponse(false); 189 SendValidResponse(false);
187 190
188 // Since the cache timeout is zero, the cache entry should be invalidated 191 // Since the cache timeout is zero, the cache entry should be invalidated
189 // immediately. 192 // immediately.
190 ASSERT_FALSE(CheckURL(url)); 193 ASSERT_FALSE(CheckURL(url));
191 EXPECT_CALL(*this, OnCheckDone(url, Classification::UNSAFE, false)); 194 EXPECT_CALL(*this, OnCheckDone(url, Classification::UNSAFE, false));
192 SendValidResponse(true); 195 SendValidResponse(true);
193 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698