| OLD | NEW |
| 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/net/safe_search_util.h" | 5 #include "chrome/browser/net/safe_search_util.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "net/http/http_request_headers.h" | 10 #include "net/http/http_request_headers.h" |
| 11 #include "net/url_request/url_request_test_util.h" | 11 #include "net/url_request/url_request_test_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 class SafeSearchUtilTest : public ::testing::Test { | 15 class SafeSearchUtilTest : public ::testing::Test { |
| 16 protected: | 16 protected: |
| 17 SafeSearchUtilTest() {} | 17 SafeSearchUtilTest() {} |
| 18 ~SafeSearchUtilTest() override {} | 18 ~SafeSearchUtilTest() override {} |
| 19 | 19 |
| 20 scoped_ptr<net::URLRequest> CreateRequest(const std::string& url) { | 20 scoped_ptr<net::URLRequest> CreateRequest(const std::string& url) { |
| 21 return context_.CreateRequest(GURL(url), net::DEFAULT_PRIORITY, NULL, NULL); | 21 return context_.CreateRequest(GURL(url), net::DEFAULT_PRIORITY, NULL); |
| 22 } | 22 } |
| 23 | 23 |
| 24 scoped_ptr<net::URLRequest> CreateYoutubeRequest() { | 24 scoped_ptr<net::URLRequest> CreateYoutubeRequest() { |
| 25 return CreateRequest("http://www.youtube.com"); | 25 return CreateRequest("http://www.youtube.com"); |
| 26 } | 26 } |
| 27 | 27 |
| 28 scoped_ptr<net::URLRequest> CreateNonYoutubeRequest() { | 28 scoped_ptr<net::URLRequest> CreateNonYoutubeRequest() { |
| 29 return CreateRequest("http://www.notyoutube.com"); | 29 return CreateRequest("http://www.notyoutube.com"); |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 TEST_F(SafeSearchUtilTest, DoesntTouchNonYoutubeURL) { | 162 TEST_F(SafeSearchUtilTest, DoesntTouchNonYoutubeURL) { |
| 163 scoped_ptr<net::URLRequest> request = CreateNonYoutubeRequest(); | 163 scoped_ptr<net::URLRequest> request = CreateNonYoutubeRequest(); |
| 164 net::HttpRequestHeaders headers; | 164 net::HttpRequestHeaders headers; |
| 165 headers.SetHeader("Youtube-Safety-Mode", "Off"); | 165 headers.SetHeader("Youtube-Safety-Mode", "Off"); |
| 166 safe_search_util::ForceYouTubeSafetyMode(request.get(), &headers); | 166 safe_search_util::ForceYouTubeSafetyMode(request.get(), &headers); |
| 167 std::string value; | 167 std::string value; |
| 168 EXPECT_TRUE(headers.GetHeader("Youtube-Safety-Mode", &value)); | 168 EXPECT_TRUE(headers.GetHeader("Youtube-Safety-Mode", &value)); |
| 169 EXPECT_EQ("Off", value); | 169 EXPECT_EQ("Off", value); |
| 170 } | 170 } |
| OLD | NEW |