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

Unified 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: Remove mac comment 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index b45c161edfc8dc43b2ec03b05f9689dd8511d3a3..0236a7cfb02c7a2169a4db964db35946d700ba9b 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -2417,6 +2417,66 @@ TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) {
EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize());
}
+TEST_F(WebContentsImplTest, CapturerPreventsHiding) {
+ const gfx::Size original_preferred_size(1024, 768);
+ contents()->UpdatePreferredSize(original_preferred_size);
+
+ TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>(
+ contents()->GetMainFrame()->GetRenderViewHost()->GetView());
+
+ // With no capturers, setting and un-setting occlusion should change the
+ // view's occlusion state.
+ EXPECT_FALSE(view->is_showing());
+ contents()->WasShown();
+ EXPECT_TRUE(view->is_showing());
+ contents()->WasHidden();
+ EXPECT_FALSE(view->is_showing());
+ contents()->WasShown();
+ EXPECT_TRUE(view->is_showing());
+
+ // Add a capturer and try to hide the contents. The view will remain visible.
+ contents()->IncrementCapturerCount(gfx::Size());
+ contents()->WasHidden();
+ EXPECT_TRUE(view->is_showing());
+
+ // Remove the capturer, and the WasHidden should take effect.
+ contents()->DecrementCapturerCount();
+ EXPECT_FALSE(view->is_showing());
+}
+
+TEST_F(WebContentsImplTest, CapturerPreventsOcclusion) {
+ const gfx::Size original_preferred_size(1024, 768);
+ contents()->UpdatePreferredSize(original_preferred_size);
+
+ TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>(
+ contents()->GetMainFrame()->GetRenderViewHost()->GetView());
+
+ // With no capturers, setting and un-setting occlusion should change the
+ // view's occlusion state.
+ EXPECT_FALSE(view->is_occluded());
+ contents()->WasOccluded();
+ EXPECT_TRUE(view->is_occluded());
+ contents()->WasUnOccluded();
+ EXPECT_FALSE(view->is_occluded());
+ contents()->WasOccluded();
+ EXPECT_TRUE(view->is_occluded());
+
+ // Add a capturer. This should cause the view to be un-occluded.
+ contents()->IncrementCapturerCount(gfx::Size());
+ EXPECT_FALSE(view->is_occluded());
+
+ // Try to occlude the view. This will fail to propagate because of the
+ // active capturer.
+ contents()->WasOccluded();
+ EXPECT_FALSE(view->is_occluded());
+
+ // Remove the capturer and try again.
+ contents()->DecrementCapturerCount();
+ EXPECT_FALSE(view->is_occluded());
+ contents()->WasOccluded();
+ EXPECT_TRUE(view->is_occluded());
+}
+
// Tests that GetLastActiveTime starts with a real, non-zero time and updates
// on activity.
TEST_F(WebContentsImplTest, GetLastActiveTime) {
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/browser/web_contents/web_contents_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698