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

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor_unittest.cc

Issue 2958223002: Use ContainsValue() instead of std::find() in chrome/browser and chrome/common (Closed)
Patch Set: Rebase patch. Created 3 years, 5 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/predictors/autocomplete_action_predictor.h" 5 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/stl_util.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "chrome/browser/history/history_service_factory.h" 19 #include "chrome/browser/history/history_service_factory.h"
19 #include "chrome/browser/prerender/prerender_field_trial.h" 20 #include "chrome/browser/prerender/prerender_field_trial.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "components/history/core/browser/history_service.h" 23 #include "components/history/core/browser/history_service.h"
23 #include "components/history/core/browser/in_memory_database.h" 24 #include "components/history/core/browser/in_memory_database.h"
24 #include "components/history/core/browser/url_database.h" 25 #include "components/history/core/browser/url_database.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 330
330 std::vector<AutocompleteActionPredictorTable::Row::Id> id_list; 331 std::vector<AutocompleteActionPredictorTable::Row::Id> id_list;
331 DeleteOldIdsFromCaches(&id_list); 332 DeleteOldIdsFromCaches(&id_list);
332 EXPECT_EQ(expected.size(), id_list.size()); 333 EXPECT_EQ(expected.size(), id_list.size());
333 EXPECT_EQ(all_ids.size() - expected.size(), db_cache()->size()); 334 EXPECT_EQ(all_ids.size() - expected.size(), db_cache()->size());
334 EXPECT_EQ(all_ids.size() - expected.size(), db_id_cache()->size()); 335 EXPECT_EQ(all_ids.size() - expected.size(), db_id_cache()->size());
335 336
336 for (std::vector<AutocompleteActionPredictorTable::Row::Id>::iterator it = 337 for (std::vector<AutocompleteActionPredictorTable::Row::Id>::iterator it =
337 all_ids.begin(); 338 all_ids.begin();
338 it != all_ids.end(); ++it) { 339 it != all_ids.end(); ++it) {
339 bool in_expected = 340 bool in_expected = base::ContainsValue(expected, *it);
340 (std::find(expected.begin(), expected.end(), *it) != expected.end()); 341 bool in_list = base::ContainsValue(id_list, *it);
341 bool in_list =
342 (std::find(id_list.begin(), id_list.end(), *it) != id_list.end());
343 EXPECT_EQ(in_expected, in_list); 342 EXPECT_EQ(in_expected, in_list);
344 } 343 }
345 } 344 }
346 345
347 TEST_F(AutocompleteActionPredictorTest, RecommendActionURL) { 346 TEST_F(AutocompleteActionPredictorTest, RecommendActionURL) {
348 ASSERT_NO_FATAL_FAILURE(AddAllRows()); 347 ASSERT_NO_FATAL_FAILURE(AddAllRows());
349 348
350 AutocompleteMatch match; 349 AutocompleteMatch match;
351 match.type = AutocompleteMatchType::HISTORY_URL; 350 match.type = AutocompleteMatchType::HISTORY_URL;
352 351
(...skipping 18 matching lines...) Expand all
371 AutocompleteActionPredictor::ACTION_PRERENDER) ? 370 AutocompleteActionPredictor::ACTION_PRERENDER) ?
372 AutocompleteActionPredictor::ACTION_PRECONNECT : 371 AutocompleteActionPredictor::ACTION_PRECONNECT :
373 test_url_db[i].expected_action; 372 test_url_db[i].expected_action;
374 EXPECT_EQ(expected_action, 373 EXPECT_EQ(expected_action,
375 predictor()->RecommendAction(test_url_db[i].user_text, match)) 374 predictor()->RecommendAction(test_url_db[i].user_text, match))
376 << "Unexpected action for " << match.destination_url; 375 << "Unexpected action for " << match.destination_url;
377 } 376 }
378 } 377 }
379 378
380 } // namespace predictors 379 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698