OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/fullscreen_jank_detector.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 namespace { |
| 14 |
| 15 const gfx::Size size1 = gfx::Size(1, 2); |
| 16 const gfx::Size size2 = gfx::Size(2, 1); |
| 17 |
| 18 } // anonymous namespace |
| 19 |
| 20 class FullscreenJankDetectorTest : public ::testing::Test { |
| 21 public: |
| 22 FullscreenJankDetectorTest() {} |
| 23 ~FullscreenJankDetectorTest() override {} |
| 24 |
| 25 void SetUp() override { InitializeState(); } |
| 26 |
| 27 protected: |
| 28 FullscreenJankDetector detector_; |
| 29 |
| 30 private: |
| 31 void InitializeState() { |
| 32 detector_.OnPhysicalBackingSizeChanged(size1); |
| 33 detector_.OnFrameMetadataUpdated(false, size1); |
| 34 EXPECT_FALSE(detector_.IsInFullscreenTransition()); |
| 35 } |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(FullscreenJankDetectorTest); |
| 38 }; |
| 39 |
| 40 TEST_F(FullscreenJankDetectorTest, ChangingSizeWhileNotFullscreenIsNotJank) { |
| 41 detector_.OnPhysicalBackingSizeChanged(size2); |
| 42 EXPECT_FALSE(detector_.IsInFullscreenTransition()); |
| 43 } |
| 44 |
| 45 TEST_F(FullscreenJankDetectorTest, EnterFullscreenRotateExitFullscreen) { |
| 46 // Entering fullscreen is jank. |
| 47 detector_.OnFullscreenStateChanged(true); |
| 48 EXPECT_TRUE(detector_.IsInFullscreenTransition()); |
| 49 |
| 50 // We received a new view size, but the frame size doesn't match. |
| 51 detector_.OnPhysicalBackingSizeChanged(size2); |
| 52 EXPECT_TRUE(detector_.IsInFullscreenTransition()); |
| 53 |
| 54 // We received a new frame with the correct size and fullscreen state. |
| 55 detector_.OnFrameMetadataUpdated(true, size2); |
| 56 EXPECT_FALSE(detector_.IsInFullscreenTransition()); |
| 57 |
| 58 // View size rotates. |
| 59 detector_.OnPhysicalBackingSizeChanged(size1); |
| 60 EXPECT_TRUE(detector_.IsInFullscreenTransition()); |
| 61 |
| 62 // Frame size catches up. |
| 63 detector_.OnFrameMetadataUpdated(true, size1); |
| 64 EXPECT_FALSE(detector_.IsInFullscreenTransition()); |
| 65 |
| 66 // Exiting fullscreen is jank. |
| 67 detector_.OnFullscreenStateChanged(false); |
| 68 EXPECT_TRUE(detector_.IsInFullscreenTransition()); |
| 69 |
| 70 // New view size. |
| 71 detector_.OnPhysicalBackingSizeChanged(size2); |
| 72 EXPECT_TRUE(detector_.IsInFullscreenTransition()); |
| 73 |
| 74 // Correctly-sized frame. |
| 75 detector_.OnFrameMetadataUpdated(false, size2); |
| 76 EXPECT_FALSE(detector_.IsInFullscreenTransition()); |
| 77 } |
| 78 |
| 79 } // namespace content |
OLD | NEW |