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

Side by Side Diff: content/public/test/render_view_test.cc

Issue 1363523002: RenderViewTests: Implement proper shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use EXPECT_EQ instead of DCHECK_EQ. Created 5 years, 3 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
« no previous file with comments | « content/public/test/render_view_test.h ('k') | 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 "content/public/test/render_view_test.h" 5 #include "content/public/test/render_view_test.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 InitializeMojo(); 263 InitializeMojo();
264 #endif 264 #endif
265 265
266 // This needs to pass the mock render thread to the view. 266 // This needs to pass the mock render thread to the view.
267 RenderViewImpl* view = 267 RenderViewImpl* view =
268 RenderViewImpl::Create(compositor_deps_.get(), view_params, false); 268 RenderViewImpl::Create(compositor_deps_.get(), view_params, false);
269 view_ = view; 269 view_ = view;
270 } 270 }
271 271
272 void RenderViewTest::TearDown() { 272 void RenderViewTest::TearDown() {
273 // Try very hard to collect garbage before shutting down.
274 // "5" was chosen following http://crbug.com/46571#c9
275 const int kGCIterations = 5;
276 for (int i = 0; i < kGCIterations; i++)
277 GetMainFrame()->collectGarbage();
278
279 // Run the loop so the release task from the renderwidget executes. 273 // Run the loop so the release task from the renderwidget executes.
280 ProcessPendingMessages(); 274 ProcessPendingMessages();
281 275
282 for (int i = 0; i < kGCIterations; i++) 276 render_thread_->SendCloseMessage();
283 GetMainFrame()->collectGarbage();
284 277
285 render_thread_->SendCloseMessage(); 278 scoped_ptr<blink::WebLeakDetector> leak_detector =
279 make_scoped_ptr(blink::WebLeakDetector::create(this));
280
281 leak_detector->collectGarbageAndGetDOMCounts(GetMainFrame());
282
286 view_ = NULL; 283 view_ = NULL;
287 mock_process_.reset(); 284 mock_process_.reset();
288 285
289 // After telling the view to close and resetting mock_process_ we may get 286 // After telling the view to close and resetting mock_process_ we may get
290 // some new tasks which need to be processed before shutting down WebKit 287 // some new tasks which need to be processed before shutting down WebKit
291 // (http://crbug.com/21508). 288 // (http://crbug.com/21508).
292 base::RunLoop().RunUntilIdle(); 289 base::RunLoop().RunUntilIdle();
293 290
294 #if defined(OS_MACOSX) 291 #if defined(OS_MACOSX)
295 // Needs to run before blink::shutdown(). 292 // Needs to run before blink::shutdown().
296 autorelease_pool_.reset(NULL); 293 autorelease_pool_.reset(NULL);
297 #endif 294 #endif
298 295
299 blink_platform_impl_.Shutdown(); 296 blink_platform_impl_.Shutdown();
300 blink::shutdown(); 297 blink::shutdown();
301 298
302 platform_->PlatformUninitialize(); 299 platform_->PlatformUninitialize();
303 platform_.reset(); 300 platform_.reset();
304 params_.reset(); 301 params_.reset();
305 command_line_.reset(); 302 command_line_.reset();
306 } 303 }
307 304
305 void RenderViewTest::onLeakDetectionComplete(const Result& result) {
306 EXPECT_EQ(0u, result.numberOfLiveAudioNodes);
307 EXPECT_EQ(0u, result.numberOfLiveDocuments);
308 EXPECT_EQ(0u, result.numberOfLiveNodes);
309 EXPECT_EQ(0u, result.numberOfLiveLayoutObjects);
310 EXPECT_EQ(0u, result.numberOfLiveResources);
311 EXPECT_EQ(0u, result.numberOfLiveActiveDOMObjects);
312 EXPECT_EQ(0u, result.numberOfLiveScriptPromises);
313 EXPECT_EQ(0u, result.numberOfLiveFrames);
314 EXPECT_EQ(0u, result.numberOfLiveV8PerContextData);
315 }
316
308 void RenderViewTest::SendNativeKeyEvent( 317 void RenderViewTest::SendNativeKeyEvent(
309 const NativeWebKeyboardEvent& key_event) { 318 const NativeWebKeyboardEvent& key_event) {
310 SendWebKeyboardEvent(key_event); 319 SendWebKeyboardEvent(key_event);
311 } 320 }
312 321
313 void RenderViewTest::SendWebKeyboardEvent( 322 void RenderViewTest::SendWebKeyboardEvent(
314 const blink::WebKeyboardEvent& key_event) { 323 const blink::WebKeyboardEvent& key_event) {
315 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 324 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
316 impl->OnMessageReceived( 325 impl->OnMessageReceived(
317 InputMsg_HandleInputEvent(0, &key_event, ui::LatencyInfo(), false)); 326 InputMsg_HandleInputEvent(0, &key_event, ui::LatencyInfo(), false));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 TestRenderFrame* frame = 594 TestRenderFrame* frame =
586 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); 595 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame());
587 frame->Navigate(common_params, StartNavigationParams(), request_params); 596 frame->Navigate(common_params, StartNavigationParams(), request_params);
588 597
589 // The load actually happens asynchronously, so we pump messages to process 598 // The load actually happens asynchronously, so we pump messages to process
590 // the pending continuation. 599 // the pending continuation.
591 FrameLoadWaiter(frame).Wait(); 600 FrameLoadWaiter(frame).Wait();
592 } 601 }
593 602
594 } // namespace content 603 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/render_view_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698