| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "components/content_settings/core/browser/cookie_settings.h" | 9 #include "components/content_settings/core/browser/cookie_settings.h" |
| 10 #include "components/pref_registry/testing_pref_service_syncable.h" | |
| 11 #include "components/signin/core/browser/signin_header_helper.h" | 10 #include "components/signin/core/browser/signin_header_helper.h" |
| 12 #include "components/signin/core/common/signin_switches.h" | 11 #include "components/signin/core/common/signin_switches.h" |
| 12 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 13 #include "net/url_request/url_request_test_util.h" | 13 #include "net/url_request/url_request_test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 class SigninHeaderHelperTest : public testing::Test { | 17 class SigninHeaderHelperTest : public testing::Test { |
| 18 protected: | 18 protected: |
| 19 void SetUp() override { | 19 void SetUp() override { |
| 20 content_settings::CookieSettings::RegisterProfilePrefs(prefs_.registry()); | 20 content_settings::CookieSettings::RegisterProfilePrefs(prefs_.registry()); |
| 21 HostContentSettingsMap::RegisterProfilePrefs(prefs_.registry()); | 21 HostContentSettingsMap::RegisterProfilePrefs(prefs_.registry()); |
| 22 | 22 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 EXPECT_EQ(url_request->extra_request_headers().GetHeader( | 51 EXPECT_EQ(url_request->extra_request_headers().GetHeader( |
| 52 signin::kChromeConnectedHeader, &request), | 52 signin::kChromeConnectedHeader, &request), |
| 53 expected_result); | 53 expected_result); |
| 54 if (expected_result) { | 54 if (expected_result) { |
| 55 EXPECT_EQ(expected_request, request); | 55 EXPECT_EQ(expected_request, request); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 base::MessageLoop loop_; | 59 base::MessageLoop loop_; |
| 60 | 60 |
| 61 user_prefs::TestingPrefServiceSyncable prefs_; | 61 sync_preferences::TestingPrefServiceSyncable prefs_; |
| 62 net::TestURLRequestContext url_request_context_; | 62 net::TestURLRequestContext url_request_context_; |
| 63 | 63 |
| 64 scoped_refptr<HostContentSettingsMap> settings_map_; | 64 scoped_refptr<HostContentSettingsMap> settings_map_; |
| 65 scoped_refptr<content_settings::CookieSettings> cookie_settings_; | 65 scoped_refptr<content_settings::CookieSettings> cookie_settings_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Tests that no Mirror request is returned when the user is not signed in (no | 68 // Tests that no Mirror request is returned when the user is not signed in (no |
| 69 // account id). | 69 // account id). |
| 70 TEST_F(SigninHeaderHelperTest, TestNoMirrorRequestNoAccountId) { | 70 TEST_F(SigninHeaderHelperTest, TestNoMirrorRequestNoAccountId) { |
| 71 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 71 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 url_request->SetExtraRequestHeaderByName(signin::kChromeConnectedHeader, | 191 url_request->SetExtraRequestHeaderByName(signin::kChromeConnectedHeader, |
| 192 fake_header, false); | 192 fake_header, false); |
| 193 EXPECT_FALSE(signin::AppendOrRemoveMirrorRequestHeaderIfPossible( | 193 EXPECT_FALSE(signin::AppendOrRemoveMirrorRequestHeaderIfPossible( |
| 194 url_request.get(), redirect_url, account_id, cookie_settings_.get(), | 194 url_request.get(), redirect_url, account_id, cookie_settings_.get(), |
| 195 signin::PROFILE_MODE_DEFAULT)); | 195 signin::PROFILE_MODE_DEFAULT)); |
| 196 std::string header; | 196 std::string header; |
| 197 EXPECT_TRUE(url_request->extra_request_headers().GetHeader( | 197 EXPECT_TRUE(url_request->extra_request_headers().GetHeader( |
| 198 signin::kChromeConnectedHeader, &header)); | 198 signin::kChromeConnectedHeader, &header)); |
| 199 EXPECT_EQ(fake_header, header); | 199 EXPECT_EQ(fake_header, header); |
| 200 } | 200 } |
| OLD | NEW |