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

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

Issue 753683004: Revert of Supervised user SafeSites: Expose & use API key from src-internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 <string> 5 #include <string>
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/supervised_user/experimental/supervised_user_async_url_ checker.h" 13 #include "chrome/browser/supervised_user/experimental/supervised_user_async_url_ checker.h"
14 #include "net/url_request/test_url_fetcher_factory.h" 14 #include "net/url_request/test_url_fetcher_factory.h"
15 #include "net/url_request/url_request_test_util.h" 15 #include "net/url_request/url_request_test_util.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 using testing::_; 20 using testing::_;
21 21
22 namespace { 22 namespace {
23 23
24 const char kCx[] = "somecsecx"; 24 const char kCx[] = "somecsecx";
25 const char kApiKey[] = "someapikey";
25 const size_t kCacheSize = 2; 26 const size_t kCacheSize = 2;
26 27
27 const int kSupervisedUserAsyncURLCheckerSafeURLFetcherID = 0; 28 const int kSupervisedUserAsyncURLCheckerSafeURLFetcherID = 0;
28 const int kSupervisedUserAsyncURLCheckerUnsafeURLFetcherID = 1; 29 const int kSupervisedUserAsyncURLCheckerUnsafeURLFetcherID = 1;
29 30
30 const char* kURLs[] = { 31 const char* kURLs[] = {
31 "http://www.randomsite1.com", 32 "http://www.randomsite1.com",
32 "http://www.randomsite2.com", 33 "http://www.randomsite2.com",
33 "http://www.randomsite3.com", 34 "http://www.randomsite3.com",
34 "http://www.randomsite4.com", 35 "http://www.randomsite4.com",
(...skipping 24 matching lines...) Expand all
59 } 60 }
60 61
61 } // namespace 62 } // namespace
62 63
63 class SupervisedUserAsyncURLCheckerTest : public testing::Test { 64 class SupervisedUserAsyncURLCheckerTest : public testing::Test {
64 public: 65 public:
65 SupervisedUserAsyncURLCheckerTest() 66 SupervisedUserAsyncURLCheckerTest()
66 : next_url_(0), 67 : next_url_(0),
67 request_context_(new net::TestURLRequestContextGetter( 68 request_context_(new net::TestURLRequestContextGetter(
68 base::MessageLoopProxy::current())), 69 base::MessageLoopProxy::current())),
69 checker_(request_context_.get(), kCx, kCacheSize) { 70 checker_(request_context_.get(), kCx, kApiKey, kCacheSize) {
70 } 71 }
71 72
72 MOCK_METHOD3(OnCheckDone, 73 MOCK_METHOD3(OnCheckDone,
73 void(const GURL& url, 74 void(const GURL& url,
74 SupervisedUserURLFilter::FilteringBehavior behavior, 75 SupervisedUserURLFilter::FilteringBehavior behavior,
75 bool uncertain)); 76 bool uncertain));
76 77
77 protected: 78 protected:
78 GURL GetNewURL() { 79 GURL GetNewURL() {
79 CHECK(next_url_ < arraysize(kURLs)); 80 CHECK(next_url_ < arraysize(kURLs));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 TEST_F(SupervisedUserAsyncURLCheckerTest, CoalesceRequestsToSameURL) { 225 TEST_F(SupervisedUserAsyncURLCheckerTest, CoalesceRequestsToSameURL) {
225 GURL url(GetNewURL()); 226 GURL url(GetNewURL());
226 // Start two checks for the same URL. 227 // Start two checks for the same URL.
227 EXPECT_FALSE(CheckURL(url)); 228 EXPECT_FALSE(CheckURL(url));
228 EXPECT_FALSE(CheckURL(url)); 229 EXPECT_FALSE(CheckURL(url));
229 // A single response should answer both checks. 230 // A single response should answer both checks.
230 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::ALLOW, false)) 231 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::ALLOW, false))
231 .Times(2); 232 .Times(2);
232 SendValidResponse(true, url); 233 SendValidResponse(true, url);
233 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698