OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/browser/wallet/wallet_signin_helper.h" | 5 #include "components/autofill/content/browser/wallet/wallet_signin_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSigninNo) { | 121 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSigninNo) { |
122 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); | 122 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); |
123 signin_helper_->StartPassiveSignin(0); | 123 signin_helper_->StartPassiveSignin(0); |
124 MockFailedPassiveSignInResponseNo(); | 124 MockFailedPassiveSignInResponseNo(); |
125 } | 125 } |
126 | 126 |
127 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) { | 127 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) { |
128 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken")); | 128 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken")); |
129 net::CookieMonster* cookie_monster = | 129 net::CookieMonster* cookie_monster = |
130 content::CreateInMemoryCookieStore(NULL)->GetCookieMonster(); | 130 content::CreateCookieStore(content::CookieStoreConfig())-> |
| 131 GetCookieMonster(); |
131 net::CookieOptions httponly_options; | 132 net::CookieOptions httponly_options; |
132 httponly_options.set_include_httponly(); | 133 httponly_options.set_include_httponly(); |
133 scoped_ptr<net::CanonicalCookie> cookie( | 134 scoped_ptr<net::CanonicalCookie> cookie( |
134 net::CanonicalCookie::Create(GetPassiveAuthUrl(0).GetWithEmptyPath(), | 135 net::CanonicalCookie::Create(GetPassiveAuthUrl(0).GetWithEmptyPath(), |
135 "gdToken=gdToken; HttpOnly", | 136 "gdToken=gdToken; HttpOnly", |
136 base::Time::Now(), | 137 base::Time::Now(), |
137 httponly_options)); | 138 httponly_options)); |
138 | 139 |
139 net::CookieList cookie_list; | 140 net::CookieList cookie_list; |
140 cookie_list.push_back(*cookie); | 141 cookie_list.push_back(*cookie); |
141 cookie_monster->InitializeFrom(cookie_list); | 142 cookie_monster->InitializeFrom(cookie_list); |
142 browser_context_.GetRequestContext()->GetURLRequestContext() | 143 browser_context_.GetRequestContext()->GetURLRequestContext() |
143 ->set_cookie_store(cookie_monster); | 144 ->set_cookie_store(cookie_monster); |
144 signin_helper_->StartWalletCookieValueFetch(); | 145 signin_helper_->StartWalletCookieValueFetch(); |
145 base::RunLoop().RunUntilIdle(); | 146 base::RunLoop().RunUntilIdle(); |
146 } | 147 } |
147 | 148 |
148 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenMissing) { | 149 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenMissing) { |
149 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue(std::string())); | 150 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue(std::string())); |
150 net::CookieMonster* cookie_monster = | 151 net::CookieMonster* cookie_monster = |
151 content::CreateInMemoryCookieStore(NULL)->GetCookieMonster(); | 152 content::CreateCookieStore(content::CookieStoreConfig())-> |
| 153 GetCookieMonster(); |
152 net::CookieOptions httponly_options; | 154 net::CookieOptions httponly_options; |
153 httponly_options.set_include_httponly(); | 155 httponly_options.set_include_httponly(); |
154 scoped_ptr<net::CanonicalCookie> cookie( | 156 scoped_ptr<net::CanonicalCookie> cookie( |
155 net::CanonicalCookie::Create(GetPassiveAuthUrl(0).GetWithEmptyPath(), | 157 net::CanonicalCookie::Create(GetPassiveAuthUrl(0).GetWithEmptyPath(), |
156 "fake_cookie=monkeys; HttpOnly", | 158 "fake_cookie=monkeys; HttpOnly", |
157 base::Time::Now(), | 159 base::Time::Now(), |
158 httponly_options)); | 160 httponly_options)); |
159 | 161 |
160 net::CookieList cookie_list; | 162 net::CookieList cookie_list; |
161 cookie_list.push_back(*cookie); | 163 cookie_list.push_back(*cookie); |
162 cookie_monster->InitializeFrom(cookie_list); | 164 cookie_monster->InitializeFrom(cookie_list); |
163 browser_context_.GetRequestContext()->GetURLRequestContext() | 165 browser_context_.GetRequestContext()->GetURLRequestContext() |
164 ->set_cookie_store(cookie_monster); | 166 ->set_cookie_store(cookie_monster); |
165 signin_helper_->StartWalletCookieValueFetch(); | 167 signin_helper_->StartWalletCookieValueFetch(); |
166 base::RunLoop().RunUntilIdle(); | 168 base::RunLoop().RunUntilIdle(); |
167 } | 169 } |
168 | 170 |
169 // TODO(aruslan): http://crbug.com/188317 Need more tests. | 171 // TODO(aruslan): http://crbug.com/188317 Need more tests. |
170 | 172 |
171 } // namespace wallet | 173 } // namespace wallet |
172 } // namespace autofill | 174 } // namespace autofill |
OLD | NEW |