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

Side by Side Diff: google_apis/gaia/oauth2_token_service_request_unittest.cc

Issue 1135793002: Using ThreadTaskRunnerHandle in lieu of MessageLoopProxy in google_apis module (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "google_apis/gaia/oauth2_token_service_request.h" 5 #include "google_apis/gaia/oauth2_token_service_request.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/thread_task_runner_handle.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "google_apis/gaia/fake_oauth2_token_service.h" 14 #include "google_apis/gaia/fake_oauth2_token_service.h"
14 #include "google_apis/gaia/google_service_auth_error.h" 15 #include "google_apis/gaia/google_service_auth_error.h"
15 #include "google_apis/gaia/oauth2_token_service.h" 16 #include "google_apis/gaia/oauth2_token_service.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace { 19 namespace {
19 20
20 const char kAccessToken[] = "access_token"; 21 const char kAccessToken[] = "access_token";
21 const char kAccountId[] = "test_user@gmail.com"; 22 const char kAccountId[] = "test_user@gmail.com";
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 scoped_ptr<MockOAuth2TokenService> oauth2_service_; 173 scoped_ptr<MockOAuth2TokenService> oauth2_service_;
173 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> provider_; 174 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> provider_;
174 TestingOAuth2TokenServiceConsumer consumer_; 175 TestingOAuth2TokenServiceConsumer consumer_;
175 }; 176 };
176 177
177 void OAuth2TokenServiceRequestTest::SetUp() { 178 void OAuth2TokenServiceRequestTest::SetUp() {
178 scopes_.insert(kScope); 179 scopes_.insert(kScope);
179 oauth2_service_.reset(new MockOAuth2TokenService); 180 oauth2_service_.reset(new MockOAuth2TokenService);
180 oauth2_service_->AddAccount(kAccountId); 181 oauth2_service_->AddAccount(kAccountId);
181 provider_ = 182 provider_ =
182 new Provider(base::MessageLoopProxy::current(), oauth2_service_.get()); 183 new Provider(base::ThreadTaskRunnerHandle::Get(), oauth2_service_.get());
183 } 184 }
184 185
185 void OAuth2TokenServiceRequestTest::TearDown() { 186 void OAuth2TokenServiceRequestTest::TearDown() {
186 // Run the loop to execute any pending tasks that may free resources. 187 // Run the loop to execute any pending tasks that may free resources.
187 ui_loop_.RunUntilIdle(); 188 ui_loop_.RunUntilIdle();
188 } 189 }
189 190
190 OAuth2TokenServiceRequestTest::Provider::Provider( 191 OAuth2TokenServiceRequestTest::Provider::Provider(
191 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 192 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
192 OAuth2TokenService* token_service) 193 OAuth2TokenService* token_service)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 OAuth2TokenServiceRequest::InvalidateToken( 262 OAuth2TokenServiceRequest::InvalidateToken(
262 provider_.get(), kAccountId, scopes_, kAccessToken); 263 provider_.get(), kAccountId, scopes_, kAccessToken);
263 ui_loop_.RunUntilIdle(); 264 ui_loop_.RunUntilIdle();
264 EXPECT_EQ(0, consumer_.num_get_token_success_); 265 EXPECT_EQ(0, consumer_.num_get_token_success_);
265 EXPECT_EQ(0, consumer_.num_get_token_failure_); 266 EXPECT_EQ(0, consumer_.num_get_token_failure_);
266 EXPECT_EQ(kAccessToken, oauth2_service_->last_token_invalidated()); 267 EXPECT_EQ(kAccessToken, oauth2_service_->last_token_invalidated());
267 EXPECT_EQ(1, oauth2_service_->num_invalidate_token()); 268 EXPECT_EQ(1, oauth2_service_->num_invalidate_token());
268 } 269 }
269 270
270 } // namespace 271 } // namespace
OLDNEW
« no previous file with comments | « google_apis/gaia/oauth2_access_token_fetcher_impl_unittest.cc ('k') | google_apis/gaia/ubertoken_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698