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

Side by Side Diff: chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 request.reset(new MockProfileOAuth2TokenService::Request( 145 request.reset(new MockProfileOAuth2TokenService::Request(
146 consumer, 146 consumer,
147 GoogleServiceAuthError(GoogleServiceAuthError::NONE), 147 GoogleServiceAuthError(GoogleServiceAuthError::NONE),
148 oauth2_access_token_)); 148 oauth2_access_token_));
149 } else { 149 } else {
150 request.reset(new MockProfileOAuth2TokenService::Request( 150 request.reset(new MockProfileOAuth2TokenService::Request(
151 consumer, 151 consumer,
152 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE), 152 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE),
153 std::string())); 153 std::string()));
154 } 154 }
155 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 155 base::MessageLoop::current()->PostTask(
156 &MockProfileOAuth2TokenService::InformConsumer, request->AsWeakPtr())); 156 FROM_HERE,
157 base::Bind(&MockProfileOAuth2TokenService::InformConsumer,
158 request->AsWeakPtr()));
157 return request.PassAs<OAuth2TokenService::Request>(); 159 return request.PassAs<OAuth2TokenService::Request>();
158 } 160 }
159 161
160 static ProfileKeyedService* CreateOAuth2TokenService(Profile* profile) { 162 static ProfileKeyedService* CreateOAuth2TokenService(Profile* profile) {
161 return new MockProfileOAuth2TokenService(); 163 return new MockProfileOAuth2TokenService();
162 } 164 }
163 165
164 class ProfileOAuth2TokenServiceRequestTest : public testing::Test { 166 class ProfileOAuth2TokenServiceRequestTest : public testing::Test {
165 public: 167 public:
166 virtual void SetUp() OVERRIDE; 168 virtual void SetUp() OVERRIDE;
167 169
168 protected: 170 protected:
169 MessageLoop ui_loop_; 171 base::MessageLoop ui_loop_;
170 scoped_ptr<content::TestBrowserThread> ui_thread_; 172 scoped_ptr<content::TestBrowserThread> ui_thread_;
171 173
172 scoped_ptr<Profile> profile_; 174 scoped_ptr<Profile> profile_;
173 TestingOAuth2TokenServiceConsumer consumer_; 175 TestingOAuth2TokenServiceConsumer consumer_;
174 MockProfileOAuth2TokenService* oauth2_service_; 176 MockProfileOAuth2TokenService* oauth2_service_;
175 177
176 scoped_ptr<ProfileOAuth2TokenServiceRequest> request_; 178 scoped_ptr<ProfileOAuth2TokenServiceRequest> request_;
177 }; 179 };
178 180
179 void ProfileOAuth2TokenServiceRequestTest::SetUp() { 181 void ProfileOAuth2TokenServiceRequestTest::SetUp() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 profile_.get(), 234 profile_.get(),
233 std::set<std::string>(), 235 std::set<std::string>(),
234 &consumer_)); 236 &consumer_));
235 ui_loop_.RunUntilIdle(); 237 ui_loop_.RunUntilIdle();
236 request.reset(); 238 request.reset();
237 EXPECT_EQ(1, consumer_.number_of_successful_tokens_); 239 EXPECT_EQ(1, consumer_.number_of_successful_tokens_);
238 EXPECT_EQ(0, consumer_.number_of_errors_); 240 EXPECT_EQ(0, consumer_.number_of_errors_);
239 } 241 }
240 242
241 } // namespace 243 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698