OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 }; | 99 }; |
100 | 100 |
101 template<> void DownloadQueryTest::AddFilter( | 101 template<> void DownloadQueryTest::AddFilter( |
102 DownloadQuery::FilterType name, bool cpp_value) { | 102 DownloadQuery::FilterType name, bool cpp_value) { |
103 scoped_ptr<base::Value> value(new base::FundamentalValue(cpp_value)); | 103 scoped_ptr<base::Value> value(new base::FundamentalValue(cpp_value)); |
104 CHECK(query_.AddFilter(name, *value.get())); | 104 CHECK(query_.AddFilter(name, *value.get())); |
105 } | 105 } |
106 | 106 |
107 template<> void DownloadQueryTest::AddFilter( | 107 template<> void DownloadQueryTest::AddFilter( |
108 DownloadQuery::FilterType name, int cpp_value) { | 108 DownloadQuery::FilterType name, int cpp_value) { |
109 scoped_ptr<base::Value> value(base::Value::CreateIntegerValue(cpp_value)); | 109 scoped_ptr<base::Value> value(new base::FundamentalValue(cpp_value)); |
110 CHECK(query_.AddFilter(name, *value.get())); | 110 CHECK(query_.AddFilter(name, *value.get())); |
111 } | 111 } |
112 | 112 |
113 template<> void DownloadQueryTest::AddFilter( | 113 template<> void DownloadQueryTest::AddFilter( |
114 DownloadQuery::FilterType name, const char* cpp_value) { | 114 DownloadQuery::FilterType name, const char* cpp_value) { |
115 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); | 115 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); |
116 } | 116 } |
117 | 117 |
118 template<> void DownloadQueryTest::AddFilter( | 118 template<> void DownloadQueryTest::AddFilter( |
119 DownloadQuery::FilterType name, std::string cpp_value) { | 119 DownloadQuery::FilterType name, std::string cpp_value) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); | 151 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); |
152 } | 152 } |
153 #endif | 153 #endif |
154 | 154 |
155 TEST_F(DownloadQueryTest, DownloadQueryTest_ZeroItems) { | 155 TEST_F(DownloadQueryTest, DownloadQueryTest_ZeroItems) { |
156 Search(); | 156 Search(); |
157 EXPECT_EQ(0U, results()->size()); | 157 EXPECT_EQ(0U, results()->size()); |
158 } | 158 } |
159 | 159 |
160 TEST_F(DownloadQueryTest, DownloadQueryTest_InvalidFilter) { | 160 TEST_F(DownloadQueryTest, DownloadQueryTest_InvalidFilter) { |
161 scoped_ptr<base::Value> value(base::Value::CreateIntegerValue(0)); | 161 scoped_ptr<base::Value> value(new base::FundamentalValue(0)); |
162 EXPECT_FALSE(query()->AddFilter( | 162 EXPECT_FALSE(query()->AddFilter( |
163 static_cast<DownloadQuery::FilterType>(kint32max), | 163 static_cast<DownloadQuery::FilterType>(kint32max), |
164 *value.get())); | 164 *value.get())); |
165 } | 165 } |
166 | 166 |
167 TEST_F(DownloadQueryTest, DownloadQueryTest_EmptyQuery) { | 167 TEST_F(DownloadQueryTest, DownloadQueryTest_EmptyQuery) { |
168 CreateMocks(2); | 168 CreateMocks(2); |
169 Search(); | 169 Search(); |
170 ASSERT_EQ(2U, results()->size()); | 170 ASSERT_EQ(2U, results()->size()); |
171 ASSERT_EQ(0U, results()->at(0)->GetId()); | 171 ASSERT_EQ(0U, results()->at(0)->GetId()); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 base::Time start = base::Time::Now(); | 605 base::Time start = base::Time::Now(); |
606 Search(); | 606 Search(); |
607 base::Time end = base::Time::Now(); | 607 base::Time end = base::Time::Now(); |
608 double nanos = (end - start).InMillisecondsF() * 1000.0 * 1000.0; | 608 double nanos = (end - start).InMillisecondsF() * 1000.0 * 1000.0; |
609 double nanos_per_item = nanos / static_cast<double>(kNumItems); | 609 double nanos_per_item = nanos / static_cast<double>(kNumItems); |
610 double nanos_per_item_per_filter = nanos_per_item | 610 double nanos_per_item_per_filter = nanos_per_item |
611 / static_cast<double>(kNumFilters); | 611 / static_cast<double>(kNumFilters); |
612 std::cout << "Search took " << nanos_per_item_per_filter | 612 std::cout << "Search took " << nanos_per_item_per_filter |
613 << " nanoseconds per item per filter.\n"; | 613 << " nanoseconds per item per filter.\n"; |
614 } | 614 } |
OLD | NEW |