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

Side by Side Diff: components/omnibox/browser/in_memory_url_index_unittest.cc

Issue 2846673006: Omnibox: Make InMemoryURLIndex respect hidden URLRows (Closed)
Patch Set: address mpearson comments Created 3 years, 7 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
« no previous file with comments | « components/history/core/browser/url_database.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <fstream> 9 #include <fstream>
10 #include <numeric> 10 #include <numeric>
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 InitializeInMemoryURLIndex(); 476 InitializeInMemoryURLIndex();
477 URLIndexPrivateData& private_data(*GetPrivateData()); 477 URLIndexPrivateData& private_data(*GetPrivateData());
478 478
479 // history_info_map_ should have the same number of items as were filtered. 479 // history_info_map_ should have the same number of items as were filtered.
480 EXPECT_EQ(1U, private_data.history_info_map_.size()); 480 EXPECT_EQ(1U, private_data.history_info_map_.size());
481 EXPECT_EQ(35U, private_data.char_word_map_.size()); 481 EXPECT_EQ(35U, private_data.char_word_map_.size());
482 EXPECT_EQ(17U, private_data.word_map_.size()); 482 EXPECT_EQ(17U, private_data.word_map_.size());
483 } 483 }
484 484
485 TEST_F(InMemoryURLIndexTest, HiddenURLRowsAreIgnored) {
486 history::URLID new_row_id = 87654321; // Arbitrarily chosen large new row id.
487 history::URLRow new_row =
488 history::URLRow(GURL("http://hidden.com/"), new_row_id++);
489 new_row.set_last_visit(base::Time::Now());
490 new_row.set_hidden(true);
491
492 EXPECT_FALSE(UpdateURL(new_row));
493 EXPECT_EQ(0U, url_index_
Peter Kasting 2017/05/04 19:17:36 Nit: EXPECT_TRUE(...empty())?
tommycli 2017/05/08 15:44:45 Well... I didn't do that because everywhere else i
494 ->HistoryItemsForTerms(ASCIIToUTF16("hidden"),
495 base::string16::npos, kMaxMatches)
496 .size());
497 }
498
485 TEST_F(InMemoryURLIndexTest, Retrieval) { 499 TEST_F(InMemoryURLIndexTest, Retrieval) {
486 // See if a very specific term gives a single result. 500 // See if a very specific term gives a single result.
487 ScoredHistoryMatches matches = url_index_->HistoryItemsForTerms( 501 ScoredHistoryMatches matches = url_index_->HistoryItemsForTerms(
488 ASCIIToUTF16("DrudgeReport"), base::string16::npos, kMaxMatches); 502 ASCIIToUTF16("DrudgeReport"), base::string16::npos, kMaxMatches);
489 ASSERT_EQ(1U, matches.size()); 503 ASSERT_EQ(1U, matches.size());
490 504
491 // Verify that we got back the result we expected. 505 // Verify that we got back the result we expected.
492 EXPECT_EQ(5, matches[0].url_info.id()); 506 EXPECT_EQ(5, matches[0].url_info.id());
493 EXPECT_EQ("http://drudgereport.com/", matches[0].url_info.url().spec()); 507 EXPECT_EQ("http://drudgereport.com/", matches[0].url_info.url().spec());
494 EXPECT_EQ(ASCIIToUTF16("DRUDGE REPORT 2010"), matches[0].url_info.title()); 508 EXPECT_EQ(ASCIIToUTF16("DRUDGE REPORT 2010"), matches[0].url_info.title());
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 ASSERT_TRUE(GetCacheFilePath(&full_file_path)); 1418 ASSERT_TRUE(GetCacheFilePath(&full_file_path));
1405 std::vector<base::FilePath::StringType> actual_parts; 1419 std::vector<base::FilePath::StringType> actual_parts;
1406 full_file_path.GetComponents(&actual_parts); 1420 full_file_path.GetComponents(&actual_parts);
1407 ASSERT_EQ(expected_parts.size(), actual_parts.size()); 1421 ASSERT_EQ(expected_parts.size(), actual_parts.size());
1408 size_t count = expected_parts.size(); 1422 size_t count = expected_parts.size();
1409 for (size_t i = 0; i < count; ++i) 1423 for (size_t i = 0; i < count; ++i)
1410 EXPECT_EQ(expected_parts[i], actual_parts[i]); 1424 EXPECT_EQ(expected_parts[i], actual_parts[i]);
1411 // Must clear the history_dir_ to satisfy the dtor's DCHECK. 1425 // Must clear the history_dir_ to satisfy the dtor's DCHECK.
1412 set_history_dir(base::FilePath()); 1426 set_history_dir(base::FilePath());
1413 } 1427 }
OLDNEW
« no previous file with comments | « components/history/core/browser/url_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698