OLD | NEW |
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 "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 5 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 8 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
9 #include "components/signin/core/browser/signin_error_controller.h" | 9 #include "components/signin/core/browser/signin_error_controller.h" |
10 #include "components/signin/core/browser/test_signin_client.h" | 10 #include "components/signin/core/browser/test_signin_client.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public OAuth2TokenService::Observer { | 30 public OAuth2TokenService::Observer { |
31 public: | 31 public: |
32 MutableProfileOAuth2TokenServiceTest() | 32 MutableProfileOAuth2TokenServiceTest() |
33 : factory_(NULL), | 33 : factory_(NULL), |
34 token_available_count_(0), | 34 token_available_count_(0), |
35 token_revoked_count_(0), | 35 token_revoked_count_(0), |
36 tokens_loaded_count_(0), | 36 tokens_loaded_count_(0), |
37 start_batch_changes_(0), | 37 start_batch_changes_(0), |
38 end_batch_changes_(0) {} | 38 end_batch_changes_(0) {} |
39 | 39 |
40 virtual void SetUp() override { | 40 void SetUp() override { |
41 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
42 OSCrypt::UseMockKeychain(true); | 42 OSCrypt::UseMockKeychain(true); |
43 #endif | 43 #endif |
44 | 44 |
45 factory_.SetFakeResponse(GaiaUrls::GetInstance()->oauth2_revoke_url(), | 45 factory_.SetFakeResponse(GaiaUrls::GetInstance()->oauth2_revoke_url(), |
46 "", | 46 "", |
47 net::HTTP_OK, | 47 net::HTTP_OK, |
48 net::URLRequestStatus::SUCCESS); | 48 net::URLRequestStatus::SUCCESS); |
49 oauth2_service_.Initialize(&client_); | 49 oauth2_service_.Initialize(&client_); |
50 // Make sure PO2TS has a chance to load itself before continuing. | 50 // Make sure PO2TS has a chance to load itself before continuing. |
51 base::RunLoop().RunUntilIdle(); | 51 base::RunLoop().RunUntilIdle(); |
52 oauth2_service_.AddObserver(this); | 52 oauth2_service_.AddObserver(this); |
53 } | 53 } |
54 | 54 |
55 virtual void TearDown() override { | 55 void TearDown() override { |
56 oauth2_service_.RemoveObserver(this); | 56 oauth2_service_.RemoveObserver(this); |
57 oauth2_service_.Shutdown(); | 57 oauth2_service_.Shutdown(); |
58 } | 58 } |
59 | 59 |
60 void AddAuthTokenManually(const std::string& service, | 60 void AddAuthTokenManually(const std::string& service, |
61 const std::string& value) { | 61 const std::string& value) { |
62 scoped_refptr<TokenWebData> token_web_data = client_.GetDatabase(); | 62 scoped_refptr<TokenWebData> token_web_data = client_.GetDatabase(); |
63 if (token_web_data.get()) | 63 if (token_web_data.get()) |
64 token_web_data->SetTokenForService(service, value); | 64 token_web_data->SetTokenForService(service, value); |
65 } | 65 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 tokens["AccountId-user@gmail.com"] = "refresh_token"; | 370 tokens["AccountId-user@gmail.com"] = "refresh_token"; |
371 tokens["AccountId-Foo.Bar@gmail.com"] = "refresh_token"; | 371 tokens["AccountId-Foo.Bar@gmail.com"] = "refresh_token"; |
372 tokens["AccountId-12345"] = "refresh_token"; | 372 tokens["AccountId-12345"] = "refresh_token"; |
373 | 373 |
374 oauth2_service_.LoadAllCredentialsIntoMemory(tokens); | 374 oauth2_service_.LoadAllCredentialsIntoMemory(tokens); |
375 | 375 |
376 EXPECT_TRUE(oauth2_service_.RefreshTokenIsAvailable("user@gmail.com")); | 376 EXPECT_TRUE(oauth2_service_.RefreshTokenIsAvailable("user@gmail.com")); |
377 EXPECT_TRUE(oauth2_service_.RefreshTokenIsAvailable("foobar@gmail.com")); | 377 EXPECT_TRUE(oauth2_service_.RefreshTokenIsAvailable("foobar@gmail.com")); |
378 EXPECT_TRUE(oauth2_service_.RefreshTokenIsAvailable("12345")); | 378 EXPECT_TRUE(oauth2_service_.RefreshTokenIsAvailable("12345")); |
379 } | 379 } |
OLD | NEW |