| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 #ifdef CHROME_PERSONALIZATION |
| 5 |
| 6 #include "chrome/test/live_sync/live_bookmarks_sync_test.h" |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/command_line.h" |
| 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 14 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/profile_manager.h" |
| 16 #include "chrome/test/ui_test_utils.h" |
| 17 |
| 18 // BookmarkLoadObserver is used when blocking until the BookmarkModel |
| 19 // finishes loading. As soon as the BookmarkModel finishes loading the message |
| 20 // loop is quit. |
| 21 class BookmarkLoadObserver : public BookmarkModelObserver { |
| 22 public: |
| 23 BookmarkLoadObserver() {} |
| 24 virtual void Loaded(BookmarkModel* model) { |
| 25 MessageLoop::current()->Quit(); |
| 26 } |
| 27 |
| 28 virtual void BookmarkNodeMoved(BookmarkModel* model, |
| 29 const BookmarkNode* old_parent, |
| 30 int old_index, |
| 31 const BookmarkNode* new_parent, |
| 32 int new_index) {} |
| 33 virtual void BookmarkNodeAdded(BookmarkModel* model, |
| 34 const BookmarkNode* parent, |
| 35 int index) {} |
| 36 virtual void BookmarkNodeRemoved(BookmarkModel* model, |
| 37 const BookmarkNode* parent, |
| 38 int old_index, |
| 39 const BookmarkNode* node) {} |
| 40 virtual void BookmarkNodeChanged(BookmarkModel* model, |
| 41 const BookmarkNode* node) {} |
| 42 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 43 const BookmarkNode* node) {} |
| 44 virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, |
| 45 const BookmarkNode* node) {} |
| 46 |
| 47 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver); |
| 49 }; |
| 50 |
| 51 // static |
| 52 void LiveBookmarksSyncTest::BlockUntilLoaded(BookmarkModel* m) { |
| 53 if (m->IsLoaded()) |
| 54 return; |
| 55 BookmarkLoadObserver observer; |
| 56 m->AddObserver(&observer); |
| 57 ui_test_utils::RunMessageLoop(); |
| 58 m->RemoveObserver(&observer); |
| 59 ASSERT_TRUE(m->IsLoaded()); |
| 60 } |
| 61 |
| 62 // static |
| 63 const BookmarkNode* LiveBookmarksSyncTest::GetByUniqueURL(BookmarkModel* m, |
| 64 const GURL& url) { |
| 65 std::vector<const BookmarkNode*> nodes; |
| 66 m->GetNodesByURL(url, &nodes); |
| 67 EXPECT_EQ(1, nodes.size()); |
| 68 return nodes[0]; |
| 69 } |
| 70 |
| 71 // static |
| 72 Profile* LiveBookmarksSyncTest::MakeProfile(const string16& name) { |
| 73 string16 path_string; |
| 74 PathService::Get(chrome::DIR_USER_DATA, &path_string); |
| 75 file_util::AppendToPath(&path_string, name); |
| 76 FilePath path(path_string); |
| 77 return ProfileManager::CreateProfile(path, name, L"", L""); |
| 78 } |
| 79 |
| 80 #endif // CHROME_PERSONALIZATION |
| OLD | NEW |