| 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());
|
| +}
|
|
|