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

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

Issue 649283003: Standardize usage of virtual/override/final in google_apis/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « google_apis/gaia/oauth2_token_service_test_util.h ('k') | google_apis/gaia/ubertoken_fetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "google_apis/gaia/gaia_constants.h" 9 #include "google_apis/gaia/gaia_constants.h"
10 #include "google_apis/gaia/google_service_auth_error.h" 10 #include "google_apis/gaia/google_service_auth_error.h"
11 #include "google_apis/gaia/oauth2_access_token_consumer.h" 11 #include "google_apis/gaia/oauth2_access_token_consumer.h"
12 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" 12 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
13 #include "google_apis/gaia/oauth2_token_service.h" 13 #include "google_apis/gaia/oauth2_token_service.h"
14 #include "google_apis/gaia/oauth2_token_service_test_util.h" 14 #include "google_apis/gaia/oauth2_token_service_test_util.h"
15 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
16 #include "net/url_request/test_url_fetcher_factory.h" 16 #include "net/url_request/test_url_fetcher_factory.h"
17 #include "net/url_request/url_fetcher_delegate.h" 17 #include "net/url_request/url_fetcher_delegate.h"
18 #include "net/url_request/url_request_test_util.h" 18 #include "net/url_request/url_request_test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 // A testing consumer that retries on error. 21 // A testing consumer that retries on error.
22 class RetryingTestingOAuth2TokenServiceConsumer 22 class RetryingTestingOAuth2TokenServiceConsumer
23 : public TestingOAuth2TokenServiceConsumer { 23 : public TestingOAuth2TokenServiceConsumer {
24 public: 24 public:
25 RetryingTestingOAuth2TokenServiceConsumer( 25 RetryingTestingOAuth2TokenServiceConsumer(
26 OAuth2TokenService* oauth2_service, 26 OAuth2TokenService* oauth2_service,
27 const std::string& account_id) 27 const std::string& account_id)
28 : oauth2_service_(oauth2_service), 28 : oauth2_service_(oauth2_service),
29 account_id_(account_id) {} 29 account_id_(account_id) {}
30 virtual ~RetryingTestingOAuth2TokenServiceConsumer() {} 30 ~RetryingTestingOAuth2TokenServiceConsumer() override {}
31 31
32 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 32 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
33 const GoogleServiceAuthError& error) override { 33 const GoogleServiceAuthError& error) override {
34 TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(request, error); 34 TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(request, error);
35 request_.reset(oauth2_service_->StartRequest( 35 request_.reset(oauth2_service_->StartRequest(
36 account_id_, OAuth2TokenService::ScopeSet(), this).release()); 36 account_id_, OAuth2TokenService::ScopeSet(), this).release());
37 } 37 }
38 38
39 OAuth2TokenService* oauth2_service_; 39 OAuth2TokenService* oauth2_service_;
40 std::string account_id_; 40 std::string account_id_;
41 scoped_ptr<OAuth2TokenService::Request> request_; 41 scoped_ptr<OAuth2TokenService::Request> request_;
42 }; 42 };
43 43
(...skipping 11 matching lines...) Expand all
55 55
56 // For testing: set the refresh token to be used. 56 // For testing: set the refresh token to be used.
57 void set_refresh_token(const std::string& account_id, 57 void set_refresh_token(const std::string& account_id,
58 const std::string& refresh_token) { 58 const std::string& refresh_token) {
59 if (refresh_token.empty()) 59 if (refresh_token.empty())
60 refresh_tokens_.erase(account_id); 60 refresh_tokens_.erase(account_id);
61 else 61 else
62 refresh_tokens_[account_id] = refresh_token; 62 refresh_tokens_[account_id] = refresh_token;
63 } 63 }
64 64
65 virtual bool RefreshTokenIsAvailable(const std::string& account_id) const 65 bool RefreshTokenIsAvailable(const std::string& account_id) const override {
66 override {
67 std::map<std::string, std::string>::const_iterator it = 66 std::map<std::string, std::string>::const_iterator it =
68 refresh_tokens_.find(account_id); 67 refresh_tokens_.find(account_id);
69 68
70 return it != refresh_tokens_.end(); 69 return it != refresh_tokens_.end();
71 }; 70 };
72 71
73 private: 72 private:
74 // OAuth2TokenService implementation. 73 // OAuth2TokenService implementation.
75 virtual net::URLRequestContextGetter* GetRequestContext() override { 74 net::URLRequestContextGetter* GetRequestContext() override {
76 return request_context_getter_.get(); 75 return request_context_getter_.get();
77 } 76 }
78 77
79 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( 78 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher(
80 const std::string& account_id, 79 const std::string& account_id,
81 net::URLRequestContextGetter* getter, 80 net::URLRequestContextGetter* getter,
82 OAuth2AccessTokenConsumer* consumer) override { 81 OAuth2AccessTokenConsumer* consumer) override {
83 std::map<std::string, std::string>::const_iterator it = 82 std::map<std::string, std::string>::const_iterator it =
84 refresh_tokens_.find(account_id); 83 refresh_tokens_.find(account_id);
85 DCHECK(it != refresh_tokens_.end()); 84 DCHECK(it != refresh_tokens_.end());
86 std::string refresh_token(it->second); 85 std::string refresh_token(it->second);
87 return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token); 86 return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token);
88 }; 87 };
89 88
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } else if (i < j) { 641 } else if (i < j) {
643 EXPECT_TRUE(params[i] < params[j]) << " i=" << i << ", j=" << j; 642 EXPECT_TRUE(params[i] < params[j]) << " i=" << i << ", j=" << j;
644 EXPECT_FALSE(params[j] < params[i]) << " i=" << i << ", j=" << j; 643 EXPECT_FALSE(params[j] < params[i]) << " i=" << i << ", j=" << j;
645 } else { 644 } else {
646 EXPECT_TRUE(params[j] < params[i]) << " i=" << i << ", j=" << j; 645 EXPECT_TRUE(params[j] < params[i]) << " i=" << i << ", j=" << j;
647 EXPECT_FALSE(params[i] < params[j]) << " i=" << i << ", j=" << j; 646 EXPECT_FALSE(params[i] < params[j]) << " i=" << i << ", j=" << j;
648 } 647 }
649 } 648 }
650 } 649 }
651 } 650 }
OLDNEW
« no previous file with comments | « google_apis/gaia/oauth2_token_service_test_util.h ('k') | google_apis/gaia/ubertoken_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698