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

Unified Diff: content/browser/renderer_host/fullscreen_jank_detector_unittest.cc

Issue 2810813004: Hide fullscreen rotation jank (Closed)
Patch Set: Re-add feature flag Created 3 years, 6 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/renderer_host/fullscreen_jank_detector_unittest.cc
diff --git a/content/browser/renderer_host/fullscreen_jank_detector_unittest.cc b/content/browser/renderer_host/fullscreen_jank_detector_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1bd9f146249372aa535e89a332dcf0c6052f5ce6
--- /dev/null
+++ b/content/browser/renderer_host/fullscreen_jank_detector_unittest.cc
@@ -0,0 +1,79 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/fullscreen_jank_detector.h"
+
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+namespace {
+
+const gfx::Size size1 = gfx::Size(1, 2);
+const gfx::Size size2 = gfx::Size(2, 1);
+
+} // anonymous namespace
+
+class FullscreenJankDetectorTest : public ::testing::Test {
+ public:
+ FullscreenJankDetectorTest() {}
+ ~FullscreenJankDetectorTest() override {}
+
+ void SetUp() override { InitializeState(); }
+
+ protected:
+ FullscreenJankDetector detector_;
+
+ private:
+ void InitializeState() {
+ detector_.OnPhysicalBackingSizeChanged(size1);
+ detector_.OnFrameMetadataUpdated(false, size1);
+ EXPECT_FALSE(detector_.IsInFullscreenTransition());
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(FullscreenJankDetectorTest);
+};
+
+TEST_F(FullscreenJankDetectorTest, ChangingSizeWhileNotFullscreenIsNotJank) {
+ detector_.OnPhysicalBackingSizeChanged(size2);
+ EXPECT_FALSE(detector_.IsInFullscreenTransition());
+}
+
+TEST_F(FullscreenJankDetectorTest, EnterFullscreenRotateExitFullscreen) {
+ // Entering fullscreen is jank.
+ detector_.OnFullscreenStateChanged(true);
+ EXPECT_TRUE(detector_.IsInFullscreenTransition());
+
+ // We received a new view size, but the frame size doesn't match.
+ detector_.OnPhysicalBackingSizeChanged(size2);
+ EXPECT_TRUE(detector_.IsInFullscreenTransition());
+
+ // We received a new frame with the correct size and fullscreen state.
+ detector_.OnFrameMetadataUpdated(true, size2);
+ EXPECT_FALSE(detector_.IsInFullscreenTransition());
+
+ // View size rotates.
+ detector_.OnPhysicalBackingSizeChanged(size1);
+ EXPECT_TRUE(detector_.IsInFullscreenTransition());
+
+ // Frame size catches up.
+ detector_.OnFrameMetadataUpdated(true, size1);
+ EXPECT_FALSE(detector_.IsInFullscreenTransition());
+
+ // Exiting fullscreen is jank.
+ detector_.OnFullscreenStateChanged(false);
+ EXPECT_TRUE(detector_.IsInFullscreenTransition());
+
+ // New view size.
+ detector_.OnPhysicalBackingSizeChanged(size2);
+ EXPECT_TRUE(detector_.IsInFullscreenTransition());
+
+ // Correctly-sized frame.
+ detector_.OnFrameMetadataUpdated(false, size2);
+ EXPECT_FALSE(detector_.IsInFullscreenTransition());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698