| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bookmarks/bookmark_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 BookmarkEntryToString(entry)); | 119 BookmarkEntryToString(entry)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 base::ScopedTempDir temp_dir_; | 122 base::ScopedTempDir temp_dir_; |
| 123 base::FilePath path_; | 123 base::FilePath path_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 // Class that will notify message loop when file is written. | 126 // Class that will notify message loop when file is written. |
| 127 class BookmarksObserver : public BookmarksExportObserver { | 127 class BookmarksObserver : public BookmarksExportObserver { |
| 128 public: | 128 public: |
| 129 explicit BookmarksObserver(MessageLoop* loop) : loop_(loop) { | 129 explicit BookmarksObserver(base::MessageLoop* loop) : loop_(loop) { |
| 130 DCHECK(loop); | 130 DCHECK(loop); |
| 131 } | 131 } |
| 132 | 132 |
| 133 virtual void OnExportFinished() OVERRIDE { | 133 virtual void OnExportFinished() OVERRIDE { |
| 134 loop_->Quit(); | 134 loop_->Quit(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 MessageLoop* loop_; | 138 base::MessageLoop* loop_; |
| 139 DISALLOW_COPY_AND_ASSIGN(BookmarksObserver); | 139 DISALLOW_COPY_AND_ASSIGN(BookmarksObserver); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 // Tests bookmark_html_writer by populating a BookmarkModel, writing it out by | 142 // Tests bookmark_html_writer by populating a BookmarkModel, writing it out by |
| 143 // way of bookmark_html_writer, then using the importer to read it back in. | 143 // way of bookmark_html_writer, then using the importer to read it back in. |
| 144 TEST_F(BookmarkHTMLWriterTest, Test) { | 144 TEST_F(BookmarkHTMLWriterTest, Test) { |
| 145 MessageLoop message_loop; | 145 base::MessageLoop message_loop; |
| 146 content::TestBrowserThread fake_ui_thread(BrowserThread::UI, &message_loop); | 146 content::TestBrowserThread fake_ui_thread(BrowserThread::UI, &message_loop); |
| 147 content::TestBrowserThread fake_file_thread(BrowserThread::FILE, | 147 content::TestBrowserThread fake_file_thread(BrowserThread::FILE, |
| 148 &message_loop); | 148 &message_loop); |
| 149 | 149 |
| 150 TestingProfile profile; | 150 TestingProfile profile; |
| 151 profile.CreateHistoryService(true, false); | 151 profile.CreateHistoryService(true, false); |
| 152 profile.BlockUntilHistoryProcessesPendingRequests(); | 152 profile.BlockUntilHistoryProcessesPendingRequests(); |
| 153 profile.CreateFaviconService(); | 153 profile.CreateFaviconService(); |
| 154 profile.CreateBookmarkModel(true); | 154 profile.CreateBookmarkModel(true); |
| 155 | 155 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 bookmark_folder_name, string16(), string16()); | 272 bookmark_folder_name, string16(), string16()); |
| 273 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 273 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
| 274 string16(), string16(), string16()); | 274 string16(), string16(), string16()); |
| 275 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 275 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
| 276 string16(), string16(), string16()); | 276 string16(), string16(), string16()); |
| 277 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 277 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
| 278 f3_title, f4_title, string16()); | 278 f3_title, f4_title, string16()); |
| 279 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 279 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
| 280 string16(), string16(), string16()); | 280 string16(), string16(), string16()); |
| 281 } | 281 } |
| OLD | NEW |