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

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

Issue 690423003: Supervised user SafeSites: Expose & use API key from src-internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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";
26 const size_t kCacheSize = 2; 25 const size_t kCacheSize = 2;
27 26
28 const int kSupervisedUserAsyncURLCheckerSafeURLFetcherID = 0; 27 const int kSupervisedUserAsyncURLCheckerSafeURLFetcherID = 0;
29 const int kSupervisedUserAsyncURLCheckerUnsafeURLFetcherID = 1; 28 const int kSupervisedUserAsyncURLCheckerUnsafeURLFetcherID = 1;
30 29
31 const char* kURLs[] = { 30 const char* kURLs[] = {
32 "http://www.randomsite1.com", 31 "http://www.randomsite1.com",
33 "http://www.randomsite2.com", 32 "http://www.randomsite2.com",
34 "http://www.randomsite3.com", 33 "http://www.randomsite3.com",
35 "http://www.randomsite4.com", 34 "http://www.randomsite4.com",
(...skipping 24 matching lines...) Expand all
60 } 59 }
61 60
62 } // namespace 61 } // namespace
63 62
64 class SupervisedUserAsyncURLCheckerTest : public testing::Test { 63 class SupervisedUserAsyncURLCheckerTest : public testing::Test {
65 public: 64 public:
66 SupervisedUserAsyncURLCheckerTest() 65 SupervisedUserAsyncURLCheckerTest()
67 : next_url_(0), 66 : next_url_(0),
68 request_context_(new net::TestURLRequestContextGetter( 67 request_context_(new net::TestURLRequestContextGetter(
69 base::MessageLoopProxy::current())), 68 base::MessageLoopProxy::current())),
70 checker_(request_context_.get(), kCx, kApiKey, kCacheSize) { 69 checker_(request_context_.get(), kCx, kCacheSize) {
71 } 70 }
72 71
73 MOCK_METHOD3(OnCheckDone, 72 MOCK_METHOD3(OnCheckDone,
74 void(const GURL& url, 73 void(const GURL& url,
75 SupervisedUserURLFilter::FilteringBehavior behavior, 74 SupervisedUserURLFilter::FilteringBehavior behavior,
76 bool uncertain)); 75 bool uncertain));
77 76
78 protected: 77 protected:
79 GURL GetNewURL() { 78 GURL GetNewURL() {
80 CHECK(next_url_ < arraysize(kURLs)); 79 CHECK(next_url_ < arraysize(kURLs));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 TEST_F(SupervisedUserAsyncURLCheckerTest, CoalesceRequestsToSameURL) { 224 TEST_F(SupervisedUserAsyncURLCheckerTest, CoalesceRequestsToSameURL) {
226 GURL url(GetNewURL()); 225 GURL url(GetNewURL());
227 // Start two checks for the same URL. 226 // Start two checks for the same URL.
228 EXPECT_FALSE(CheckURL(url)); 227 EXPECT_FALSE(CheckURL(url));
229 EXPECT_FALSE(CheckURL(url)); 228 EXPECT_FALSE(CheckURL(url));
230 // A single response should answer both checks. 229 // A single response should answer both checks.
231 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::ALLOW, false)) 230 EXPECT_CALL(*this, OnCheckDone(url, SupervisedUserURLFilter::ALLOW, false))
232 .Times(2); 231 .Times(2);
233 SendValidResponse(true, url); 232 SendValidResponse(true, url);
234 } 233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698