blob: 24352438aa4606c223d71a627e65163482a2ff48 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2019 The Chromium Authors
Alan Cutter4cfd0c532019-11-20 05:55:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Peter Kasting919ce652020-05-07 10:22:365#include "content/public/test/browser_test.h"
Alan Cutter4cfd0c532019-11-20 05:55:336#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
12namespace content {
13
Alison Galed94ce4f2024-04-22 15:20:3914// TODO(crbug.com/41478398): Add test coverage across all platforms.
Georg Neis35ff854b2024-12-17 02:02:0815#if BUILDFLAG(IS_CHROMEOS)
Alan Cutter4cfd0c532019-11-20 05:55:3316class 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
29IN_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 Neis35ff854b2024-12-17 02:02:0842#endif // BUILDFLAG(IS_CHROMEOS)
Alan Cutter4cfd0c532019-11-20 05:55:3343
44} // namespace content