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 "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 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/guid.h" | 13 #include "base/guid.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/stl_util.h" | |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
20 #include "chrome/browser/prerender/prerender_field_trial.h" | 21 #include "chrome/browser/prerender/prerender_field_trial.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
23 #include "components/history/core/browser/history_service.h" | 24 #include "components/history/core/browser/history_service.h" |
24 #include "components/history/core/browser/in_memory_database.h" | 25 #include "components/history/core/browser/in_memory_database.h" |
25 #include "components/history/core/browser/url_database.h" | 26 #include "components/history/core/browser/url_database.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 | 328 |
328 std::vector<AutocompleteActionPredictorTable::Row::Id> id_list; | 329 std::vector<AutocompleteActionPredictorTable::Row::Id> id_list; |
329 DeleteOldIdsFromCaches(&id_list); | 330 DeleteOldIdsFromCaches(&id_list); |
330 EXPECT_EQ(expected.size(), id_list.size()); | 331 EXPECT_EQ(expected.size(), id_list.size()); |
331 EXPECT_EQ(all_ids.size() - expected.size(), db_cache()->size()); | 332 EXPECT_EQ(all_ids.size() - expected.size(), db_cache()->size()); |
332 EXPECT_EQ(all_ids.size() - expected.size(), db_id_cache()->size()); | 333 EXPECT_EQ(all_ids.size() - expected.size(), db_id_cache()->size()); |
333 | 334 |
334 for (std::vector<AutocompleteActionPredictorTable::Row::Id>::iterator it = | 335 for (std::vector<AutocompleteActionPredictorTable::Row::Id>::iterator it = |
335 all_ids.begin(); | 336 all_ids.begin(); |
336 it != all_ids.end(); ++it) { | 337 it != all_ids.end(); ++it) { |
337 bool in_expected = | 338 bool in_expected = (base::ContainsValue(expected, *it)); |
Nico
2017/06/28 13:55:28
remove parens around base::ContainsValue()
Tripta
2017/06/29 08:53:10
Done.
| |
338 (std::find(expected.begin(), expected.end(), *it) != expected.end()); | 339 bool in_list = (base::ContainsValue(id_list, *it)); |
Nico
2017/06/28 13:55:28
remove parens around base::ContainsValue()
Tripta
2017/06/29 08:53:10
Done.
| |
339 bool in_list = | |
340 (std::find(id_list.begin(), id_list.end(), *it) != id_list.end()); | |
341 EXPECT_EQ(in_expected, in_list); | 340 EXPECT_EQ(in_expected, in_list); |
342 } | 341 } |
343 } | 342 } |
344 | 343 |
345 TEST_F(AutocompleteActionPredictorTest, RecommendActionURL) { | 344 TEST_F(AutocompleteActionPredictorTest, RecommendActionURL) { |
346 ASSERT_NO_FATAL_FAILURE(AddAllRows()); | 345 ASSERT_NO_FATAL_FAILURE(AddAllRows()); |
347 | 346 |
348 AutocompleteMatch match; | 347 AutocompleteMatch match; |
349 match.type = AutocompleteMatchType::HISTORY_URL; | 348 match.type = AutocompleteMatchType::HISTORY_URL; |
350 | 349 |
(...skipping 18 matching lines...) Expand all Loading... | |
369 AutocompleteActionPredictor::ACTION_PRERENDER) ? | 368 AutocompleteActionPredictor::ACTION_PRERENDER) ? |
370 AutocompleteActionPredictor::ACTION_PRECONNECT : | 369 AutocompleteActionPredictor::ACTION_PRECONNECT : |
371 test_url_db[i].expected_action; | 370 test_url_db[i].expected_action; |
372 EXPECT_EQ(expected_action, | 371 EXPECT_EQ(expected_action, |
373 predictor()->RecommendAction(test_url_db[i].user_text, match)) | 372 predictor()->RecommendAction(test_url_db[i].user_text, match)) |
374 << "Unexpected action for " << match.destination_url; | 373 << "Unexpected action for " << match.destination_url; |
375 } | 374 } |
376 } | 375 } |
377 | 376 |
378 } // namespace predictors | 377 } // namespace predictors |
OLD | NEW |