Alan Cutter | 4cfd0c53 | 2019-11-20 05:55:33 | [diff] [blame] | 1 | // Copyright 2019 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 "base/strings/stringprintf.h" |
Alan Cutter | 4cfd0c53 | 2019-11-20 05:55:33 | [diff] [blame] | 6 | #include "content/public/test/browser_test_utils.h" |
| 7 | #include "content/public/test/content_browser_test.h" |
| 8 | #include "content/shell/browser/shell.h" |
| 9 | #include "ui/display/display.h" |
| 10 | #include "ui/display/screen.h" |
| 11 | |
| 12 | namespace content { |
| 13 | |
| 14 | // TODO(https://crbug.com/998131): Add test coverage across all platforms. |
| 15 | #if defined(OS_CHROMEOS) |
| 16 | class PanelRotationBrowserTest : public ContentBrowserTest { |
| 17 | protected: |
| 18 | void SetPanelRotation(display::Display::Rotation rotation) { |
| 19 | display::Screen* screen = display::Screen::GetScreen(); |
| 20 | screen->SetPanelRotationForTesting(screen->GetPrimaryDisplay().id(), |
| 21 | rotation); |
| 22 | } |
| 23 | int ReadScreenOrientationAngle() { |
| 24 | return EvalJs(CreateBrowser()->web_contents(), "screen.orientation.angle") |
| 25 | .ExtractInt(); |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | IN_PROC_BROWSER_TEST_F(PanelRotationBrowserTest, ScreenOrientationAPI) { |
| 30 | SetPanelRotation(display::Display::ROTATE_0); |
| 31 | EXPECT_EQ(ReadScreenOrientationAngle(), 0); |
| 32 | |
| 33 | SetPanelRotation(display::Display::ROTATE_90); |
| 34 | EXPECT_EQ(ReadScreenOrientationAngle(), 270); |
| 35 | |
| 36 | SetPanelRotation(display::Display::ROTATE_180); |
| 37 | EXPECT_EQ(ReadScreenOrientationAngle(), 180); |
| 38 | |
| 39 | SetPanelRotation(display::Display::ROTATE_270); |
| 40 | EXPECT_EQ(ReadScreenOrientationAngle(), 90); |
| 41 | } |
| 42 | #endif // defined(OS_CHROMEOS) |
| 43 | |
| 44 | } // namespace content |