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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | |
11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/thread_task_runner_handle.h" |
12 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
13 #include "components/signin/core/browser/account_service_flag_fetcher.h" | 13 #include "components/signin/core/browser/account_service_flag_fetcher.h" |
14 #include "google_apis/gaia/gaia_urls.h" | 14 #include "google_apis/gaia/gaia_urls.h" |
15 #include "net/url_request/test_url_fetcher_factory.h" | 15 #include "net/url_request/test_url_fetcher_factory.h" |
16 #include "net/url_request/url_request_test_util.h" | 16 #include "net/url_request/url_request_test_util.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 const char kAccountId[] = "user@gmail.com"; | 20 const char kAccountId[] = "user@gmail.com"; |
21 const char kDifferentAccountId[] = "some_other_user@gmail.com"; | 21 const char kDifferentAccountId[] = "some_other_user@gmail.com"; |
22 | 22 |
23 const int kGaiaAuthFetcherURLFetcherID = 0; | 23 const int kGaiaAuthFetcherURLFetcherID = 0; |
24 | 24 |
25 // TODO(treib): This class should really live in components/signin/ next to the | 25 // TODO(treib): This class should really live in components/signin/ next to the |
26 // AccountServiceFlagFetcher, but it uses the FakePO2TS which lives in | 26 // AccountServiceFlagFetcher, but it uses the FakePO2TS which lives in |
27 // chrome/browser/ (because it uses the AndroidPO2TS which depends on stuff from | 27 // chrome/browser/ (because it uses the AndroidPO2TS which depends on stuff from |
28 // chrome/browser/). So when the AndroidPO2TS is componentized, then this should | 28 // chrome/browser/). So when the AndroidPO2TS is componentized, then this should |
29 // move as well. | 29 // move as well. |
30 class AccountServiceFlagFetcherTest : public testing::Test { | 30 class AccountServiceFlagFetcherTest : public testing::Test { |
31 public: | 31 public: |
32 AccountServiceFlagFetcherTest() | 32 AccountServiceFlagFetcherTest() |
33 : request_context_(new net::TestURLRequestContextGetter( | 33 : request_context_(new net::TestURLRequestContextGetter( |
34 base::MessageLoopProxy::current())) { | 34 base::ThreadTaskRunnerHandle::Get())) { |
35 service_flags_.push_back("some_flag"); | 35 service_flags_.push_back("some_flag"); |
36 service_flags_.push_back("another_flag"); | 36 service_flags_.push_back("another_flag"); |
37 service_flags_.push_back("andonemore"); | 37 service_flags_.push_back("andonemore"); |
38 } | 38 } |
39 | 39 |
40 MOCK_METHOD2(OnFlagsFetched, | 40 MOCK_METHOD2(OnFlagsFetched, |
41 void(AccountServiceFlagFetcher::ResultCode result, | 41 void(AccountServiceFlagFetcher::ResultCode result, |
42 const std::vector<std::string>& flags)); | 42 const std::vector<std::string>& flags)); |
43 | 43 |
44 protected: | 44 protected: |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 token_service_.IssueAllTokensForAccount( | 300 token_service_.IssueAllTokensForAccount( |
301 kAccountId, | 301 kAccountId, |
302 "access_token", | 302 "access_token", |
303 base::Time::Now() + base::TimeDelta::FromHours(1)); | 303 base::Time::Now() + base::TimeDelta::FromHours(1)); |
304 | 304 |
305 SendValidLoginResponse(); | 305 SendValidLoginResponse(); |
306 // Do not send a GetUserInfo response, but make sure the request is there. | 306 // Do not send a GetUserInfo response, but make sure the request is there. |
307 GetGetUserInfoURLFetcher(); | 307 GetGetUserInfoURLFetcher(); |
308 } | 308 } |
OLD | NEW |