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

Unified Diff: chrome/browser/extensions/api/downloads/downloads_api_unittest.cc

Issue 2956213003: Statically allocate extension download lookups. (Closed)
Patch Set: Better tests Created 3 years, 6 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 | « chrome/browser/extensions/api/downloads/downloads_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
diff --git a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
index a2b8a6b229d5c844787fc9b673da09e0d728d0b0..5e9a6d15010305972b4550be705e6e99e4430037 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/api/downloads/downloads_api.h"
+#include <algorithm>
+
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/download/download_core_service_factory.h"
@@ -127,4 +129,49 @@ TEST_F(DownloadsApiUnitTest, ParseSearchQuery) {
RunFunction(new DownloadsSearchFunction, "[{\"totalBytesGreater\":2}]");
}
+// Marked as an "internal" unit test because it doesn't use the TEST_F macro so
+// the name must be different.
+TEST(DownloadsApiInternalUnitTest, FilterTypeSorted) {
+ struct KeyCompare {
+ bool operator()(const DownloadQueryFilterTypePair& a,
+ const DownloadQueryFilterTypePair& b) const {
+ return strcmp(a.first, b.first) < 0;
+ }
+ };
+ EXPECT_TRUE(std::is_sorted(DownloadQueryFilterTypeBeginForTest(),
+ DownloadQueryFilterTypeEndForTest(),
+ KeyCompare()));
+
+ // All items should be found.
+ for (const DownloadQueryFilterTypePair* cur =
+ DownloadQueryFilterTypeBeginForTest();
+ cur != DownloadQueryFilterTypeEndForTest(); ++cur) {
+ EXPECT_EQ(cur, FindDownloadFilterTypeByString(cur->first));
+ }
+
+ EXPECT_EQ(nullptr, FindDownloadFilterTypeByString("NOTFOUND"));
+}
+
+// Marked as an "internal" unit test because it doesn't use the TEST_F macro so
+// the name must be different.
+TEST(DownloadsApiInternalUnitTest, SortTypeSorted) {
+ struct KeyCompare {
+ bool operator()(const DownloadQuerySortTypePair& a,
+ const DownloadQuerySortTypePair& b) const {
+ return strcmp(a.first, b.first) < 0;
+ }
+ };
+ EXPECT_TRUE(std::is_sorted(DownloadQuerySortTypeBeginForTest(),
+ DownloadQuerySortTypeEndForTest(), KeyCompare()));
+
+ // All items should be found.
+ for (const DownloadQuerySortTypePair* cur =
+ DownloadQuerySortTypeBeginForTest();
+ cur != DownloadQuerySortTypeEndForTest(); ++cur) {
+ EXPECT_EQ(cur, FindDownloadSortTypeByString(cur->first));
+ }
+
+ EXPECT_EQ(nullptr, FindDownloadSortTypeByString("NOTFOUND"));
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/downloads/downloads_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698