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

Side by Side Diff: chrome/browser/ui/bookmarks/bookmark_browsertest.cc

Issue 11787025: bookmarks: Wait for bookmark model to load by using WaitForBookmarkModelToLoad() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/timer.h" 6 #include "base/timer.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 FROM_HERE, 50 FROM_HERE,
51 base::TimeDelta::FromMilliseconds(15), 51 base::TimeDelta::FromMilliseconds(15),
52 base::Bind(&CheckAnimation, browser(), runner->QuitClosure())); 52 base::Bind(&CheckAnimation, browser(), runner->QuitClosure()));
53 runner->Run(); 53 runner->Run();
54 return base::Time::Now() - start; 54 return base::Time::Now() - start;
55 } 55 }
56 56
57 BookmarkModel* WaitForBookmarkModel(Profile* profile) { 57 BookmarkModel* WaitForBookmarkModel(Profile* profile) {
58 BookmarkModel* bookmark_model = 58 BookmarkModel* bookmark_model =
59 BookmarkModelFactory::GetForProfile(profile); 59 BookmarkModelFactory::GetForProfile(profile);
60 if (!bookmark_model->IsLoaded()) { 60 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model);
61 content::WindowedNotificationObserver observer(
62 chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
63 content::NotificationService::AllSources());
64 observer.Wait();
65 }
66 return bookmark_model; 61 return bookmark_model;
67 } 62 }
68 }; 63 };
69 64
70 // Test of bookmark bar toggling, visibility, and animation. 65 // Test of bookmark bar toggling, visibility, and animation.
71 IN_PROC_BROWSER_TEST_F(BookmarkBrowsertest, BookmarkBarVisibleWait) { 66 IN_PROC_BROWSER_TEST_F(BookmarkBrowsertest, BookmarkBarVisibleWait) {
72 ASSERT_FALSE(IsVisible()); 67 ASSERT_FALSE(IsVisible());
73 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); 68 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
74 base::TimeDelta delay = WaitForBookmarkBarAnimationToFinish(); 69 base::TimeDelta delay = WaitForBookmarkBarAnimationToFinish();
75 LOG(INFO) << "Took " << delay.InMilliseconds() << " ms to show bookmark bar"; 70 LOG(INFO) << "Took " << delay.InMilliseconds() << " ms to show bookmark bar";
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 bookmark_model1, GURL(kPersistBookmarkURL), 116 bookmark_model1, GURL(kPersistBookmarkURL),
122 ASCIIToUTF16(kPersistBookmarkTitle)); 117 ASCIIToUTF16(kPersistBookmarkTitle));
123 std::vector<BookmarkService::URLAndTitle> urls1, urls2; 118 std::vector<BookmarkService::URLAndTitle> urls1, urls2;
124 bookmark_model1->GetBookmarks(&urls1); 119 bookmark_model1->GetBookmarks(&urls1);
125 bookmark_model2->GetBookmarks(&urls2); 120 bookmark_model2->GetBookmarks(&urls2);
126 ASSERT_EQ(1u, urls1.size()); 121 ASSERT_EQ(1u, urls1.size());
127 ASSERT_TRUE(urls2.empty()); 122 ASSERT_TRUE(urls2.empty());
128 } 123 }
129 124
130 #endif 125 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698