Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: components/download/internal/client_set_unittest.cc

Issue 2895953004: Add initial Controller to DownloadService (Closed)
Patch Set: Rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/download/internal/client_set.cc ('k') | components/download/internal/config.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/download/internal/client_set_unittest.cc
diff --git a/components/download/internal/client_set_unittest.cc b/components/download/internal/client_set_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..04d454c72e354103ae52bd0b03c60e29d577ba66
--- /dev/null
+++ b/components/download/internal/client_set_unittest.cc
@@ -0,0 +1,43 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/download/internal/client_set.h"
+
+#include <algorithm>
+
+#include "base/memory/ptr_util.h"
+#include "components/download/internal/test/empty_client.h"
+#include "components/download/public/clients.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace download {
+
+TEST(DownloadServiceClientSetTest, TestGetClient) {
+ auto client = base::MakeUnique<test::EmptyClient>();
+ Client* raw_client = client.get();
+
+ auto client_map = base::MakeUnique<DownloadClientMap>();
+ client_map->insert(std::make_pair(DownloadClient::TEST, std::move(client)));
+ ClientSet clients(std::move(client_map));
+
+ EXPECT_EQ(raw_client, clients.GetClient(DownloadClient::TEST));
+ EXPECT_EQ(nullptr, clients.GetClient(DownloadClient::INVALID));
+}
+
+TEST(DownloadServiceClientSetTest, TestGetRegisteredClients) {
+ auto client = base::MakeUnique<test::EmptyClient>();
+
+ auto client_map = base::MakeUnique<DownloadClientMap>();
+ client_map->insert(std::make_pair(DownloadClient::TEST, std::move(client)));
+ ClientSet clients(std::move(client_map));
+
+ std::set<DownloadClient> expected_set = {DownloadClient::TEST};
+ std::set<DownloadClient> actual_set = clients.GetRegisteredClients();
+
+ EXPECT_EQ(expected_set.size(), actual_set.size());
+ EXPECT_TRUE(
+ std::equal(expected_set.begin(), expected_set.end(), actual_set.begin()));
+}
+
+} // namespace download
« no previous file with comments | « components/download/internal/client_set.cc ('k') | components/download/internal/config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698