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

Side by Side Diff: chrome/browser/download/download_query_unittest.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/download/download_query.h" 5 #include "chrome/browser/download/download_query.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 template <> 122 template <>
123 void DownloadQueryTest::AddFilter(DownloadQuery::FilterType name, 123 void DownloadQueryTest::AddFilter(DownloadQuery::FilterType name,
124 double cpp_value) { 124 double cpp_value) {
125 std::unique_ptr<base::Value> value(new base::Value(cpp_value)); 125 std::unique_ptr<base::Value> value(new base::Value(cpp_value));
126 CHECK(query_.AddFilter(name, *value.get())); 126 CHECK(query_.AddFilter(name, *value.get()));
127 } 127 }
128 128
129 template<> void DownloadQueryTest::AddFilter( 129 template<> void DownloadQueryTest::AddFilter(
130 DownloadQuery::FilterType name, const char* cpp_value) { 130 DownloadQuery::FilterType name, const char* cpp_value) {
131 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); 131 CHECK(query_.AddFilter(name, base::Value(cpp_value)));
132 } 132 }
133 133
134 template<> void DownloadQueryTest::AddFilter( 134 template<> void DownloadQueryTest::AddFilter(
135 DownloadQuery::FilterType name, std::string cpp_value) { 135 DownloadQuery::FilterType name, std::string cpp_value) {
136 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); 136 CHECK(query_.AddFilter(name, base::Value(cpp_value)));
137 } 137 }
138 138
139 template<> void DownloadQueryTest::AddFilter( 139 template<> void DownloadQueryTest::AddFilter(
140 DownloadQuery::FilterType name, const base::char16* cpp_value) { 140 DownloadQuery::FilterType name, const base::char16* cpp_value) {
141 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); 141 CHECK(query_.AddFilter(name, base::Value(cpp_value)));
142 } 142 }
143 143
144 template<> void DownloadQueryTest::AddFilter( 144 template<> void DownloadQueryTest::AddFilter(
145 DownloadQuery::FilterType name, std::vector<base::string16> cpp_value) { 145 DownloadQuery::FilterType name, std::vector<base::string16> cpp_value) {
146 std::unique_ptr<base::ListValue> list(new base::ListValue()); 146 std::unique_ptr<base::ListValue> list(new base::ListValue());
147 for (std::vector<base::string16>::const_iterator it = cpp_value.begin(); 147 for (std::vector<base::string16>::const_iterator it = cpp_value.begin();
148 it != cpp_value.end(); ++it) { 148 it != cpp_value.end(); ++it) {
149 list->AppendString(*it); 149 list->AppendString(*it);
150 } 150 }
151 CHECK(query_.AddFilter(name, *list.get())); 151 CHECK(query_.AddFilter(name, *list.get()));
152 } 152 }
153 153
154 template<> void DownloadQueryTest::AddFilter( 154 template<> void DownloadQueryTest::AddFilter(
155 DownloadQuery::FilterType name, std::vector<std::string> cpp_value) { 155 DownloadQuery::FilterType name, std::vector<std::string> cpp_value) {
156 std::unique_ptr<base::ListValue> list(new base::ListValue()); 156 std::unique_ptr<base::ListValue> list(new base::ListValue());
157 for (std::vector<std::string>::const_iterator it = cpp_value.begin(); 157 for (std::vector<std::string>::const_iterator it = cpp_value.begin();
158 it != cpp_value.end(); ++it) { 158 it != cpp_value.end(); ++it) {
159 list->AppendString(*it); 159 list->AppendString(*it);
160 } 160 }
161 CHECK(query_.AddFilter(name, *list.get())); 161 CHECK(query_.AddFilter(name, *list.get()));
162 } 162 }
163 163
164 #if defined(OS_WIN) 164 #if defined(OS_WIN)
165 template<> void DownloadQueryTest::AddFilter( 165 template<> void DownloadQueryTest::AddFilter(
166 DownloadQuery::FilterType name, std::wstring cpp_value) { 166 DownloadQuery::FilterType name, std::wstring cpp_value) {
167 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); 167 CHECK(query_.AddFilter(name, base::Value(cpp_value)));
168 } 168 }
169 #endif 169 #endif
170 170
171 TEST_F(DownloadQueryTest, DownloadQueryTest_ZeroItems) { 171 TEST_F(DownloadQueryTest, DownloadQueryTest_ZeroItems) {
172 Search(); 172 Search();
173 EXPECT_EQ(0U, results()->size()); 173 EXPECT_EQ(0U, results()->size());
174 } 174 }
175 175
176 TEST_F(DownloadQueryTest, DownloadQueryTest_InvalidFilter) { 176 TEST_F(DownloadQueryTest, DownloadQueryTest_InvalidFilter) {
177 std::unique_ptr<base::Value> value(new base::Value(0)); 177 std::unique_ptr<base::Value> value(new base::Value(0));
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 base::Time start = base::Time::Now(); 792 base::Time start = base::Time::Now();
793 Search(); 793 Search();
794 base::Time end = base::Time::Now(); 794 base::Time end = base::Time::Now();
795 double nanos = (end - start).InMillisecondsF() * 1000.0 * 1000.0; 795 double nanos = (end - start).InMillisecondsF() * 1000.0 * 1000.0;
796 double nanos_per_item = nanos / static_cast<double>(kNumItems); 796 double nanos_per_item = nanos / static_cast<double>(kNumItems);
797 double nanos_per_item_per_filter = nanos_per_item 797 double nanos_per_item_per_filter = nanos_per_item
798 / static_cast<double>(kNumFilters); 798 / static_cast<double>(kNumFilters);
799 std::cout << "Search took " << nanos_per_item_per_filter 799 std::cout << "Search took " << nanos_per_item_per_filter
800 << " nanoseconds per item per filter.\n"; 800 << " nanoseconds per item per filter.\n";
801 } 801 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698