Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: ash/content/display/screen_orientation_delegate_chromeos_unittest.cc

Issue 759063002: Move Screen Rotation from MaximizeModeController to ScreenOrientationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/ash_switches.h" 5 #include "ash/ash_switches.h"
6 #include "ash/content/display/screen_orientation_delegate_chromeos.h" 6 #include "ash/content/display/screen_orientation_delegate_chromeos.h"
7 #include "ash/display/display_info.h" 7 #include "ash/display/display_info.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/ash_test_helper.h" 11 #include "ash/test/ash_test_helper.h"
12 #include "ash/test/test_shell_delegate.h" 12 #include "ash/test/test_shell_delegate.h"
13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
flackr 2014/11/27 15:39:15 Obsolete?
jonross 2014/12/10 17:57:30 Yup, removed.
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/test_browser_context.h" 18 #include "content/public/test/test_browser_context.h"
19 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" 19 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
20 #include "ui/gfx/display.h" 20 #include "ui/gfx/display.h"
21 #include "ui/views/test/webview_test_helper.h" 21 #include "ui/views/test/webview_test_helper.h"
22 #include "ui/views/view.h" 22 #include "ui/views/view.h"
23 #include "ui/views/views_delegate.h" 23 #include "ui/views/views_delegate.h"
24 24
25 namespace ash { 25 namespace ash {
26 26
27 namespace { 27 namespace {
28 28
29 gfx::Display::Rotation Rotation() { 29 gfx::Display::Rotation Rotation() {
30 return Shell::GetInstance() 30 return Shell::GetInstance()
31 ->display_manager() 31 ->display_manager()
32 ->GetDisplayInfo(gfx::Display::InternalDisplayId()) 32 ->GetDisplayInfo(gfx::Display::InternalDisplayId())
33 .rotation(); 33 .rotation();
34 } 34 }
35 35
36 bool RotationLocked() { 36 bool RotationLocked() {
37 return Shell::GetInstance()->maximize_mode_controller()->rotation_locked(); 37 return Shell::GetInstance()->screen_orientation_delegate()->rotation_locked();
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 class ScreenOrientationDelegateTest : public test::AshTestBase { 42 class ScreenOrientationDelegateTest : public test::AshTestBase {
43 public: 43 public:
44 ScreenOrientationDelegateTest(); 44 ScreenOrientationDelegateTest();
45 virtual ~ScreenOrientationDelegateTest(); 45 virtual ~ScreenOrientationDelegateTest();
46 46
47 ScreenOrientationDelegate* delegate() { return screen_orientation_delegate_; } 47 ScreenOrientationDelegate* delegate() { return screen_orientation_delegate_; }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); 139 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation());
140 EXPECT_TRUE(RotationLocked()); 140 EXPECT_TRUE(RotationLocked());
141 141
142 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 142 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
143 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); 143 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
144 } 144 }
145 145
146 // Tests that a user initiated rotation lock cannot be unlocked by a 146 // Tests that a user initiated rotation lock cannot be unlocked by a
147 // content::WebContents. 147 // content::WebContents.
148 TEST_F(ScreenOrientationDelegateTest, UserLockRejectsUnlock) { 148 TEST_F(ScreenOrientationDelegateTest, UserLockRejectsUnlock) {
149 Shell::GetInstance()->maximize_mode_controller()->SetRotationLocked(true); 149 delegate()->SetRotationLocked(true);
150 150
151 scoped_ptr<content::WebContents> content(CreateWebContents()); 151 scoped_ptr<content::WebContents> content(CreateWebContents());
152 delegate()->Unlock(content.get()); 152 delegate()->Unlock(content.get());
153 EXPECT_TRUE(RotationLocked()); 153 EXPECT_TRUE(RotationLocked());
154 } 154 }
155 155
156 // Tests that orientation can only be set by the first content::WebContents that 156 // Tests that orientation can only be set by the first content::WebContents that
157 // has set a rotation lock. 157 // has set a rotation lock.
158 TEST_F(ScreenOrientationDelegateTest, SecondContentCannotChangeOrientation) { 158 TEST_F(ScreenOrientationDelegateTest, SecondContentCannotChangeOrientation) {
159 scoped_ptr<content::WebContents> content1(CreateWebContents()); 159 scoped_ptr<content::WebContents> content1(CreateWebContents());
(...skipping 25 matching lines...) Expand all
185 ASSERT_NE(content1->GetNativeView(), content2->GetNativeView()); 185 ASSERT_NE(content1->GetNativeView(), content2->GetNativeView());
186 186
187 delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); 187 delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape);
188 delegate()->Unlock(content1.get()); 188 delegate()->Unlock(content1.get());
189 delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); 189 delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait);
190 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); 190 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation());
191 EXPECT_TRUE(RotationLocked()); 191 EXPECT_TRUE(RotationLocked());
192 } 192 }
193 193
194 } // namespace ash 194 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698