| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "chrome/browser/signin/profile_oauth2_token_service_request.h" | 4 #include "chrome/browser/signin/profile_oauth2_token_service_request.h" |
| 5 | 5 |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "chrome/browser/signin/oauth2_token_service.h" | 10 #include "chrome/browser/signin/oauth2_token_service.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 scoped_ptr<Profile> profile_; | 174 scoped_ptr<Profile> profile_; |
| 175 TestingOAuth2TokenServiceConsumer consumer_; | 175 TestingOAuth2TokenServiceConsumer consumer_; |
| 176 MockProfileOAuth2TokenService* oauth2_service_; | 176 MockProfileOAuth2TokenService* oauth2_service_; |
| 177 | 177 |
| 178 scoped_ptr<ProfileOAuth2TokenServiceRequest> request_; | 178 scoped_ptr<ProfileOAuth2TokenServiceRequest> request_; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 void ProfileOAuth2TokenServiceRequestTest::SetUp() { | 181 void ProfileOAuth2TokenServiceRequestTest::SetUp() { |
| 182 ui_thread_.reset(new content::TestBrowserThread(content::BrowserThread::UI, | 182 ui_thread_.reset(new content::TestBrowserThread(content::BrowserThread::UI, |
| 183 &ui_loop_)); | 183 &ui_loop_)); |
| 184 profile_.reset(new TestingProfile()); | 184 TestingProfile::Builder builder; |
| 185 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( | 185 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 186 profile_.get(), &CreateOAuth2TokenService); | 186 &CreateOAuth2TokenService); |
| 187 profile_ = builder.Build(); |
| 188 |
| 187 oauth2_service_ = (MockProfileOAuth2TokenService*) | 189 oauth2_service_ = (MockProfileOAuth2TokenService*) |
| 188 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 190 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); |
| 189 } | 191 } |
| 190 | 192 |
| 191 TEST_F(ProfileOAuth2TokenServiceRequestTest, | 193 TEST_F(ProfileOAuth2TokenServiceRequestTest, |
| 192 Failure) { | 194 Failure) { |
| 193 oauth2_service_->SetExpectation(false, std::string()); | 195 oauth2_service_->SetExpectation(false, std::string()); |
| 194 scoped_ptr<ProfileOAuth2TokenServiceRequest> request( | 196 scoped_ptr<ProfileOAuth2TokenServiceRequest> request( |
| 195 ProfileOAuth2TokenServiceRequest::CreateAndStart( | 197 ProfileOAuth2TokenServiceRequest::CreateAndStart( |
| 196 profile_.get(), | 198 profile_.get(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 profile_.get(), | 236 profile_.get(), |
| 235 std::set<std::string>(), | 237 std::set<std::string>(), |
| 236 &consumer_)); | 238 &consumer_)); |
| 237 ui_loop_.RunUntilIdle(); | 239 ui_loop_.RunUntilIdle(); |
| 238 request.reset(); | 240 request.reset(); |
| 239 EXPECT_EQ(1, consumer_.number_of_successful_tokens_); | 241 EXPECT_EQ(1, consumer_.number_of_successful_tokens_); |
| 240 EXPECT_EQ(0, consumer_.number_of_errors_); | 242 EXPECT_EQ(0, consumer_.number_of_errors_); |
| 241 } | 243 } |
| 242 | 244 |
| 243 } // namespace | 245 } // namespace |
| OLD | NEW |