| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/download/internal/client_set.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "base/memory/ptr_util.h" |
| 10 #include "components/download/internal/test/empty_client.h" |
| 11 #include "components/download/public/clients.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace download { |
| 15 |
| 16 TEST(DownloadServiceClientSetTest, TestGetClient) { |
| 17 auto client = base::MakeUnique<test::EmptyClient>(); |
| 18 Client* raw_client = client.get(); |
| 19 |
| 20 auto client_map = base::MakeUnique<DownloadClientMap>(); |
| 21 client_map->insert(std::make_pair(DownloadClient::TEST, std::move(client))); |
| 22 ClientSet clients(std::move(client_map)); |
| 23 |
| 24 EXPECT_EQ(raw_client, clients.GetClient(DownloadClient::TEST)); |
| 25 EXPECT_EQ(nullptr, clients.GetClient(DownloadClient::INVALID)); |
| 26 } |
| 27 |
| 28 TEST(DownloadServiceClientSetTest, TestGetRegisteredClients) { |
| 29 auto client = base::MakeUnique<test::EmptyClient>(); |
| 30 |
| 31 auto client_map = base::MakeUnique<DownloadClientMap>(); |
| 32 client_map->insert(std::make_pair(DownloadClient::TEST, std::move(client))); |
| 33 ClientSet clients(std::move(client_map)); |
| 34 |
| 35 std::set<DownloadClient> expected_set = {DownloadClient::TEST}; |
| 36 std::set<DownloadClient> actual_set = clients.GetRegisteredClients(); |
| 37 |
| 38 EXPECT_EQ(expected_set.size(), actual_set.size()); |
| 39 EXPECT_TRUE( |
| 40 std::equal(expected_set.begin(), expected_set.end(), actual_set.begin())); |
| 41 } |
| 42 |
| 43 } // namespace download |
| OLD | NEW |