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/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/thread_task_runner_handle.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
14 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h" | 14 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.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"; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return result; | 101 return result; |
102 } | 102 } |
103 | 103 |
104 } // namespace | 104 } // namespace |
105 | 105 |
106 class FamilyInfoFetcherTest : public testing::Test, | 106 class FamilyInfoFetcherTest : public testing::Test, |
107 public FamilyInfoFetcher::Consumer { | 107 public FamilyInfoFetcher::Consumer { |
108 public: | 108 public: |
109 FamilyInfoFetcherTest() | 109 FamilyInfoFetcherTest() |
110 : request_context_(new net::TestURLRequestContextGetter( | 110 : request_context_(new net::TestURLRequestContextGetter( |
111 base::MessageLoopProxy::current())), | 111 base::ThreadTaskRunnerHandle::Get())), |
112 fetcher_(this, kAccountId, &token_service_, request_context_.get()) { | 112 fetcher_(this, kAccountId, &token_service_, request_context_.get()) {} |
113 } | |
114 | 113 |
115 MOCK_METHOD1(OnGetFamilyProfileSuccess, | 114 MOCK_METHOD1(OnGetFamilyProfileSuccess, |
116 void(const FamilyInfoFetcher::FamilyProfile& family)); | 115 void(const FamilyInfoFetcher::FamilyProfile& family)); |
117 MOCK_METHOD1(OnGetFamilyMembersSuccess, | 116 MOCK_METHOD1(OnGetFamilyMembersSuccess, |
118 void(const std::vector<FamilyInfoFetcher::FamilyMember>& | 117 void(const std::vector<FamilyInfoFetcher::FamilyMember>& |
119 members)); | 118 members)); |
120 MOCK_METHOD1(OnFailure, void(FamilyInfoFetcher::ErrorCode error)); | 119 MOCK_METHOD1(OnFailure, void(FamilyInfoFetcher::ErrorCode error)); |
121 | 120 |
122 protected: | 121 protected: |
123 void IssueRefreshToken() { | 122 void IssueRefreshToken() { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 IssueRefreshToken(); | 312 IssueRefreshToken(); |
314 | 313 |
315 fetcher_.StartGetFamilyProfile(); | 314 fetcher_.StartGetFamilyProfile(); |
316 | 315 |
317 IssueAccessToken(); | 316 IssueAccessToken(); |
318 | 317 |
319 // Failed API call should result in a network error. | 318 // Failed API call should result in a network error. |
320 EXPECT_CALL(*this, OnFailure(FamilyInfoFetcher::NETWORK_ERROR)); | 319 EXPECT_CALL(*this, OnFailure(FamilyInfoFetcher::NETWORK_ERROR)); |
321 SendFailedResponse(); | 320 SendFailedResponse(); |
322 } | 321 } |
OLD | NEW |