| 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/permission_request_creat
or_apiary.h" | 5 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat
or_apiary.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/values.h" | 14 #include "base/values.h" |
| 13 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 15 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
| 14 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 15 #include "net/url_request/test_url_fetcher_factory.h" | 17 #include "net/url_request/test_url_fetcher_factory.h" |
| 16 #include "net/url_request/url_request_test_util.h" | 18 #include "net/url_request/url_request_test_util.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 const char kAccountId[] = "account@gmail.com"; | 24 const char kAccountId[] = "account@gmail.com"; |
| 23 | 25 |
| 24 std::string BuildResponse() { | 26 std::string BuildResponse() { |
| 25 base::DictionaryValue dict; | 27 base::DictionaryValue dict; |
| 26 base::DictionaryValue* permission_dict = new base::DictionaryValue; | 28 auto permission_dict = base::MakeUnique<base::DictionaryValue>(); |
| 27 permission_dict->SetStringWithoutPathExpansion("id", "requestid"); | 29 permission_dict->SetStringWithoutPathExpansion("id", "requestid"); |
| 28 dict.SetWithoutPathExpansion("permissionRequest", permission_dict); | 30 dict.SetWithoutPathExpansion("permissionRequest", std::move(permission_dict)); |
| 29 std::string result; | 31 std::string result; |
| 30 base::JSONWriter::Write(dict, &result); | 32 base::JSONWriter::Write(dict, &result); |
| 31 return result; | 33 return result; |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 class PermissionRequestCreatorApiaryTest : public testing::Test { | 38 class PermissionRequestCreatorApiaryTest : public testing::Test { |
| 37 public: | 39 public: |
| 38 PermissionRequestCreatorApiaryTest() | 40 PermissionRequestCreatorApiaryTest() |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 132 |
| 131 // We should have gotten a request for an access token. | 133 // We should have gotten a request for an access token. |
| 132 EXPECT_EQ(1U, token_service_.GetPendingRequests().size()); | 134 EXPECT_EQ(1U, token_service_.GetPendingRequests().size()); |
| 133 | 135 |
| 134 IssueAccessTokens(); | 136 IssueAccessTokens(); |
| 135 | 137 |
| 136 // Our callback should get called on an error. | 138 // Our callback should get called on an error. |
| 137 EXPECT_CALL(*this, OnRequestCreated(false)); | 139 EXPECT_CALL(*this, OnRequestCreated(false)); |
| 138 SendFailedResponse(0); | 140 SendFailedResponse(0); |
| 139 } | 141 } |
| OLD | NEW |