summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 23:00:09 +0000
committersuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 23:00:09 +0000
commitd1039ff56adb7ca0d9fcb1283e40a020a94e6943 (patch)
tree0417a0150ffa9a4cda2a9c58a1507227361216e3 /chrome
parentdcd47e751e95cf52cbe4da3fc8ef34adf8413cb5 (diff)
downloadchromium_src-d1039ff56adb7ca0d9fcb1283e40a020a94e6943.zip
chromium_src-d1039ff56adb7ca0d9fcb1283e40a020a94e6943.tar.gz
chromium_src-d1039ff56adb7ca0d9fcb1283e40a020a94e6943.tar.bz2
Fix a crash issue of AutocompleteEditViewTest.
This CL fixes a crash issue of AutocompleteEditViewTest, which is due to not waiting for bookmark model and history service being fully loaded. BUG=21971 TEST=none Review URL: http://codereview.chromium.org/201135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
index 1023b9c..37585d2 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
@@ -197,10 +197,28 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
}
void SetupHistory() {
+ Profile* profile = browser()->profile();
HistoryService* history_service =
- browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ profile->GetHistoryService(Profile::EXPLICIT_ACCESS);
ASSERT_TRUE(history_service);
+ if (!history_service->backend_loaded()) {
+ NotificationRegistrar registrar;
+ registrar.Add(this, NotificationType::HISTORY_LOADED,
+ Source<Profile>(profile));
+ ui_test_utils::RunMessageLoop();
+ }
+
+ BookmarkModel* bookmark_model = profile->GetBookmarkModel();
+ ASSERT_TRUE(bookmark_model);
+
+ if (!bookmark_model->IsLoaded()) {
+ NotificationRegistrar registrar;
+ registrar.Add(this, NotificationType::BOOKMARK_MODEL_LOADED,
+ Source<Profile>(profile));
+ ui_test_utils::RunMessageLoop();
+ }
+
// Add enough history pages containing |kSearchText| to trigger open history
// page url in autocomplete result.
for (size_t i = 0; i < arraysize(kHistoryEntries); i++) {
@@ -213,8 +231,7 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
cur.typed_count, t, false);
history_service->SetPageContents(url, cur.body);
if (cur.starred) {
- browser()->profile()->GetBookmarkModel()->SetURLStarred(
- url, std::wstring(), true);
+ bookmark_model->SetURLStarred(url, std::wstring(), true);
}
}
}
@@ -233,6 +250,8 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
case NotificationType::TAB_CLOSED:
case NotificationType::TEMPLATE_URL_MODEL_LOADED:
case NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED:
+ case NotificationType::HISTORY_LOADED:
+ case NotificationType::BOOKMARK_MODEL_LOADED:
break;
default:
FAIL() << "Unexpected notification type";