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