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

Unified Diff: content/browser/download/download_query_unittest.cc

Issue 7825035: Implement chrome.experimental.downloads.search() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 years, 2 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
Index: content/browser/download/download_query_unittest.cc
diff --git a/content/browser/download/download_query_unittest.cc b/content/browser/download/download_query_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2b01106b579e856c26e2e4dc14039c31caf4fabd
--- /dev/null
+++ b/content/browser/download/download_query_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 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 "base/stl_util.h"
+#include "content/browser/download/download_query.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using download_util::DownloadQuery;
+
+class MockDownloadItem : public DownloadItemInterface {
+ public:
+};
+
+class DownloadQueryTest : public testing::Test {
+ public:
+ DownloadQueryTest() {}
+ virtual ~DownloadQueryTest() {}
+ virtual void TearDown() {
+ STLDeleteElements(&all_items_);
+ }
+ DownloadQuery* query() { return &query_; }
+ DownloadQuery::DownloadItems* all_items() { return &all_items_; }
+ DownloadQuery::DownloadItems* results() { return &results; }
+ void Search() {
+ query()->Search(all_items_, &results_);
+ }
+
+ private:
+ DownloadQuery query_;
+ DownloadQuery::DownloadItems all_items_;
+ DownloadQuery::DownloadItems results_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadQueryTest);
+};
+
+TEST_F(DownloadQueryTest, EmptyQueryNoItems) {
+ Search();
+ EXPECT_EQ(0, results()->size());
+}
+
+TEST_F(DownloadQueryTest, EmptyQuerySomeItems) {
+ all_items()->push_back(new MockDownloadItem(0));
+ all_items()->push_back(new MockDownloadItem(1));
+ all_items()->push_back(new MockDownloadItem(2));
+ Search();
+ EXPECT_EQ(3, results()->size());
+}

Powered by Google App Engine
This is Rietveld 408576698