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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 853883007: Add occlusion support to WebContentsImpl and RenderWidgetHostView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up Created 5 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
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/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/frame_host/cross_site_transferring_request.h" 7 #include "content/browser/frame_host/cross_site_transferring_request.h"
8 #include "content/browser/frame_host/interstitial_page_impl.h" 8 #include "content/browser/frame_host/interstitial_page_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/media/audio_stream_monitor.h" 10 #include "content/browser/media/audio_stream_monitor.h"
(...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 EXPECT_EQ(1, contents()->GetCapturerCount()); 2410 EXPECT_EQ(1, contents()->GetCapturerCount());
2411 EXPECT_EQ(capture_size, contents()->GetPreferredSize()); 2411 EXPECT_EQ(capture_size, contents()->GetPreferredSize());
2412 2412
2413 // Decrement capturer count, and since the count has dropped to zero, the 2413 // Decrement capturer count, and since the count has dropped to zero, the
2414 // original preferred size should be restored. 2414 // original preferred size should be restored.
2415 contents()->DecrementCapturerCount(); 2415 contents()->DecrementCapturerCount();
2416 EXPECT_EQ(0, contents()->GetCapturerCount()); 2416 EXPECT_EQ(0, contents()->GetCapturerCount());
2417 EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize()); 2417 EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize());
2418 } 2418 }
2419 2419
2420 TEST_F(WebContentsImplTest, CapturerPreventsHiding) {
2421 const gfx::Size original_preferred_size(1024, 768);
2422 contents()->UpdatePreferredSize(original_preferred_size);
2423
2424 TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>(
2425 contents()->GetMainFrame()->GetRenderViewHost()->GetView());
2426
2427 // With no capturers, setting and un-setting occlusion should change the
2428 // view's occlusion state.
2429 EXPECT_FALSE(view->is_showing());
2430 contents()->WasShown();
2431 EXPECT_TRUE(view->is_showing());
2432 contents()->WasHidden();
2433 EXPECT_FALSE(view->is_showing());
2434 contents()->WasShown();
2435 EXPECT_TRUE(view->is_showing());
2436
2437 // Add a capturer and try to hide the contents. The view will remain visible.
2438 contents()->IncrementCapturerCount(gfx::Size());
2439 contents()->WasHidden();
2440 EXPECT_TRUE(view->is_showing());
2441
2442 // Remove the capturer, and the WasHidden should take effect.
2443 contents()->DecrementCapturerCount();
2444 EXPECT_FALSE(view->is_showing());
2445 }
2446
2447 TEST_F(WebContentsImplTest, CapturerPreventsOcclusion) {
2448 const gfx::Size original_preferred_size(1024, 768);
2449 contents()->UpdatePreferredSize(original_preferred_size);
2450
2451 TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>(
2452 contents()->GetMainFrame()->GetRenderViewHost()->GetView());
2453
2454 // With no capturers, setting and un-setting occlusion should change the
2455 // view's occlusion state.
2456 EXPECT_FALSE(view->is_occluded());
2457 contents()->WasOccluded();
2458 EXPECT_TRUE(view->is_occluded());
2459 contents()->WasUnOccluded();
2460 EXPECT_FALSE(view->is_occluded());
2461 contents()->WasOccluded();
2462 EXPECT_TRUE(view->is_occluded());
2463
2464 // Add a capturer. This should cause the view to be un-occluded.
2465 contents()->IncrementCapturerCount(gfx::Size());
2466 EXPECT_FALSE(view->is_occluded());
2467
2468 // Try to occlude the view. This will fail to propagate because of the
2469 // active capturer.
2470 contents()->WasOccluded();
2471 EXPECT_FALSE(view->is_occluded());
2472
2473 // Remove the capturer and try again.
2474 contents()->DecrementCapturerCount();
2475 EXPECT_FALSE(view->is_occluded());
2476 contents()->WasOccluded();
2477 EXPECT_TRUE(view->is_occluded());
2478 }
2479
2420 // Tests that GetLastActiveTime starts with a real, non-zero time and updates 2480 // Tests that GetLastActiveTime starts with a real, non-zero time and updates
2421 // on activity. 2481 // on activity.
2422 TEST_F(WebContentsImplTest, GetLastActiveTime) { 2482 TEST_F(WebContentsImplTest, GetLastActiveTime) {
2423 // The WebContents starts with a valid creation time. 2483 // The WebContents starts with a valid creation time.
2424 EXPECT_FALSE(contents()->GetLastActiveTime().is_null()); 2484 EXPECT_FALSE(contents()->GetLastActiveTime().is_null());
2425 2485
2426 // Reset the last active time to a known-bad value. 2486 // Reset the last active time to a known-bad value.
2427 contents()->last_active_time_ = base::TimeTicks(); 2487 contents()->last_active_time_ = base::TimeTicks();
2428 ASSERT_TRUE(contents()->GetLastActiveTime().is_null()); 2488 ASSERT_TRUE(contents()->GetLastActiveTime().is_null());
2429 2489
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 2846
2787 // Destroy the remote player. No power save blockers should remain. 2847 // Destroy the remote player. No power save blockers should remain.
2788 rfh->OnMessageReceived( 2848 rfh->OnMessageReceived(
2789 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); 2849 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId));
2790 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 2850 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
2791 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 2851 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
2792 } 2852 }
2793 #endif 2853 #endif
2794 2854
2795 } // namespace content 2855 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698