summaryrefslogtreecommitdiffstats
path: root/chrome/browser/visitedlink_unittest.cc
diff options
context:
space:
mode:
authordglazkov@chromium.org <dglazkov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 15:27:19 +0000
committerdglazkov@chromium.org <dglazkov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 15:27:19 +0000
commit6e8d64646d95d8865178dc89bfa372a4f6c81ad9 (patch)
tree42e5102580d40d76ab9326c516cd462a2af74513 /chrome/browser/visitedlink_unittest.cc
parent58d518b6820b4a73b7f2d8ab4233687e0ea952ad (diff)
downloadchromium_src-6e8d64646d95d8865178dc89bfa372a4f6c81ad9.zip
chromium_src-6e8d64646d95d8865178dc89bfa372a4f6c81ad9.tar.gz
chromium_src-6e8d64646d95d8865178dc89bfa372a4f6c81ad9.tar.bz2
Rework visited link updating mechanism to be more robust.
This is a follow-up to http://src.chromium.org/viewvc/chrome?view=rev&revision=22540, which eliminated one crash, but still left behind another, this time due to racing between history backend and WebView creation. The solution is to make sure no visited-link-related messages are sent to the rendering process until we know for sure it is created. BUG=17555 TEST=VisitedLinkeRelayTest.WebViewReadiness R=darin Review URL: http://codereview.chromium.org/165210 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/visitedlink_unittest.cc')
-rw-r--r--chrome/browser/visitedlink_unittest.cc31
1 files changed, 30 insertions, 1 deletions
diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc
index d6735ae..8775f9e 100644
--- a/chrome/browser/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink_unittest.cc
@@ -565,7 +565,6 @@ class VisitedLinkEventsTest : public RenderViewHostTestHarness {
rvh_factory_.set_render_process_host_factory(&vc_rph_factory_);
profile_.reset(new VisitCountingProfile(event_listener_.get()));
RenderViewHostTestHarness::SetUp();
- rvh()->CreateRenderView();
}
VisitCountingProfile* profile() const {
@@ -648,6 +647,8 @@ TEST_F(VisitedLinkEventsTest, Coalescense) {
TEST_F(VisitedLinkRelayTest, Basics) {
VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
+ rvh()->CreateRenderView();
+
// Add a few URLs.
master->AddURL(GURL("http://acidtests.org/"));
master->AddURL(GURL("http://google.com/"));
@@ -670,6 +671,7 @@ TEST_F(VisitedLinkRelayTest, Basics) {
TEST_F(VisitedLinkRelayTest, TabVisibility) {
VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
+ rvh()->CreateRenderView();
// Simulate tab becoming inactive.
rvh()->WasHidden();
@@ -712,3 +714,30 @@ TEST_F(VisitedLinkRelayTest, TabVisibility) {
EXPECT_EQ(1, profile()->add_event_count());
EXPECT_EQ(1, profile()->reset_event_count());
}
+
+TEST_F(VisitedLinkRelayTest, WebViewReadiness) {
+ VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
+
+ // Add a few URLs.
+ master->AddURL(GURL("http://acidtests.org/"));
+ master->AddURL(GURL("http://google.com/"));
+ master->AddURL(GURL("http://chromium.org/"));
+
+ WaitForCoalescense();
+
+ std::set<GURL> deleted_urls;
+ deleted_urls.insert(GURL("http://acidtests.org/"));
+ master->DeleteURLs(deleted_urls);
+
+ // We shouldn't have any events, because RenderView hasn't been created,
+ // and we ensure that updates are sent until it is.
+ EXPECT_EQ(0, profile()->add_event_count());
+ EXPECT_EQ(0, profile()->reset_event_count());
+
+ rvh()->CreateRenderView();
+
+ // We should now have just a reset event: adds are eaten up by a reset
+ // that followed.
+ EXPECT_EQ(0, profile()->add_event_count());
+ EXPECT_EQ(1, profile()->reset_event_count());
+}