| 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 "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h" | 5 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 19 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/url_request/test_url_fetcher_factory.h" | 21 #include "net/url_request/test_url_fetcher_factory.h" |
| 21 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 account1.profile_image_url == account2.profile_image_url; | 43 account1.profile_image_url == account2.profile_image_url; |
| 43 } | 44 } |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 std::string BuildGetFamilyProfileResponse( | 48 std::string BuildGetFamilyProfileResponse( |
| 48 const FamilyInfoFetcher::FamilyProfile& family) { | 49 const FamilyInfoFetcher::FamilyProfile& family) { |
| 49 base::DictionaryValue dict; | 50 base::DictionaryValue dict; |
| 50 base::DictionaryValue* family_dict = new base::DictionaryValue; | 51 base::DictionaryValue* family_dict = new base::DictionaryValue; |
| 51 family_dict->SetStringWithoutPathExpansion("familyId", family.id); | 52 family_dict->SetStringWithoutPathExpansion("familyId", family.id); |
| 52 base::DictionaryValue* profile_dict = new base::DictionaryValue; | 53 std::unique_ptr<base::DictionaryValue> profile_dict = |
| 54 base::MakeUnique<base::DictionaryValue>(); |
| 53 profile_dict->SetStringWithoutPathExpansion("name", family.name); | 55 profile_dict->SetStringWithoutPathExpansion("name", family.name); |
| 54 family_dict->SetWithoutPathExpansion("profile", profile_dict); | 56 family_dict->SetWithoutPathExpansion("profile", std::move(profile_dict)); |
| 55 dict.SetWithoutPathExpansion("family", family_dict); | 57 dict.SetWithoutPathExpansion("family", family_dict); |
| 56 std::string result; | 58 std::string result; |
| 57 base::JSONWriter::Write(dict, &result); | 59 base::JSONWriter::Write(dict, &result); |
| 58 return result; | 60 return result; |
| 59 } | 61 } |
| 60 | 62 |
| 61 std::string BuildEmptyGetFamilyProfileResponse() { | 63 std::string BuildEmptyGetFamilyProfileResponse() { |
| 62 base::DictionaryValue dict; | 64 base::DictionaryValue dict; |
| 63 base::DictionaryValue* family_dict = new base::DictionaryValue; | 65 base::DictionaryValue* family_dict = new base::DictionaryValue; |
| 64 dict.SetWithoutPathExpansion("family", family_dict); | 66 dict.SetWithoutPathExpansion("family", family_dict); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 IssueRefreshToken(); | 316 IssueRefreshToken(); |
| 315 | 317 |
| 316 fetcher_.StartGetFamilyProfile(); | 318 fetcher_.StartGetFamilyProfile(); |
| 317 | 319 |
| 318 IssueAccessToken(); | 320 IssueAccessToken(); |
| 319 | 321 |
| 320 // Failed API call should result in a network error. | 322 // Failed API call should result in a network error. |
| 321 EXPECT_CALL(*this, OnFailure(FamilyInfoFetcher::NETWORK_ERROR)); | 323 EXPECT_CALL(*this, OnFailure(FamilyInfoFetcher::NETWORK_ERROR)); |
| 322 SendFailedResponse(); | 324 SendFailedResponse(); |
| 323 } | 325 } |
| OLD | NEW |