| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/importer/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(ProfileWriterTest); | 132 DISALLOW_COPY_AND_ASSIGN(ProfileWriterTest); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 // Add bookmarks via ProfileWriter to profile1 when profile2 also exists. | 135 // Add bookmarks via ProfileWriter to profile1 when profile2 also exists. |
| 136 TEST_F(ProfileWriterTest, CheckBookmarksWithMultiProfile) { | 136 TEST_F(ProfileWriterTest, CheckBookmarksWithMultiProfile) { |
| 137 TestingProfile profile2; | 137 TestingProfile profile2; |
| 138 profile2.CreateBookmarkModel(true); | 138 profile2.CreateBookmarkModel(true); |
| 139 | 139 |
| 140 BookmarkModel* bookmark_model2 = | 140 BookmarkModel* bookmark_model2 = |
| 141 BookmarkModelFactory::GetForProfile(&profile2); | 141 BookmarkModelFactory::GetForBrowserContext(&profile2); |
| 142 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model2); | 142 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model2); |
| 143 bookmarks::AddIfNotBookmarked( | 143 bookmarks::AddIfNotBookmarked( |
| 144 bookmark_model2, GURL("http://www.bing.com"), base::ASCIIToUTF16("Bing")); | 144 bookmark_model2, GURL("http://www.bing.com"), base::ASCIIToUTF16("Bing")); |
| 145 TestingProfile profile1; | 145 TestingProfile profile1; |
| 146 profile1.CreateBookmarkModel(true); | 146 profile1.CreateBookmarkModel(true); |
| 147 | 147 |
| 148 CreateImportedBookmarksEntries(); | 148 CreateImportedBookmarksEntries(); |
| 149 BookmarkModel* bookmark_model1 = | 149 BookmarkModel* bookmark_model1 = |
| 150 BookmarkModelFactory::GetForProfile(&profile1); | 150 BookmarkModelFactory::GetForBrowserContext(&profile1); |
| 151 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model1); | 151 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model1); |
| 152 | 152 |
| 153 scoped_refptr<TestProfileWriter> profile_writer( | 153 scoped_refptr<TestProfileWriter> profile_writer( |
| 154 new TestProfileWriter(&profile1)); | 154 new TestProfileWriter(&profile1)); |
| 155 profile_writer->AddBookmarks(bookmarks_, | 155 profile_writer->AddBookmarks(bookmarks_, |
| 156 base::ASCIIToUTF16("Imported from Firefox")); | 156 base::ASCIIToUTF16("Imported from Firefox")); |
| 157 | 157 |
| 158 std::vector<BookmarkModel::URLAndTitle> url_record1; | 158 std::vector<BookmarkModel::URLAndTitle> url_record1; |
| 159 bookmark_model1->GetBookmarks(&url_record1); | 159 bookmark_model1->GetBookmarks(&url_record1); |
| 160 EXPECT_EQ(2u, url_record1.size()); | 160 EXPECT_EQ(2u, url_record1.size()); |
| 161 | 161 |
| 162 std::vector<BookmarkModel::URLAndTitle> url_record2; | 162 std::vector<BookmarkModel::URLAndTitle> url_record2; |
| 163 bookmark_model2->GetBookmarks(&url_record2); | 163 bookmark_model2->GetBookmarks(&url_record2); |
| 164 EXPECT_EQ(1u, url_record2.size()); | 164 EXPECT_EQ(1u, url_record2.size()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Verify that bookmarks are duplicated when added twice. | 167 // Verify that bookmarks are duplicated when added twice. |
| 168 TEST_F(ProfileWriterTest, CheckBookmarksAfterWritingDataTwice) { | 168 TEST_F(ProfileWriterTest, CheckBookmarksAfterWritingDataTwice) { |
| 169 TestingProfile profile; | 169 TestingProfile profile; |
| 170 profile.CreateBookmarkModel(true); | 170 profile.CreateBookmarkModel(true); |
| 171 | 171 |
| 172 CreateImportedBookmarksEntries(); | 172 CreateImportedBookmarksEntries(); |
| 173 BookmarkModel* bookmark_model = | 173 BookmarkModel* bookmark_model = |
| 174 BookmarkModelFactory::GetForProfile(&profile); | 174 BookmarkModelFactory::GetForBrowserContext(&profile); |
| 175 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 175 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
| 176 | 176 |
| 177 scoped_refptr<TestProfileWriter> profile_writer( | 177 scoped_refptr<TestProfileWriter> profile_writer( |
| 178 new TestProfileWriter(&profile)); | 178 new TestProfileWriter(&profile)); |
| 179 profile_writer->AddBookmarks(bookmarks_, | 179 profile_writer->AddBookmarks(bookmarks_, |
| 180 base::ASCIIToUTF16("Imported from Firefox")); | 180 base::ASCIIToUTF16("Imported from Firefox")); |
| 181 std::vector<BookmarkModel::URLAndTitle> bookmarks_record; | 181 std::vector<BookmarkModel::URLAndTitle> bookmarks_record; |
| 182 bookmark_model->GetBookmarks(&bookmarks_record); | 182 bookmark_model->GetBookmarks(&bookmarks_record); |
| 183 EXPECT_EQ(2u, bookmarks_record.size()); | 183 EXPECT_EQ(2u, bookmarks_record.size()); |
| 184 | 184 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 201 new TestProfileWriter(&profile)); | 201 new TestProfileWriter(&profile)); |
| 202 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); | 202 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); |
| 203 VerifyHistoryCount(&profile); | 203 VerifyHistoryCount(&profile); |
| 204 size_t original_history_count = history_count_; | 204 size_t original_history_count = history_count_; |
| 205 history_count_ = 0; | 205 history_count_ = 0; |
| 206 | 206 |
| 207 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); | 207 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); |
| 208 VerifyHistoryCount(&profile); | 208 VerifyHistoryCount(&profile); |
| 209 EXPECT_EQ(original_history_count, history_count_); | 209 EXPECT_EQ(original_history_count, history_count_); |
| 210 } | 210 } |
| OLD | NEW |