profile_writer_unittest.cc revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/importer/profile_writer.h"
658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <string>
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
9ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "base/message_loop/message_loop.h"
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/bookmarks/bookmark_model_factory.h"
1258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/history/history_service.h"
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/history/history_service_factory.h"
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/history/history_types.h"
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/importer/importer_unittest_utils.h"
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/common/importer/imported_bookmark_entry.h"
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/test/base/testing_profile.h"
18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/bookmarks/browser/bookmark_match.h"
19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/bookmarks/browser/bookmark_model.h"
20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/bookmarks/browser/bookmark_utils.h"
21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/bookmarks/test/bookmark_test_helpers.h"
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/test/test_browser_thread.h"
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)using content::BrowserThread;
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class TestProfileWriter : public ProfileWriter {
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  explicit TestProfileWriter(Profile* profile) : ProfileWriter(profile) {}
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) protected:
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual ~TestProfileWriter() {}
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class ProfileWriterTest : public testing::Test {
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ProfileWriterTest()
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      : ui_thread_(BrowserThread::UI, &loop_),
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        file_thread_(BrowserThread::FILE, &loop_) {
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual ~ProfileWriterTest() {}
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Create test bookmark entries to be added to ProfileWriter to
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // simulate bookmark importing.
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void CreateImportedBookmarksEntries() {
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    AddImportedBookmarkEntry(GURL("http://www.google.com"),
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             base::ASCIIToUTF16("Google"));
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    AddImportedBookmarkEntry(GURL("http://www.yahoo.com"),
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             base::ASCIIToUTF16("Yahoo"));
49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Helper function to create history entries.
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  history::URLRow MakeURLRow(const char* url,
53a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                             base::string16 title,
54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                             int visit_count,
55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                             int days_since_last_visit,
56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                             int typed_count) {
57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    history::URLRow row(GURL(url), 0);
58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    row.set_title(title);
59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    row.set_visit_count(visit_count);
60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    row.set_typed_count(typed_count);
61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    row.set_last_visit(base::Time::NowFromSystemTime() -
62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                       base::TimeDelta::FromDays(days_since_last_visit));
63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    return row;
64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Create test history entries to be added to ProfileWriter to
67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // simulate history importing.
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void CreateHistoryPageEntries() {
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    history::URLRow row1(
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        MakeURLRow("http://www.google.com", base::ASCIIToUTF16("Google"),
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        3, 10, 1));
72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    history::URLRow row2(
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        MakeURLRow("http://www.yahoo.com", base::ASCIIToUTF16("Yahoo"),
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        3, 30, 10));
75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    pages_.push_back(row1);
76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    pages_.push_back(row2);
77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void VerifyBookmarksCount(
8046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)      const std::vector<BookmarkModel::URLAndTitle>& bookmarks_record,
81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      BookmarkModel* bookmark_model,
82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      size_t expected) {
830529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    std::vector<BookmarkMatch> matches;
84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    for (size_t i = 0; i < bookmarks_record.size(); ++i) {
850529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      bookmark_model->GetBookmarksMatching(
860529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch          bookmarks_record[i].title, 10, &matches);
87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      EXPECT_EQ(expected, matches.size());
88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      matches.clear();
89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    }
90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void VerifyHistoryCount(Profile* profile) {
93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    HistoryService* history_service =
94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        HistoryServiceFactory::GetForProfile(profile,
95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                                             Profile::EXPLICIT_ACCESS);
96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    history::QueryOptions options;
97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    CancelableRequestConsumer history_request_consumer;
98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    history_service->QueryHistory(
99a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)        base::string16(),
100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        options,
101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        &history_request_consumer,
102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        base::Bind(&ProfileWriterTest::HistoryQueryComplete,
103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                   base::Unretained(this)));
104868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    base::MessageLoop::current()->Run();
105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void HistoryQueryComplete(HistoryService::Handle handle,
108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                            history::QueryResults* results) {
109868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    base::MessageLoop::current()->Quit();
110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    history_count_ = results->size();
111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
113868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) protected:
114868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  std::vector<ImportedBookmarkEntry> bookmarks_;
115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  history::URLRows pages_;
116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  size_t history_count_;
117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
119a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void AddImportedBookmarkEntry(const GURL& url, const base::string16& title) {
120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    base::Time date;
121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ImportedBookmarkEntry entry;
122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    entry.creation_time = date;
123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    entry.url = url;
124868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    entry.title = title;
125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    entry.in_toolbar = true;
126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    entry.is_folder = false;
127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    bookmarks_.push_back(entry);
128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
130868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  base::MessageLoop loop_;
131868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  content::TestBrowserThread ui_thread_;
132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  content::TestBrowserThread file_thread_;
133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ProfileWriterTest);
135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Add bookmarks via ProfileWriter to profile1 when profile2 also exists.
138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST_F(ProfileWriterTest, CheckBookmarksWithMultiProfile) {
139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  TestingProfile profile2;
140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile2.CreateBookmarkModel(true);
141868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
142868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  BookmarkModel* bookmark_model2 =
143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      BookmarkModelFactory::GetForProfile(&profile2);
14458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  test::WaitForBookmarkModelToLoad(bookmark_model2);
145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bookmark_utils::AddIfNotBookmarked(bookmark_model2,
146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                                     GURL("http://www.bing.com"),
1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                     base::ASCIIToUTF16("Bing"));
148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  TestingProfile profile1;
149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile1.CreateBookmarkModel(true);
150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  CreateImportedBookmarksEntries();
152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  BookmarkModel* bookmark_model1 =
153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      BookmarkModelFactory::GetForProfile(&profile1);
15458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  test::WaitForBookmarkModelToLoad(bookmark_model1);
155868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
156868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<TestProfileWriter> profile_writer(
157868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      new TestProfileWriter(&profile1));
158868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile_writer->AddBookmarks(bookmarks_,
1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                               base::ASCIIToUTF16("Imported from Firefox"));
160868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
16146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  std::vector<BookmarkModel::URLAndTitle> url_record1;
162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bookmark_model1->GetBookmarks(&url_record1);
163868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(2u, url_record1.size());
164868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
16546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  std::vector<BookmarkModel::URLAndTitle> url_record2;
166868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bookmark_model2->GetBookmarks(&url_record2);
167868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(1u, url_record2.size());
168868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
169868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
170868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Verify that bookmarks are duplicated when added twice.
171868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST_F(ProfileWriterTest, CheckBookmarksAfterWritingDataTwice) {
172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  TestingProfile profile;
173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile.CreateBookmarkModel(true);
174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
175868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  CreateImportedBookmarksEntries();
176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  BookmarkModel* bookmark_model =
177868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      BookmarkModelFactory::GetForProfile(&profile);
17858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  test::WaitForBookmarkModelToLoad(bookmark_model);
179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<TestProfileWriter> profile_writer(
181868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      new TestProfileWriter(&profile));
182868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile_writer->AddBookmarks(bookmarks_,
1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                               base::ASCIIToUTF16("Imported from Firefox"));
18446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  std::vector<BookmarkModel::URLAndTitle> bookmarks_record;
185868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bookmark_model->GetBookmarks(&bookmarks_record);
186868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(2u, bookmarks_record.size());
187868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  VerifyBookmarksCount(bookmarks_record, bookmark_model, 1);
189868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
190868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile_writer->AddBookmarks(bookmarks_,
1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                               base::ASCIIToUTF16("Imported from Firefox"));
192868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Verify that duplicate bookmarks exist.
193868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  VerifyBookmarksCount(bookmarks_record, bookmark_model, 2);
194868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
195868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Verify that history entires are not duplicated when added twice.
197868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST_F(ProfileWriterTest, CheckHistoryAfterWritingDataTwice) {
198868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  TestingProfile profile;
199bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  ASSERT_TRUE(profile.CreateHistoryService(true, false));
200868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile.BlockUntilHistoryProcessesPendingRequests();
201868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
202868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  CreateHistoryPageEntries();
203868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<TestProfileWriter> profile_writer(
204868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      new TestProfileWriter(&profile));
205868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED);
206868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  VerifyHistoryCount(&profile);
207868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  size_t original_history_count = history_count_;
208868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  history_count_ = 0;
209868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
210868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED);
211868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  VerifyHistoryCount(&profile);
212868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(original_history_count, history_count_);
213868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
214