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

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: fix InstantNTP test. 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 using WalletSigninHelper::state; 71 using WalletSigninHelper::state;
72 72
73 // Bring in the State enum. 73 // Bring in the State enum.
74 using WalletSigninHelper::State; 74 using WalletSigninHelper::State;
75 using WalletSigninHelper::IDLE; 75 using WalletSigninHelper::IDLE;
76 }; 76 };
77 77
78 } // namespace 78 } // namespace
79 79
80 class WalletSigninHelperTest : public testing::Test { 80 class WalletSigninHelperTest : public testing::Test {
81 public: 81 protected:
82 WalletSigninHelperTest() {}
83
84 virtual void SetUp() OVERRIDE { 82 virtual void SetUp() OVERRIDE {
85 signin_helper_.reset(new WalletSigninHelperForTesting( 83 signin_helper_.reset(new WalletSigninHelperForTesting(
86 &mock_delegate_, 84 &mock_delegate_,
87 browser_context_.GetRequestContext())); 85 browser_context_.GetRequestContext()));
88 EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state()); 86 EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state());
89 } 87 }
90 88
91 virtual void TearDown() OVERRIDE { 89 virtual void TearDown() OVERRIDE {
92 signin_helper_.reset(); 90 signin_helper_.reset();
93 } 91 }
94 92
95 protected:
96 // Sets up a response for the mock URLFetcher and completes the request. 93 // Sets up a response for the mock URLFetcher and completes the request.
97 void SetUpFetcherResponseAndCompleteRequest( 94 void SetUpFetcherResponseAndCompleteRequest(
98 const std::string& url, 95 const std::string& url,
99 int response_code, 96 int response_code,
100 const net::ResponseCookies& cookies, 97 const net::ResponseCookies& cookies,
101 const std::string& response_string) { 98 const std::string& response_string) {
102 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); 99 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
103 ASSERT_TRUE(fetcher); 100 ASSERT_TRUE(fetcher);
104 ASSERT_TRUE(fetcher->delegate()); 101 ASSERT_TRUE(fetcher->delegate());
105 102
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 148
152 WalletSigninHelperForTesting::State state() const { 149 WalletSigninHelperForTesting::State state() const {
153 return signin_helper_->state(); 150 return signin_helper_->state();
154 } 151 }
155 152
156 scoped_ptr<WalletSigninHelperForTesting> signin_helper_; 153 scoped_ptr<WalletSigninHelperForTesting> signin_helper_;
157 MockWalletSigninHelperDelegate mock_delegate_; 154 MockWalletSigninHelperDelegate mock_delegate_;
158 content::TestBrowserContext browser_context_; 155 content::TestBrowserContext browser_context_;
159 156
160 private: 157 private:
158 // The profile's request context must be released on the IO thread.
159 content::TestBrowserThreadBundle thread_bundle_;
161 net::TestURLFetcherFactory factory_; 160 net::TestURLFetcherFactory factory_;
162 content::TestBrowserThreadBundle thread_bundle_;
163 }; 161 };
164 162
165 TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { 163 TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) {
166 EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com")); 164 EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com"));
167 signin_helper_->StartPassiveSignin(); 165 signin_helper_->StartPassiveSignin();
168 MockSuccessfulPassiveSignInResponse(); 166 MockSuccessfulPassiveSignInResponse();
169 MockSuccessfulGetAccountInfoResponse("user@gmail.com"); 167 MockSuccessfulGetAccountInfoResponse("user@gmail.com");
170 } 168 }
171 169
172 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) { 170 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 browser_context_.GetRequestContext()->GetURLRequestContext() 235 browser_context_.GetRequestContext()->GetURLRequestContext()
238 ->set_cookie_store(cookie_monster); 236 ->set_cookie_store(cookie_monster);
239 signin_helper_->StartWalletCookieValueFetch(); 237 signin_helper_->StartWalletCookieValueFetch();
240 base::RunLoop().RunUntilIdle(); 238 base::RunLoop().RunUntilIdle();
241 } 239 }
242 240
243 // TODO(aruslan): http://crbug.com/188317 Need more tests. 241 // TODO(aruslan): http://crbug.com/188317 Need more tests.
244 242
245 } // namespace wallet 243 } // namespace wallet
246 } // namespace autofill 244 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698