Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Alan Cutter | 4cfd0c53 | 2019-11-20 05:55:33 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Peter Kasting | 919ce65 | 2020-05-07 10:22:36 | [diff] [blame] | 5 | #include "content/public/test/browser_test.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 | |
Alison Gale | d94ce4f | 2024-04-22 15:20:39 | [diff] [blame] | 14 | // TODO(crbug.com/41478398): Add test coverage across all platforms. |
Georg Neis | 35ff854b | 2024-12-17 02:02:08 | [diff] [blame] | 15 | #if BUILDFLAG(IS_CHROMEOS) |
Alan Cutter | 4cfd0c53 | 2019-11-20 05:55:33 | [diff] [blame] | 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 | } |
Georg Neis | 35ff854b | 2024-12-17 02:02:08 | [diff] [blame] | 42 | #endif // BUILDFLAG(IS_CHROMEOS) |
Alan Cutter | 4cfd0c53 | 2019-11-20 05:55:33 | [diff] [blame] | 43 | |
| 44 | } // namespace content |