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

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

Issue 2134753004: mash: Partially migrate ScreenOrientationController to ash/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase; explicitily call OnWindowVisibilityChanging. Created 4 years, 5 months 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
« no previous file with comments | « no previous file | ash/content/screen_orientation_delegate_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/display/screen_orientation_controller_chromeos.h" 5 #include "ash/display/screen_orientation_controller_chromeos.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/ash_switches.h" 11 #include "ash/common/ash_switches.h"
11 #include "ash/common/display/display_info.h" 12 #include "ash/common/display/display_info.h"
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
14 #include "ash/content/shell_content_state.h" 15 #include "ash/content/shell_content_state.h"
15 #include "ash/display/display_manager.h" 16 #include "ash/display/display_manager.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
18 #include "ash/test/ash_test_helper.h" 19 #include "ash/test/ash_test_helper.h"
19 #include "ash/test/content/test_shell_content_state.h" 20 #include "ash/test/content/test_shell_content_state.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 289
289 // Tests that a rotation lock is removed when the setting window is hidden, and 290 // Tests that a rotation lock is removed when the setting window is hidden, and
290 // that it is reapplied when the window becomes visible. 291 // that it is reapplied when the window becomes visible.
291 TEST_F(ScreenOrientationControllerTest, VisibilityChangesLock) { 292 TEST_F(ScreenOrientationControllerTest, VisibilityChangesLock) {
292 std::unique_ptr<content::WebContents> content(CreateWebContents()); 293 std::unique_ptr<content::WebContents> content(CreateWebContents());
293 std::unique_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 294 std::unique_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
294 AttachAndActivateWebContents(content.get(), focus_window.get()); 295 AttachAndActivateWebContents(content.get(), focus_window.get());
295 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 296 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
296 EXPECT_TRUE(RotationLocked()); 297 EXPECT_TRUE(RotationLocked());
297 298
298 aura::Window* window = content->GetNativeView(); 299 WmWindow* window = WmWindowAura::Get(content->GetNativeView());
300 ScreenOrientationController* controller =
301 Shell::GetInstance()->screen_orientation_controller();
299 window->Hide(); 302 window->Hide();
303 controller->OnWindowVisibilityChanging(window, false);
jonross 2016/07/11 19:48:13 I'm a bit concerned that this is not being trigger
msw 2016/07/11 20:02:31 Might be async WmWindow behavior, or a plumbing is
jonross 2016/07/11 20:10:58 ScreenOrientationController should become a listen
msw 2016/07/11 21:53:10 Thanks for pushing me to dig in; I'll need to impl
300 EXPECT_FALSE(RotationLocked()); 304 EXPECT_FALSE(RotationLocked());
301 305
302 window->Show(); 306 window->Show();
307 controller->OnWindowVisibilityChanging(window, true);
303 EXPECT_TRUE(RotationLocked()); 308 EXPECT_TRUE(RotationLocked());
304 } 309 }
305 310
306 // Tests that when a window is destroyed that its rotation lock is removed, and 311 // Tests that when a window is destroyed that its rotation lock is removed, and
307 // window activations no longer change the lock 312 // window activations no longer change the lock
308 TEST_F(ScreenOrientationControllerTest, WindowDestructionRemovesLock) { 313 TEST_F(ScreenOrientationControllerTest, WindowDestructionRemovesLock) {
309 std::unique_ptr<content::WebContents> content(CreateWebContents()); 314 std::unique_ptr<content::WebContents> content(CreateWebContents());
310 std::unique_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0)); 315 std::unique_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0));
311 std::unique_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1)); 316 std::unique_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1));
312 317
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 655
651 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( 656 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation(
652 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE); 657 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE);
653 658
654 EXPECT_EQ( 659 EXPECT_EQ(
655 kNewRotation, 660 kNewRotation,
656 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); 661 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation());
657 } 662 }
658 663
659 } // namespace ash 664 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/content/screen_orientation_delegate_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698