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

Side by Side Diff: ash/rotator/screen_rotation_animator_unittest.cc

Issue 2837773003: Flip the flag to enable smooth screen rotation by default. (Closed)
Patch Set: Add comments how the test will work. Created 3 years, 8 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 | « ash/rotator/screen_rotation_animator.cc ('k') | ash/test/ash_test_base.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/rotator/screen_rotation_animator.h" 5 #include "ash/rotator/screen_rotation_animator.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/window_tree_host_manager.h" 8 #include "ash/display/window_tree_host_manager.h"
9 #include "ash/public/cpp/config.h" 9 #include "ash/public/cpp/config.h"
10 #include "ash/rotator/screen_rotation_animator_observer.h" 10 #include "ash/rotator/screen_rotation_animator_observer.h"
11 #include "ash/rotator/test/screen_rotation_animator_test_api.h" 11 #include "ash/rotator/test/screen_rotation_animator_test_api.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/shell_port.h" 13 #include "ash/shell_port.h"
14 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
15 #include "ash/test/ash_test_helper.h"
15 #include "base/callback_forward.h" 16 #include "base/callback_forward.h"
16 #include "base/command_line.h" 17 #include "base/command_line.h"
17 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
18 #include "base/run_loop.h" 19 #include "base/run_loop.h"
19 #include "cc/output/copy_output_request.h" 20 #include "cc/output/copy_output_request.h"
20 #include "cc/output/copy_output_result.h" 21 #include "cc/output/copy_output_result.h"
21 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 22 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
22 #include "ui/display/display.h" 23 #include "ui/display/display.h"
23 #include "ui/display/manager/display_manager.h" 24 #include "ui/display/manager/display_manager.h"
24 #include "ui/display/screen.h" 25 #include "ui/display/screen.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 UpdateDisplay(specs); 216 UpdateDisplay(specs);
216 QuitWaitForCopyCallback(); 217 QuitWaitForCopyCallback();
217 } 218 }
218 219
219 void ScreenRotationAnimatorSmoothAnimationTest::QuitWaitForCopyCallback() { 220 void ScreenRotationAnimatorSmoothAnimationTest::QuitWaitForCopyCallback() {
220 run_loop_->QuitWhenIdle(); 221 run_loop_->QuitWhenIdle();
221 } 222 }
222 223
223 void ScreenRotationAnimatorSmoothAnimationTest::SetUp() { 224 void ScreenRotationAnimatorSmoothAnimationTest::SetUp() {
224 AshTestBase::SetUp(); 225 AshTestBase::SetUp();
226 // Resets the commandline will clear all the switches, including
227 // "ash-disable-smooth-screen-rotation", so that we can test the smooth screen
228 // rotation animation. The |animator| is recreated and checking this swtich.
229 ash_test_helper()->reset_commandline();
225 230
226 display_ = display::Screen::GetScreen()->GetPrimaryDisplay(); 231 display_ = display::Screen::GetScreen()->GetPrimaryDisplay();
227 if (Shell::GetAshConfig() == Config::MASH) { 232 if (Shell::GetAshConfig() == Config::MASH) {
228 ASSERT_TRUE(ShellPort::Get()->GetDisplayInfo(display_id()).id() != 233 ASSERT_TRUE(ShellPort::Get()->GetDisplayInfo(display_id()).id() !=
229 display_id()); 234 display_id());
230 return; 235 return;
231 } 236 }
232 237
233 base::CommandLine::ForCurrentProcess()->AppendSwitch(
234 switches::kAshEnableSmoothScreenRotation);
235 run_loop_ = base::MakeUnique<base::RunLoop>(); 238 run_loop_ = base::MakeUnique<base::RunLoop>();
236 SetScreenRotationAnimator(display_.id(), run_loop_->QuitWhenIdleClosure(), 239 SetScreenRotationAnimator(display_.id(), run_loop_->QuitWhenIdleClosure(),
237 run_loop_->QuitWhenIdleClosure()); 240 run_loop_->QuitWhenIdleClosure());
238 non_zero_duration_mode_ = 241 non_zero_duration_mode_ =
239 base::MakeUnique<ui::ScopedAnimationDurationScaleMode>( 242 base::MakeUnique<ui::ScopedAnimationDurationScaleMode>(
240 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); 243 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
241 } 244 }
242 245
243 void ScreenRotationAnimatorSmoothAnimationTest::SetScreenRotationAnimator( 246 void ScreenRotationAnimatorSmoothAnimationTest::SetScreenRotationAnimator(
244 int64_t display_id, 247 int64_t display_id,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 SetDisplayRotation(display_manager()->GetDisplayAt(1).id(), 537 SetDisplayRotation(display_manager()->GetDisplayAt(1).id(),
535 display::Display::ROTATE_0); 538 display::Display::ROTATE_0);
536 animator()->Rotate(display::Display::ROTATE_90, 539 animator()->Rotate(display::Display::ROTATE_90,
537 display::Display::RotationSource::ROTATION_SOURCE_USER); 540 display::Display::RotationSource::ROTATION_SOURCE_USER);
538 WaitForCopyCallback(); 541 WaitForCopyCallback();
539 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 542 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
540 EXPECT_EQ(secondary_display_id, display_manager()->GetDisplayAt(0).id()); 543 EXPECT_EQ(secondary_display_id, display_manager()->GetDisplayAt(0).id());
541 } 544 }
542 545
543 } // namespace ash 546 } // namespace ash
OLDNEW
« no previous file with comments | « ash/rotator/screen_rotation_animator.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698