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

Unified Diff: chrome/renderer/page_click_tracker_unittest.cc

Issue 6151011: Introduce RenderView::Observer interface so that RenderView doesn't have to k... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/page_click_tracker_unittest.cc
===================================================================
--- chrome/renderer/page_click_tracker_unittest.cc (revision 71253)
+++ chrome/renderer/page_click_tracker_unittest.cc (working copy)
@@ -49,10 +49,14 @@
// Tests that PageClickTracker does notify correctly when a node is clicked.
TEST_F(RenderViewTest, PageClickTracker) {
+ // RenderView creates PageClickTracker but it doesn't keep it around. Rather
+ // than make it do so for the test, we create a new object.
+ PageClickTracker* page_click_tracker = new PageClickTracker(view_);
dhollowa 2011/01/14 16:40:48 Leak? I'm not seeing where |page_click_tracker| g
jam 2011/01/14 23:00:03 RenderView manages the observers and will delete t
dhollowa 2011/01/14 23:21:23 Really? But there is a raw "new PageClickTracker(
jam 2011/01/15 00:06:54 check out render_view_observer.h. The objects bec
+
TestPageClickListener test_listener1;
TestPageClickListener test_listener2;
- view_->page_click_tracker()->AddListener(&test_listener1);
- view_->page_click_tracker()->AddListener(&test_listener2);
+ page_click_tracker->AddListener(&test_listener1);
+ page_click_tracker->AddListener(&test_listener2);
LoadHTML("<form>"
" <input type='text' id='text'></input><br>"
@@ -106,14 +110,14 @@
test_listener1.ClearResults();
// Make sure removing a listener work.
- view_->page_click_tracker()->RemoveListener(&test_listener1);
+ page_click_tracker->RemoveListener(&test_listener1);
EXPECT_TRUE(SimulateElementClick("text"));
EXPECT_FALSE(test_listener1.called_);
EXPECT_TRUE(test_listener2.called_);
test_listener2.ClearResults();
// Make sure we don't choke when no listeners are registered.
- view_->page_click_tracker()->RemoveListener(&test_listener2);
+ page_click_tracker->RemoveListener(&test_listener2);
EXPECT_TRUE(SimulateElementClick("text"));
EXPECT_FALSE(test_listener1.called_);
EXPECT_FALSE(test_listener2.called_);

Powered by Google App Engine
This is Rietveld 408576698