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

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_writer_unittest.cc

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "base/string_util.h" 11 #include "base/string_util.h"
11 #include "base/time.h" 12 #include "base/time.h"
12 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
13 #include "chrome/browser/bookmarks/bookmark_html_writer.h" 14 #include "chrome/browser/bookmarks/bookmark_html_writer.h"
14 #include "chrome/browser/bookmarks/bookmark_model.h" 15 #include "chrome/browser/bookmarks/bookmark_model.h"
16 #include "chrome/browser/chrome_thread.h"
15 #include "chrome/browser/importer/firefox2_importer.h" 17 #include "chrome/browser/importer/firefox2_importer.h"
16 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
17 19
18 class BookmarkHTMLWriterTest : public testing::Test { 20 class BookmarkHTMLWriterTest : public testing::Test {
19 protected: 21 protected:
20 virtual void SetUp() { 22 virtual void SetUp() {
21 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); 23 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_));
22 path_ = path_.AppendASCII("bookmarks.html"); 24 path_ = path_.AppendASCII("bookmarks.html");
23 file_util::Delete(path_, true); 25 file_util::Delete(path_, true);
24 } 26 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 144
143 model.AddURLWithCreationTime(model.other_node(), 0, url1_title, url1, t1); 145 model.AddURLWithCreationTime(model.other_node(), 0, url1_title, url1, t1);
144 model.AddURLWithCreationTime(model.other_node(), 1, url2_title, url2, t2); 146 model.AddURLWithCreationTime(model.other_node(), 1, url2_title, url2, t2);
145 const BookmarkNode* f3 = model.AddGroup(model.other_node(), 2, f3_title); 147 const BookmarkNode* f3 = model.AddGroup(model.other_node(), 2, f3_title);
146 const BookmarkNode* f4 = model.AddGroup(f3, 0, f4_title); 148 const BookmarkNode* f4 = model.AddGroup(f3, 0, f4_title);
147 model.AddURLWithCreationTime(f4, 0, url1_title, url1, t1); 149 model.AddURLWithCreationTime(f4, 0, url1_title, url1, t1);
148 model.AddURLWithCreationTime(model.GetBookmarkBarNode(), 2, url4_title, 150 model.AddURLWithCreationTime(model.GetBookmarkBarNode(), 2, url4_title,
149 url4, t4); 151 url4, t4);
150 152
151 // Write to a temp file. 153 // Write to a temp file.
152 bookmark_html_writer::WriteBookmarks(NULL, &model, path_); 154 MessageLoop message_loop;
155 ChromeThread fake_file_thread(ChromeThread::FILE, &message_loop);
156 bookmark_html_writer::WriteBookmarks(&model, path_);
157 message_loop.RunAllPending();
153 158
154 // Read the bookmarks back in. 159 // Read the bookmarks back in.
155 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; 160 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks;
156 Firefox2Importer::ImportBookmarksFile(path_.ToWStringHack(), std::set<GURL>(), 161 Firefox2Importer::ImportBookmarksFile(path_.ToWStringHack(), std::set<GURL>(),
157 false, L"x", NULL, &parsed_bookmarks, 162 false, L"x", NULL, &parsed_bookmarks,
158 NULL, NULL); 163 NULL, NULL);
159 164
160 // Verify we got back what we wrote. 165 // Verify we got back what we wrote.
161 ASSERT_EQ(7U, parsed_bookmarks.size()); 166 ASSERT_EQ(7U, parsed_bookmarks.size());
162 // Windows and ChromeOS builds use Sentence case. 167 // Windows and ChromeOS builds use Sentence case.
163 std::wstring bookmark_folder_name = 168 std::wstring bookmark_folder_name =
164 l10n_util::GetString(IDS_BOOMARK_BAR_FOLDER_NAME); 169 l10n_util::GetString(IDS_BOOMARK_BAR_FOLDER_NAME);
165 AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1, 170 AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1,
166 bookmark_folder_name, f1_title, std::wstring()); 171 bookmark_folder_name, f1_title, std::wstring());
167 AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2, 172 AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2,
168 bookmark_folder_name, f1_title, f2_title); 173 bookmark_folder_name, f1_title, f2_title);
169 AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3, 174 AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3,
170 bookmark_folder_name, std::wstring(), 175 bookmark_folder_name, std::wstring(),
171 std::wstring()); 176 std::wstring());
172 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4, 177 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4,
173 bookmark_folder_name, std::wstring(), 178 bookmark_folder_name, std::wstring(),
174 std::wstring()); 179 std::wstring());
175 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, 180 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1,
176 std::wstring(), std::wstring(), std::wstring()); 181 std::wstring(), std::wstring(), std::wstring());
177 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, 182 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2,
178 std::wstring(), std::wstring(), std::wstring()); 183 std::wstring(), std::wstring(), std::wstring());
179 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, 184 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1,
180 f3_title, f4_title, std::wstring()); 185 f3_title, f4_title, std::wstring());
181 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_html_writer.cc ('k') | chrome/browser/bookmarks/bookmark_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698