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

Side by Side Diff: components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup TODOs. merge code. kill more threads. i never get tired of thread carnage. Created 7 years, 5 months 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 | Annotate | Revision Log
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 using WalletSigninHelper::state; 74 using WalletSigninHelper::state;
75 75
76 // Bring in the State enum. 76 // Bring in the State enum.
77 using WalletSigninHelper::State; 77 using WalletSigninHelper::State;
78 using WalletSigninHelper::IDLE; 78 using WalletSigninHelper::IDLE;
79 }; 79 };
80 80
81 } // namespace 81 } // namespace
82 82
83 class WalletSigninHelperTest : public testing::Test { 83 class WalletSigninHelperTest : public testing::Test {
84 public: 84 protected:
85 WalletSigninHelperTest() {}
86
87 virtual void SetUp() OVERRIDE { 85 virtual void SetUp() OVERRIDE {
88 signin_helper_.reset(new WalletSigninHelperForTesting( 86 signin_helper_.reset(new WalletSigninHelperForTesting(
89 &mock_delegate_, 87 &mock_delegate_,
90 browser_context_.GetRequestContext())); 88 browser_context_.GetRequestContext()));
91 EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state()); 89 EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state());
92 } 90 }
93 91
94 virtual void TearDown() OVERRIDE { 92 virtual void TearDown() OVERRIDE {
95 signin_helper_.reset(); 93 signin_helper_.reset();
96 } 94 }
97 95
98 protected:
99 // Sets up a response for the mock URLFetcher and completes the request. 96 // Sets up a response for the mock URLFetcher and completes the request.
100 void SetUpFetcherResponseAndCompleteRequest( 97 void SetUpFetcherResponseAndCompleteRequest(
101 const std::string& url, 98 const std::string& url,
102 int response_code, 99 int response_code,
103 const net::ResponseCookies& cookies, 100 const net::ResponseCookies& cookies,
104 const std::string& response_string) { 101 const std::string& response_string) {
105 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); 102 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
106 ASSERT_TRUE(fetcher); 103 ASSERT_TRUE(fetcher);
107 ASSERT_TRUE(fetcher->delegate()); 104 ASSERT_TRUE(fetcher->delegate());
108 105
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 181
185 WalletSigninHelperForTesting::State state() const { 182 WalletSigninHelperForTesting::State state() const {
186 return signin_helper_->state(); 183 return signin_helper_->state();
187 } 184 }
188 185
189 scoped_ptr<WalletSigninHelperForTesting> signin_helper_; 186 scoped_ptr<WalletSigninHelperForTesting> signin_helper_;
190 MockWalletSigninHelperDelegate mock_delegate_; 187 MockWalletSigninHelperDelegate mock_delegate_;
191 content::TestBrowserContext browser_context_; 188 content::TestBrowserContext browser_context_;
192 189
193 private: 190 private:
191 // The profile's request context must be released on the IO thread.
192 content::TestBrowserThreadBundle thread_bundle_;
194 net::TestURLFetcherFactory factory_; 193 net::TestURLFetcherFactory factory_;
195 content::TestBrowserThreadBundle thread_bundle_;
196 }; 194 };
197 195
198 TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { 196 TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) {
199 EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com")); 197 EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com"));
200 signin_helper_->StartPassiveSignin(); 198 signin_helper_->StartPassiveSignin();
201 MockSuccessfulPassiveSignInResponse(); 199 MockSuccessfulPassiveSignInResponse();
202 MockSuccessfulGetAccountInfoResponse("user@gmail.com"); 200 MockSuccessfulGetAccountInfoResponse("user@gmail.com");
203 } 201 }
204 202
205 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) { 203 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 browser_context_.GetRequestContext()->GetURLRequestContext() 305 browser_context_.GetRequestContext()->GetURLRequestContext()
308 ->set_cookie_store(cookie_monster); 306 ->set_cookie_store(cookie_monster);
309 signin_helper_->StartWalletCookieValueFetch(); 307 signin_helper_->StartWalletCookieValueFetch();
310 base::RunLoop().RunUntilIdle(); 308 base::RunLoop().RunUntilIdle();
311 } 309 }
312 310
313 // TODO(aruslan): http://crbug.com/188317 Need more tests. 311 // TODO(aruslan): http://crbug.com/188317 Need more tests.
314 312
315 } // namespace wallet 313 } // namespace wallet
316 } // namespace autofill 314 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698