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

Unified Diff: chrome/browser/history/in_memory_url_index_unittest.cc

Issue 8359019: Create Private Data for InMemoryURLIndex (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/in_memory_url_index_types_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/in_memory_url_index_unittest.cc
===================================================================
--- chrome/browser/history/in_memory_url_index_unittest.cc (revision 107888)
+++ chrome/browser/history/in_memory_url_index_unittest.cc (working copy)
@@ -2,24 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <stdio.h>
-
#include <fstream>
-#include <string>
-#include <vector>
#include "base/file_path.h"
#include "base/file_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
+#include "base/string16.h"
#include "base/string_util.h"
-#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/history/in_memory_database.h"
#include "chrome/browser/history/in_memory_url_index.h"
+#include "chrome/browser/history/in_memory_url_index_types.h"
#include "chrome/common/chrome_paths.h"
-#include "sql/connection.h"
-#include "sql/statement.h"
#include "sql/transaction.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -59,9 +53,8 @@
int typed_count);
// Convenience functions for easily creating vectors of search terms.
- InMemoryURLIndex::String16Vector Make1Term(const char* term) const;
- InMemoryURLIndex::String16Vector Make2Terms(const char* term_1,
- const char* term_2) const;
+ String16Vector Make1Term(const char* term) const;
+ String16Vector Make2Terms(const char* term_1, const char* term_2) const;
// Validates that the given |term| is contained in |cache| and that it is
// marked as in-use.
@@ -145,20 +138,18 @@
return row;
}
-InMemoryURLIndex::String16Vector InMemoryURLIndexTest::Make1Term(
- const char* term) const {
- InMemoryURLIndex::String16Vector terms;
- terms.push_back(UTF8ToUTF16(term));
- return terms;
+String16Vector InMemoryURLIndexTest::Make1Term(const char* term) const {
+ String16Vector original_terms;
+ original_terms.push_back(UTF8ToUTF16(term));
+ return original_terms;
}
-InMemoryURLIndex::String16Vector InMemoryURLIndexTest::Make2Terms(
- const char* term_1,
- const char* term_2) const {
- InMemoryURLIndex::String16Vector terms;
- terms.push_back(UTF8ToUTF16(term_1));
- terms.push_back(UTF8ToUTF16(term_2));
- return terms;
+String16Vector InMemoryURLIndexTest::Make2Terms(const char* term_1,
+ const char* term_2) const {
+ String16Vector original_terms;
+ original_terms.push_back(UTF8ToUTF16(term_1));
+ original_terms.push_back(UTF8ToUTF16(term_2));
+ return original_terms;
}
void InMemoryURLIndexTest::CheckTerm(
@@ -173,6 +164,27 @@
<< "Cache item '" << term << "' should be marked as being in use.";
}
+// Helper function which compares two maps for equivalence. The maps' values
+// are associative containers and their contents are compared as well.
+template<typename T>
+void ExpectMapOfContainersIdentical(const T& expected, const T& actual) {
+ ASSERT_EQ(expected.size(), actual.size());
+ for (typename T::const_iterator expected_iter = expected.begin();
+ expected_iter != expected.end(); ++expected_iter) {
+ typename T::const_iterator actual_iter = actual.find(expected_iter->first);
+ ASSERT_NE(actual.end(), actual_iter);
+ typename T::mapped_type const& expected_values(expected_iter->second);
+ typename T::mapped_type const& actual_values(actual_iter->second);
+ ASSERT_EQ(expected_values.size(), actual_values.size());
+ for (typename T::mapped_type::const_iterator set_iter =
+ expected_values.begin(); set_iter != expected_values.end(); ++set_iter)
+ EXPECT_EQ(actual_values.count(*set_iter),
+ expected_values.count(*set_iter));
+ }
+}
+
+//------------------------------------------------------------------------------
+
class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest {
protected:
FilePath::StringType TestDBName() const;
@@ -217,12 +229,12 @@
EXPECT_EQ(1U, row_count);
url_index_.reset(new InMemoryURLIndex(FilePath()));
url_index_->Init(this, "en,ja,hi,zh");
- EXPECT_EQ(1, url_index_->history_item_count_);
+ URLIndexPrivateData& private_data(*(url_index_->private_data_));
// history_info_map_ should have the same number of items as were filtered.
- EXPECT_EQ(1U, url_index_->history_info_map_.size());
- EXPECT_EQ(35U, url_index_->char_word_map_.size());
- EXPECT_EQ(17U, url_index_->word_map_.size());
+ EXPECT_EQ(1U, private_data.history_info_map_.size());
+ EXPECT_EQ(35U, private_data.char_word_map_.size());
+ EXPECT_EQ(17U, private_data.word_map_.size());
}
TEST_F(InMemoryURLIndexTest, Retrieval) {
@@ -259,11 +271,11 @@
matches[0].url_info.title());
// Search which should result in very poor result.
- InMemoryURLIndex::String16Vector terms;
- terms.push_back(ASCIIToUTF16("z"));
- terms.push_back(ASCIIToUTF16("y"));
- terms.push_back(ASCIIToUTF16("x"));
- matches = url_index_->HistoryItemsForTerms(terms);
+ String16Vector original_terms;
+ original_terms.push_back(ASCIIToUTF16("z"));
+ original_terms.push_back(ASCIIToUTF16("y"));
+ original_terms.push_back(ASCIIToUTF16("x"));
+ matches = url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(1U, matches.size());
// The results should have a poor score.
EXPECT_LT(matches[0].raw_score, 500);
@@ -296,14 +308,15 @@
url_index_.reset(new InMemoryURLIndex(FilePath()));
url_index_->Init(this, "en,ja,hi,zh");
// Signal if someone has changed the test DB.
- EXPECT_EQ(27U, url_index_->history_info_map_.size());
- InMemoryURLIndex::String16Vector terms;
+ EXPECT_EQ(27U, url_index_->private_data_->history_info_map_.size());
+ String16Vector original_terms;
// Ensure title is being searched.
- terms.push_back(ASCIIToUTF16("MORTGAGE"));
- terms.push_back(ASCIIToUTF16("RATE"));
- terms.push_back(ASCIIToUTF16("DROPS"));
- ScoredHistoryMatches matches = url_index_->HistoryItemsForTerms(terms);
+ original_terms.push_back(ASCIIToUTF16("MORTGAGE"));
+ original_terms.push_back(ASCIIToUTF16("RATE"));
+ original_terms.push_back(ASCIIToUTF16("DROPS"));
+ ScoredHistoryMatches matches =
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(1U, matches.size());
// Verify that we got back the result we expected.
@@ -315,6 +328,54 @@
matches[0].url_info.title());
}
+TEST_F(InMemoryURLIndexTest, TitleChange) {
+ url_index_.reset(new InMemoryURLIndex(FilePath()));
+ url_index_->Init(this, "en,ja,hi,zh");
+
+ // Verify current title terms retrieves desired item.
+ String16Vector original_terms;
+ original_terms.push_back(ASCIIToUTF16("lebronomics"));
+ original_terms.push_back(ASCIIToUTF16("could"));
+ original_terms.push_back(ASCIIToUTF16("high"));
+ original_terms.push_back(ASCIIToUTF16("taxes"));
+ original_terms.push_back(ASCIIToUTF16("influence"));
+ ScoredHistoryMatches matches =
+ url_index_->HistoryItemsForTerms(original_terms);
+ ASSERT_EQ(1U, matches.size());
+
+ // Verify that we got back the result we expected.
+ const URLID expected_id = 3;
+ EXPECT_EQ(expected_id, matches[0].url_info.id());
+ EXPECT_EQ("http://www.businessandmedia.org/articles/2010/20100708120415.aspx",
+ matches[0].url_info.url().spec());
+ EXPECT_EQ(ASCIIToUTF16(
+ "LeBronomics: Could High Taxes Influence James' Team Decision?"),
+ matches[0].url_info.title());
+ URLRow old_row(matches[0].url_info);
+
+ // Verify new title terms retrieves nothing.
+ String16Vector new_terms;
+ new_terms.push_back(ASCIIToUTF16("does"));
+ new_terms.push_back(ASCIIToUTF16("eat"));
+ new_terms.push_back(ASCIIToUTF16("oats"));
+ new_terms.push_back(ASCIIToUTF16("little"));
+ new_terms.push_back(ASCIIToUTF16("lambs"));
+ new_terms.push_back(ASCIIToUTF16("ivy"));
+ matches = url_index_->HistoryItemsForTerms(new_terms);
+ ASSERT_EQ(0U, matches.size());
+
+ // Update the row.
+ old_row.set_title(ASCIIToUTF16("Does eat oats and little lambs eat ivy"));
+ url_index_->UpdateURL(expected_id, old_row);
+
+ // Verify we get the row using the new terms but not the original terms.
+ matches = url_index_->HistoryItemsForTerms(new_terms);
+ ASSERT_EQ(1U, matches.size());
+ EXPECT_EQ(expected_id, matches[0].url_info.id());
+ matches = url_index_->HistoryItemsForTerms(original_terms);
+ ASSERT_EQ(0U, matches.size());
+}
+
TEST_F(InMemoryURLIndexTest, NonUniqueTermCharacterSets) {
url_index_.reset(new InMemoryURLIndex(FilePath()));
url_index_->Init(this, "en,ja,hi,zh");
@@ -345,101 +406,6 @@
EXPECT_EQ(28, matches[0].url_info.id());
}
-TEST_F(InMemoryURLIndexTest, StaticFunctions) {
- // Test WordVectorFromString16
- string16 string_a(ASCIIToUTF16("http://www.google.com/ frammy the brammy"));
- InMemoryURLIndex::String16Vector string_vec =
- InMemoryURLIndex::WordVectorFromString16(string_a, false);
- ASSERT_EQ(7U, string_vec.size());
- // See if we got the words we expected.
- EXPECT_EQ(UTF8ToUTF16("http"), string_vec[0]);
- EXPECT_EQ(UTF8ToUTF16("www"), string_vec[1]);
- EXPECT_EQ(UTF8ToUTF16("google"), string_vec[2]);
- EXPECT_EQ(UTF8ToUTF16("com"), string_vec[3]);
- EXPECT_EQ(UTF8ToUTF16("frammy"), string_vec[4]);
- EXPECT_EQ(UTF8ToUTF16("the"), string_vec[5]);
- EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[6]);
-
- string_vec = InMemoryURLIndex::WordVectorFromString16(string_a, true);
- ASSERT_EQ(5U, string_vec.size());
- EXPECT_EQ(UTF8ToUTF16("http://"), string_vec[0]);
- EXPECT_EQ(UTF8ToUTF16("www.google.com/"), string_vec[1]);
- EXPECT_EQ(UTF8ToUTF16("frammy"), string_vec[2]);
- EXPECT_EQ(UTF8ToUTF16("the"), string_vec[3]);
- EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[4]);
-
- // Test WordSetFromString16
- string16 string_b(ASCIIToUTF16(
- "http://web.google.com/search Google Web Search"));
- InMemoryURLIndex::String16Set string_set =
- InMemoryURLIndex::WordSetFromString16(string_b);
- EXPECT_EQ(5U, string_set.size());
- // See if we got the words we expected.
- EXPECT_TRUE(string_set.find(UTF8ToUTF16("com")) != string_set.end());
- EXPECT_TRUE(string_set.find(UTF8ToUTF16("google")) != string_set.end());
- EXPECT_TRUE(string_set.find(UTF8ToUTF16("http")) != string_set.end());
- EXPECT_TRUE(string_set.find(UTF8ToUTF16("search")) != string_set.end());
- EXPECT_TRUE(string_set.find(UTF8ToUTF16("web")) != string_set.end());
-
- // Test SortAndDeoverlap
- TermMatches matches_a;
- matches_a.push_back(TermMatch(1, 13, 10));
- matches_a.push_back(TermMatch(2, 23, 10));
- matches_a.push_back(TermMatch(3, 3, 10));
- matches_a.push_back(TermMatch(4, 40, 5));
- TermMatches matches_b = InMemoryURLIndex::SortAndDeoverlap(matches_a);
- // Nothing should have been eliminated.
- EXPECT_EQ(matches_a.size(), matches_b.size());
- // The order should now be 3, 1, 2, 4.
- EXPECT_EQ(3, matches_b[0].term_num);
- EXPECT_EQ(1, matches_b[1].term_num);
- EXPECT_EQ(2, matches_b[2].term_num);
- EXPECT_EQ(4, matches_b[3].term_num);
- matches_a.push_back(TermMatch(5, 18, 10));
- matches_a.push_back(TermMatch(6, 38, 5));
- matches_b = InMemoryURLIndex::SortAndDeoverlap(matches_a);
- // Two matches should have been eliminated.
- EXPECT_EQ(matches_a.size() - 2, matches_b.size());
- // The order should now be 3, 1, 2, 6.
- EXPECT_EQ(3, matches_b[0].term_num);
- EXPECT_EQ(1, matches_b[1].term_num);
- EXPECT_EQ(2, matches_b[2].term_num);
- EXPECT_EQ(6, matches_b[3].term_num);
-
- // Test MatchTermInString
- TermMatches matches_c = InMemoryURLIndex::MatchTermInString(
- UTF8ToUTF16("x"), UTF8ToUTF16("axbxcxdxex fxgx/hxixjx.kx"), 123);
- ASSERT_EQ(11U, matches_c.size());
- const size_t expected_offsets[] = { 1, 3, 5, 7, 9, 12, 14, 17, 19, 21, 24 };
- for (int i = 0; i < 11; ++i)
- EXPECT_EQ(expected_offsets[i], matches_c[i].offset);
-}
-
-TEST_F(InMemoryURLIndexTest, OffsetsAndTermMatches) {
- // Test OffsetsFromTermMatches
- history::TermMatches matches_a;
- matches_a.push_back(history::TermMatch(1, 1, 2));
- matches_a.push_back(history::TermMatch(2, 4, 3));
- matches_a.push_back(history::TermMatch(3, 9, 1));
- matches_a.push_back(history::TermMatch(3, 10, 1));
- matches_a.push_back(history::TermMatch(4, 14, 5));
- std::vector<size_t> offsets =
- InMemoryURLIndex::OffsetsFromTermMatches(matches_a);
- const size_t expected_offsets_a[] = {1, 4, 9, 10, 14};
- ASSERT_EQ(offsets.size(), arraysize(expected_offsets_a));
- for (size_t i = 0; i < offsets.size(); ++i)
- EXPECT_EQ(expected_offsets_a[i], offsets[i]);
-
- // Test ReplaceOffsetsInTermMatches
- offsets[2] = string16::npos;
- history::TermMatches matches_b =
- InMemoryURLIndex::ReplaceOffsetsInTermMatches(matches_a, offsets);
- const size_t expected_offsets_b[] = {1, 4, 10, 14};
- ASSERT_EQ(arraysize(expected_offsets_b), matches_b.size());
- for (size_t i = 0; i < matches_b.size(); ++i)
- EXPECT_EQ(expected_offsets_b[i], matches_b[i].offset);
-}
-
TEST_F(InMemoryURLIndexTest, TypedCharacterCaching) {
// Verify that match results for previously typed characters are retained
// (in the term_char_word_set_cache_) and reused, if possible, in future
@@ -460,55 +426,55 @@
// Simulate typing "r" giving "r" in the simulated omnibox. The results for
// 'r' will be not cached because it is only 1 character long.
- InMemoryURLIndex::String16Vector terms;
+ String16Vector original_terms;
string16 term_r = ASCIIToUTF16("r");
- terms.push_back(term_r);
- url_index_->HistoryItemsForTerms(terms);
+ original_terms.push_back(term_r);
+ url_index_->HistoryItemsForTerms(original_terms);
EXPECT_EQ(0U, cache.size());
// Simulate typing "re" giving "r re" in the simulated omnibox.
string16 term_re = ASCIIToUTF16("re");
- terms.push_back(term_re);
+ original_terms.push_back(term_re);
// 're' should be cached at this point but not 'r' as it is a single
// character.
- ASSERT_EQ(2U, terms.size());
- url_index_->HistoryItemsForTerms(terms);
+ ASSERT_EQ(2U, original_terms.size());
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(1U, cache.size());
CheckTerm(cache, term_re);
// Simulate typing "reco" giving "r re reco" in the simulated omnibox.
string16 term_reco = ASCIIToUTF16("reco");
- terms.push_back(term_reco);
+ original_terms.push_back(term_reco);
// 're' and 'reco' should be cached at this point but not 'r' as it is a
// single character.
- url_index_->HistoryItemsForTerms(terms);
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(2U, cache.size());
CheckTerm(cache, term_re);
CheckTerm(cache, term_reco);
- terms.clear(); // Simulate pressing <ESC>.
+ original_terms.clear(); // Simulate pressing <ESC>.
// Simulate typing "mort".
string16 term_mort = ASCIIToUTF16("mort");
- terms.push_back(term_mort);
+ original_terms.push_back(term_mort);
// Since we now have only one search term, the cached results for 're' and
// 'reco' should be purged, giving us only 1 item in the cache (for 'mort').
- url_index_->HistoryItemsForTerms(terms);
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(1U, cache.size());
CheckTerm(cache, term_mort);
// Simulate typing "reco" giving "mort reco" in the simulated omnibox.
- terms.push_back(term_reco);
- url_index_->HistoryItemsForTerms(terms);
+ original_terms.push_back(term_reco);
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(2U, cache.size());
CheckTerm(cache, term_mort);
CheckTerm(cache, term_reco);
// Simulate a <DELETE> by removing the 'reco' and adding back the 'rec'.
- terms.resize(terms.size() - 1);
+ original_terms.resize(original_terms.size() - 1);
string16 term_rec = ASCIIToUTF16("rec");
- terms.push_back(term_rec);
- url_index_->HistoryItemsForTerms(terms);
+ original_terms.push_back(term_rec);
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(2U, cache.size());
CheckTerm(cache, term_mort);
CheckTerm(cache, term_rec);
@@ -552,14 +518,14 @@
TEST_F(InMemoryURLIndexTest, AddNewRows) {
url_index_.reset(new InMemoryURLIndex(FilePath()));
url_index_->Init(this, "en,ja,hi,zh");
- InMemoryURLIndex::String16Vector terms;
+ String16Vector original_terms;
// Verify that the row we're going to add does not already exist.
URLID new_row_id = 87654321;
// Newly created URLRows get a last_visit time of 'right now' so it should
// qualify as a quick result candidate.
- terms.push_back(ASCIIToUTF16("brokeandalone"));
- EXPECT_TRUE(url_index_->HistoryItemsForTerms(terms).empty());
+ original_terms.push_back(ASCIIToUTF16("brokeandalone"));
+ EXPECT_TRUE(url_index_->HistoryItemsForTerms(original_terms).empty());
// Add a new row.
URLRow new_row(GURL("http://www.brokeandaloneinmanitoba.com/"), new_row_id);
@@ -567,26 +533,27 @@
url_index_->UpdateURL(new_row_id, new_row);
// Verify that we can retrieve it.
- EXPECT_EQ(1U, url_index_->HistoryItemsForTerms(terms).size());
+ EXPECT_EQ(1U, url_index_->HistoryItemsForTerms(original_terms).size());
// Add it again just to be sure that is harmless.
url_index_->UpdateURL(new_row_id, new_row);
- EXPECT_EQ(1U, url_index_->HistoryItemsForTerms(terms).size());
+ EXPECT_EQ(1U, url_index_->HistoryItemsForTerms(original_terms).size());
}
TEST_F(InMemoryURLIndexTest, DeleteRows) {
url_index_.reset(new InMemoryURLIndex(FilePath()));
url_index_->Init(this, "en,ja,hi,zh");
- InMemoryURLIndex::String16Vector terms;
+ String16Vector original_terms;
// Make sure we actually get an existing result.
- terms.push_back(ASCIIToUTF16("DrudgeReport"));
- ScoredHistoryMatches matches = url_index_->HistoryItemsForTerms(terms);
+ original_terms.push_back(ASCIIToUTF16("DrudgeReport"));
+ ScoredHistoryMatches matches =
+ url_index_->HistoryItemsForTerms(original_terms);
ASSERT_EQ(1U, matches.size());
// Determine the row id for that result, delete that id, then search again.
url_index_->DeleteURL(matches[0].url_info.id());
- EXPECT_TRUE(url_index_->HistoryItemsForTerms(terms).empty());
+ EXPECT_TRUE(url_index_->HistoryItemsForTerms(original_terms).empty());
}
TEST_F(InMemoryURLIndexTest, WhitelistedURLs) {
@@ -697,77 +664,64 @@
url_index.SavePrivateData(&index_cache);
// Capture our private data so we can later compare for equality.
- int history_item_count(url_index.history_item_count_);
- InMemoryURLIndex::String16Vector word_list(url_index.word_list_);
- InMemoryURLIndex::WordMap word_map(url_index.word_map_);
- InMemoryURLIndex::CharWordIDMap char_word_map(url_index.char_word_map_);
- InMemoryURLIndex::WordIDHistoryMap word_id_history_map(
- url_index.word_id_history_map_);
- InMemoryURLIndex::HistoryInfoMap history_info_map(
- url_index.history_info_map_);
+ URLIndexPrivateData& private_data(*(url_index_->private_data_));
+ String16Vector word_list(private_data.word_list_);
+ WordMap word_map(private_data.word_map_);
+ CharWordIDMap char_word_map(private_data.char_word_map_);
+ WordIDHistoryMap word_id_history_map(private_data.word_id_history_map_);
+ HistoryIDWordMap history_id_word_map(private_data.history_id_word_map_);
+ HistoryInfoMap history_info_map(private_data.history_info_map_);
// Prove that there is really something there.
- EXPECT_GT(url_index.history_item_count_, 0);
- EXPECT_FALSE(url_index.word_list_.empty());
- EXPECT_FALSE(url_index.word_map_.empty());
- EXPECT_FALSE(url_index.char_word_map_.empty());
- EXPECT_FALSE(url_index.word_id_history_map_.empty());
- EXPECT_FALSE(url_index.history_info_map_.empty());
+ EXPECT_FALSE(private_data.word_list_.empty());
+ // available_words_ will already be empty since we have freshly built the
+ // data set for this test.
+ EXPECT_TRUE(private_data.available_words_.empty());
+ EXPECT_FALSE(private_data.word_map_.empty());
+ EXPECT_FALSE(private_data.char_word_map_.empty());
+ EXPECT_FALSE(private_data.word_id_history_map_.empty());
+ EXPECT_FALSE(private_data.history_id_word_map_.empty());
+ EXPECT_FALSE(private_data.history_info_map_.empty());
// Clear and then prove it's clear.
url_index.ClearPrivateData();
- EXPECT_EQ(0, url_index.history_item_count_);
- EXPECT_TRUE(url_index.word_list_.empty());
- EXPECT_TRUE(url_index.word_map_.empty());
- EXPECT_TRUE(url_index.char_word_map_.empty());
- EXPECT_TRUE(url_index.word_id_history_map_.empty());
- EXPECT_TRUE(url_index.history_info_map_.empty());
+ EXPECT_TRUE(private_data.word_list_.empty());
+ EXPECT_TRUE(private_data.available_words_.empty());
+ EXPECT_TRUE(private_data.word_map_.empty());
+ EXPECT_TRUE(private_data.char_word_map_.empty());
+ EXPECT_TRUE(private_data.word_id_history_map_.empty());
+ EXPECT_TRUE(private_data.history_id_word_map_.empty());
+ EXPECT_TRUE(private_data.history_info_map_.empty());
// Restore the cache.
EXPECT_TRUE(url_index.RestorePrivateData(index_cache));
// Compare the restored and captured for equality.
- EXPECT_EQ(history_item_count, url_index.history_item_count_);
- EXPECT_EQ(word_list.size(), url_index.word_list_.size());
- EXPECT_EQ(word_map.size(), url_index.word_map_.size());
- EXPECT_EQ(char_word_map.size(), url_index.char_word_map_.size());
- EXPECT_EQ(word_id_history_map.size(), url_index.word_id_history_map_.size());
- EXPECT_EQ(history_info_map.size(), url_index.history_info_map_.size());
+ EXPECT_EQ(word_list.size(), private_data.word_list_.size());
+ EXPECT_EQ(word_map.size(), private_data.word_map_.size());
+ EXPECT_EQ(char_word_map.size(), private_data.char_word_map_.size());
+ EXPECT_EQ(word_id_history_map.size(),
+ private_data.word_id_history_map_.size());
+ EXPECT_EQ(history_id_word_map.size(),
+ private_data.history_id_word_map_.size());
+ EXPECT_EQ(history_info_map.size(), private_data.history_info_map_.size());
// WordList must be index-by-index equal.
size_t count = word_list.size();
for (size_t i = 0; i < count; ++i)
- EXPECT_EQ(word_list[i], url_index.word_list_[i]);
- for (InMemoryURLIndex::CharWordIDMap::const_iterator expected =
- char_word_map.begin(); expected != char_word_map.end(); ++expected) {
- InMemoryURLIndex::CharWordIDMap::const_iterator actual =
- url_index.char_word_map_.find(expected->first);
- ASSERT_TRUE(url_index.char_word_map_.end() != actual);
- const InMemoryURLIndex::WordIDSet& expected_set(expected->second);
- const InMemoryURLIndex::WordIDSet& actual_set(actual->second);
- ASSERT_EQ(expected_set.size(), actual_set.size());
- for (InMemoryURLIndex::WordIDSet::const_iterator set_iter =
- expected_set.begin(); set_iter != expected_set.end(); ++set_iter)
- EXPECT_GT(actual_set.count(*set_iter), 0U);
- }
- for (InMemoryURLIndex::WordIDHistoryMap::const_iterator expected =
- word_id_history_map.begin(); expected != word_id_history_map.end();
- ++expected) {
- InMemoryURLIndex::WordIDHistoryMap::const_iterator actual =
- url_index.word_id_history_map_.find(expected->first);
- ASSERT_TRUE(url_index.word_id_history_map_.end() != actual);
- const InMemoryURLIndex::HistoryIDSet& expected_set(expected->second);
- const InMemoryURLIndex::HistoryIDSet& actual_set(actual->second);
- ASSERT_EQ(expected_set.size(), actual_set.size());
- for (InMemoryURLIndex::HistoryIDSet::const_iterator set_iter =
- expected_set.begin(); set_iter != expected_set.end(); ++set_iter)
- EXPECT_GT(actual_set.count(*set_iter), 0U);
- }
- for (InMemoryURLIndex::HistoryInfoMap::const_iterator expected =
- history_info_map.begin(); expected != history_info_map.end();
- ++expected) {
- InMemoryURLIndex::HistoryInfoMap::const_iterator actual =
- url_index.history_info_map_.find(expected->first);
- ASSERT_FALSE(url_index.history_info_map_.end() == actual);
+ EXPECT_EQ(word_list[i], private_data.word_list_[i]);
+
+ ExpectMapOfContainersIdentical(char_word_map,
+ private_data.char_word_map_);
+ ExpectMapOfContainersIdentical(word_id_history_map,
+ private_data.word_id_history_map_);
+ ExpectMapOfContainersIdentical(history_id_word_map,
+ private_data.history_id_word_map_);
+
+ for (HistoryInfoMap::const_iterator expected = history_info_map.begin();
+ expected != history_info_map.end(); ++expected) {
+ HistoryInfoMap::const_iterator actual =
+ private_data.history_info_map_.find(expected->first);
+ ASSERT_FALSE(private_data.history_info_map_.end() == actual);
const URLRow& expected_row(expected->second);
const URLRow& actual_row(actual->second);
EXPECT_EQ(expected_row.visit_count(), actual_row.visit_count());
« no previous file with comments | « chrome/browser/history/in_memory_url_index_types_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698