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

Unified Diff: chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc

Issue 299943003: Refactor ProfileOAuth2TokenServiceRequest into OAuth2TokenServiceRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow ProfileOAuth2TokenServiceRequestTest to free UI thread resources. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc
diff --git a/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc b/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc
index 0ada8e84fb0281d16e9f6631af31f035f813a04b..df33ef9f178a29f15dbedc35d7330ee41c8e462f 100644
--- a/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc
+++ b/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc
@@ -68,6 +68,8 @@ class ProfileOAuth2TokenServiceRequestTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE;
+ virtual void TearDown() OVERRIDE;
+
protected:
base::MessageLoop ui_loop_;
scoped_ptr<content::TestBrowserThread> ui_thread_;
@@ -91,14 +93,23 @@ void ProfileOAuth2TokenServiceRequestTest::SetUp() {
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
}
+void ProfileOAuth2TokenServiceRequestTest::TearDown() {
+ // Destroy the request and run the message loop one last time to ensure that
+ // resources that must be destroyed in the UI thread get cleaned up.
+ request_.reset();
+ ui_loop_.RunUntilIdle();
+}
+
TEST_F(ProfileOAuth2TokenServiceRequestTest,
Failure) {
scoped_ptr<ProfileOAuth2TokenServiceRequest> request(
ProfileOAuth2TokenServiceRequest::CreateAndStart(
profile_.get(),
- std::string(),
+ kAccountId,
OAuth2TokenService::ScopeSet(),
&consumer_));
+ // Run to ensure the request has been made.
+ ui_loop_.RunUntilIdle();
oauth2_service_->IssueErrorForAllPendingRequests(
GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
ui_loop_.RunUntilIdle();
@@ -114,6 +125,8 @@ TEST_F(ProfileOAuth2TokenServiceRequestTest, Success) {
kAccountId,
OAuth2TokenService::ScopeSet(),
&consumer_));
+ // Run to ensure the request has been made.
+ ui_loop_.RunUntilIdle();
oauth2_service_->IssueTokenForAllPendingRequests(kAccessToken,
base::Time::Max());
ui_loop_.RunUntilIdle();
@@ -131,6 +144,8 @@ TEST_F(ProfileOAuth2TokenServiceRequestTest,
kAccountId,
OAuth2TokenService::ScopeSet(),
&consumer_));
+ // Run to ensure the request has been made.
+ ui_loop_.RunUntilIdle();
request.reset();
oauth2_service_->IssueTokenForAllPendingRequests(kAccessToken,
base::Time::Max());
@@ -148,6 +163,8 @@ TEST_F(ProfileOAuth2TokenServiceRequestTest,
kAccountId,
OAuth2TokenService::ScopeSet(),
&consumer_));
+ // Run to ensure the request has been made.
+ ui_loop_.RunUntilIdle();
oauth2_service_->IssueTokenForAllPendingRequests(kAccessToken,
base::Time::Max());
ui_loop_.RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698