OLD | NEW |
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 "base/file_util.h" | 8 #include "base/file_util.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "base/time.h" | 11 #include "base/time.h" |
11 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
12 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 13 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/importer/firefox2_importer.h" | 15 #include "chrome/browser/importer/firefox2_importer.h" |
| 16 #include "grit/generated_resources.h" |
15 | 17 |
16 class BookmarkHTMLWriterTest : public testing::Test { | 18 class BookmarkHTMLWriterTest : public testing::Test { |
17 protected: | 19 protected: |
18 virtual void SetUp() { | 20 virtual void SetUp() { |
19 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); | 21 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); |
20 path_ = path_.AppendASCII("bookmarks.html"); | 22 path_ = path_.AppendASCII("bookmarks.html"); |
21 file_util::Delete(path_, true); | 23 file_util::Delete(path_, true); |
22 } | 24 } |
23 | 25 |
24 virtual void TearDown() { | 26 virtual void TearDown() { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 EXPECT_EQ(BookmarkValuesToString(on_toolbar, url, title, creation_time, | 93 EXPECT_EQ(BookmarkValuesToString(on_toolbar, url, title, creation_time, |
92 f1, f2, f3), | 94 f1, f2, f3), |
93 BookmarkEntryToString(entry)); | 95 BookmarkEntryToString(entry)); |
94 } | 96 } |
95 | 97 |
96 FilePath path_; | 98 FilePath path_; |
97 }; | 99 }; |
98 | 100 |
99 // Tests bookmark_html_writer by populating a BookmarkModel, writing it out by | 101 // Tests bookmark_html_writer by populating a BookmarkModel, writing it out by |
100 // way of bookmark_html_writer, then using the importer to read it back in. | 102 // way of bookmark_html_writer, then using the importer to read it back in. |
101 // Flaky, http://crbug.com/17592. | 103 TEST_F(BookmarkHTMLWriterTest, Test) { |
102 TEST_F(BookmarkHTMLWriterTest, FLAKY_Test) { | |
103 // Populate the BookmarkModel. This creates the following bookmark structure: | 104 // Populate the BookmarkModel. This creates the following bookmark structure: |
104 // Bookmarks bar | 105 // Bookmarks bar |
105 // F1 | 106 // F1 |
106 // url1 | 107 // url1 |
107 // F2 | 108 // F2 |
108 // url2 | 109 // url2 |
109 // url3 | 110 // url3 |
110 // url4 | 111 // url4 |
111 // Other | 112 // Other |
112 // url1 | 113 // url1 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 bookmark_html_writer::WriteBookmarks(NULL, &model, path_); | 152 bookmark_html_writer::WriteBookmarks(NULL, &model, path_); |
152 | 153 |
153 // Read the bookmarks back in. | 154 // Read the bookmarks back in. |
154 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; | 155 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; |
155 Firefox2Importer::ImportBookmarksFile(path_.ToWStringHack(), std::set<GURL>(), | 156 Firefox2Importer::ImportBookmarksFile(path_.ToWStringHack(), std::set<GURL>(), |
156 false, L"x", NULL, &parsed_bookmarks, | 157 false, L"x", NULL, &parsed_bookmarks, |
157 NULL, NULL); | 158 NULL, NULL); |
158 | 159 |
159 // Verify we got back what we wrote. | 160 // Verify we got back what we wrote. |
160 ASSERT_EQ(7U, parsed_bookmarks.size()); | 161 ASSERT_EQ(7U, parsed_bookmarks.size()); |
161 // Hardcode the value of IDS_BOOKMARK_BAR_FOLDER_NAME in en-US locale | |
162 // because all the unit tests are run in en-US locale. | |
163 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) | |
164 // Windows and ChromeOS builds use Sentence case. | 162 // Windows and ChromeOS builds use Sentence case. |
165 const wchar_t* kBookmarkBarFolderName = L"Bookmarks bar"; | 163 std::wstring bookmark_folder_name = |
166 #else | 164 l10n_util::GetString(IDS_BOOMARK_BAR_FOLDER_NAME); |
167 // Mac and Linux + GTK uses Title Case. | |
168 const wchar_t* kBookmarkBarFolderName = L"Bookmarks Bar"; | |
169 #endif | |
170 AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1, | 165 AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1, |
171 kBookmarkBarFolderName, f1_title, std::wstring()); | 166 bookmark_folder_name, f1_title, std::wstring()); |
172 AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2, | 167 AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2, |
173 kBookmarkBarFolderName, f1_title, f2_title); | 168 bookmark_folder_name, f1_title, f2_title); |
174 AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3, | 169 AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3, |
175 kBookmarkBarFolderName, std::wstring(), | 170 bookmark_folder_name, std::wstring(), |
176 std::wstring()); | 171 std::wstring()); |
177 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4, | 172 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4, |
178 kBookmarkBarFolderName, std::wstring(), | 173 bookmark_folder_name, std::wstring(), |
179 std::wstring()); | 174 std::wstring()); |
180 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 175 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
181 std::wstring(), std::wstring(), std::wstring()); | 176 std::wstring(), std::wstring(), std::wstring()); |
182 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 177 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
183 std::wstring(), std::wstring(), std::wstring()); | 178 std::wstring(), std::wstring(), std::wstring()); |
184 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 179 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
185 f3_title, f4_title, std::wstring()); | 180 f3_title, f4_title, std::wstring()); |
186 } | 181 } |
OLD | NEW |