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

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

Issue 12686006: Rename GoogleServiceAuthError::None() to AuthErrorNone() and LoginFailure::None() to LoginFailureNo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 4
5 #include "base/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "chrome/browser/signin/oauth2_token_service.h" 6 #include "chrome/browser/signin/oauth2_token_service.h"
7 #include "chrome/browser/signin/oauth2_token_service_factory.h" 7 #include "chrome/browser/signin/oauth2_token_service_factory.h"
8 #include "chrome/browser/signin/token_service_factory.h" 8 #include "chrome/browser/signin/token_service_factory.h"
9 #include "chrome/browser/signin/token_service_unittest.h" 9 #include "chrome/browser/signin/token_service_unittest.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 17 matching lines...) Expand all
28 28
29 std::string GetValidTokenResponse(std::string token, int expiration) { 29 std::string GetValidTokenResponse(std::string token, int expiration) {
30 return base::StringPrintf(kValidTokenResponse, token.c_str(), expiration); 30 return base::StringPrintf(kValidTokenResponse, token.c_str(), expiration);
31 } 31 }
32 32
33 // A simple testing consumer. 33 // A simple testing consumer.
34 class TestingOAuth2TokenServiceConsumer : public OAuth2TokenService::Consumer { 34 class TestingOAuth2TokenServiceConsumer : public OAuth2TokenService::Consumer {
35 public: 35 public:
36 TestingOAuth2TokenServiceConsumer() 36 TestingOAuth2TokenServiceConsumer()
37 : number_of_correct_tokens_(0), 37 : number_of_correct_tokens_(0),
38 last_error_(GoogleServiceAuthError::None()), 38 last_error_(GoogleServiceAuthError::AuthErrorNone()),
39 number_of_errors_(0) {} 39 number_of_errors_(0) {}
40 virtual ~TestingOAuth2TokenServiceConsumer() {} 40 virtual ~TestingOAuth2TokenServiceConsumer() {}
41 41
42 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 42 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
43 const std::string& token, 43 const std::string& token,
44 const base::Time& expiration_date) OVERRIDE { 44 const base::Time& expiration_date) OVERRIDE {
45 last_token_ = token; 45 last_token_ = token;
46 ++number_of_correct_tokens_; 46 ++number_of_correct_tokens_;
47 } 47 }
48 48
(...skipping 10 matching lines...) Expand all
59 }; 59 };
60 60
61 // A testing consumer that retries on error. 61 // A testing consumer that retries on error.
62 class RetryingTestingOAuth2TokenServiceConsumer 62 class RetryingTestingOAuth2TokenServiceConsumer
63 : public OAuth2TokenService::Consumer { 63 : public OAuth2TokenService::Consumer {
64 public: 64 public:
65 RetryingTestingOAuth2TokenServiceConsumer( 65 RetryingTestingOAuth2TokenServiceConsumer(
66 OAuth2TokenService* oauth2_service) 66 OAuth2TokenService* oauth2_service)
67 : oauth2_service_(oauth2_service), 67 : oauth2_service_(oauth2_service),
68 number_of_correct_tokens_(0), 68 number_of_correct_tokens_(0),
69 last_error_(GoogleServiceAuthError::None()), 69 last_error_(GoogleServiceAuthError::AuthErrorNone()),
70 number_of_errors_(0) {} 70 number_of_errors_(0) {}
71 virtual ~RetryingTestingOAuth2TokenServiceConsumer() {} 71 virtual ~RetryingTestingOAuth2TokenServiceConsumer() {}
72 72
73 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 73 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
74 const std::string& token, 74 const std::string& token,
75 const base::Time& expiration_date) OVERRIDE { 75 const base::Time& expiration_date) OVERRIDE {
76 last_token_ = token; 76 last_token_ = token;
77 ++number_of_correct_tokens_; 77 ++number_of_correct_tokens_;
78 } 78 }
79 79
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 EXPECT_EQ(1, consumer.number_of_errors_); 492 EXPECT_EQ(1, consumer.number_of_errors_);
493 493
494 fetcher = factory_.GetFetcherByID(0); 494 fetcher = factory_.GetFetcherByID(0);
495 EXPECT_TRUE(fetcher); 495 EXPECT_TRUE(fetcher);
496 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); 496 fetcher->set_response_code(net::HTTP_UNAUTHORIZED);
497 fetcher->SetResponseString(""); 497 fetcher->SetResponseString("");
498 fetcher->delegate()->OnURLFetchComplete(fetcher); 498 fetcher->delegate()->OnURLFetchComplete(fetcher);
499 EXPECT_EQ(0, consumer.number_of_correct_tokens_); 499 EXPECT_EQ(0, consumer.number_of_correct_tokens_);
500 EXPECT_EQ(2, consumer.number_of_errors_); 500 EXPECT_EQ(2, consumer.number_of_errors_);
501 } 501 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/oauth2_token_service_request_unittest.cc ('k') | chrome/browser/signin/signin_global_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698