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

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

Issue 2666093002: Remove base::FundamentalValue (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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 std::vector<content::MockDownloadItem*> mocks_; 108 std::vector<content::MockDownloadItem*> mocks_;
109 std::vector<std::unique_ptr<content::MockDownloadItem>> owned_mocks_; 109 std::vector<std::unique_ptr<content::MockDownloadItem>> owned_mocks_;
110 DownloadQuery query_; 110 DownloadQuery query_;
111 DownloadVector results_; 111 DownloadVector results_;
112 112
113 DISALLOW_COPY_AND_ASSIGN(DownloadQueryTest); 113 DISALLOW_COPY_AND_ASSIGN(DownloadQueryTest);
114 }; 114 };
115 115
116 template<> void DownloadQueryTest::AddFilter( 116 template<> void DownloadQueryTest::AddFilter(
117 DownloadQuery::FilterType name, bool cpp_value) { 117 DownloadQuery::FilterType name, bool cpp_value) {
118 std::unique_ptr<base::Value> value(new base::FundamentalValue(cpp_value)); 118 std::unique_ptr<base::Value> value(new base::Value(cpp_value));
119 CHECK(query_.AddFilter(name, *value.get())); 119 CHECK(query_.AddFilter(name, *value.get()));
120 } 120 }
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::FundamentalValue(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::StringValue(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) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 CHECK(query_.AddFilter(name, base::StringValue(cpp_value))); 167 CHECK(query_.AddFilter(name, base::StringValue(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::FundamentalValue(0)); 177 std::unique_ptr<base::Value> value(new base::Value(0));
178 EXPECT_FALSE(query()->AddFilter(static_cast<DownloadQuery::FilterType>( 178 EXPECT_FALSE(query()->AddFilter(static_cast<DownloadQuery::FilterType>(
179 std::numeric_limits<int32_t>::max()), 179 std::numeric_limits<int32_t>::max()),
180 *value.get())); 180 *value.get()));
181 } 181 }
182 182
183 TEST_F(DownloadQueryTest, DownloadQueryTest_EmptyQuery) { 183 TEST_F(DownloadQueryTest, DownloadQueryTest_EmptyQuery) {
184 CreateMocks(2); 184 CreateMocks(2);
185 Search(); 185 Search();
186 ASSERT_EQ(2U, results()->size()); 186 ASSERT_EQ(2U, results()->size());
187 ASSERT_EQ(0U, results()->at(0)->GetId()); 187 ASSERT_EQ(0U, results()->at(0)->GetId());
(...skipping 604 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
« no previous file with comments | « chrome/browser/download/download_query.h ('k') | chrome/browser/extensions/api/automation_internal/automation_internal_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698