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

Unified Diff: ash/rotator/screen_rotation_animator_unittest.cc

Issue 2910413002: cros: Do not cache |root_window| in ScreenRotationAnimator. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/rotator/screen_rotation_animator_unittest.cc
diff --git a/ash/rotator/screen_rotation_animator_unittest.cc b/ash/rotator/screen_rotation_animator_unittest.cc
index fa65898242594e67f52b59f6cf3f61ae3dfd0dc4..df3bf411a0c41bcc2fdcac98edc2ccf9a82435b4 100644
--- a/ash/rotator/screen_rotation_animator_unittest.cc
+++ b/ash/rotator/screen_rotation_animator_unittest.cc
@@ -42,6 +42,11 @@ void SetDisplayRotation(int64_t display_id,
display::Display::RotationSource::ROTATION_SOURCE_USER);
}
+aura::Window* GetRootWindow(int64_t display_id) {
+ return Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId(
+ display_id);
+}
+
class AnimationObserver : public ScreenRotationAnimatorObserver {
public:
AnimationObserver() {}
@@ -66,6 +71,10 @@ class TestScreenRotationAnimator : public ScreenRotationAnimator {
const base::Closure& after_callback);
~TestScreenRotationAnimator() override {}
+ void set_intersect_after_callback(const base::Closure& after_callback) {
+ intersect_after_callback_ = after_callback;
+ }
+
private:
CopyCallback CreateAfterCopyCallbackBeforeRotation(
std::unique_ptr<ScreenRotationRequest> rotation_request) override;
@@ -543,4 +552,50 @@ TEST_F(ScreenRotationAnimatorSmoothAnimationTest,
EXPECT_EQ(secondary_display_id, display_manager()->GetDisplayAt(0).id());
}
+// If the external primary display is removed during a rotation animation. It
+// should work for the next rotation request even the |root_window| changed.
+TEST_F(ScreenRotationAnimatorSmoothAnimationTest,
+ RemoveExternalPrimaryDisplayDuringAnimationChangedRootWindow) {
+ // TODO(wutao): needs GetDisplayInfo http://crbug.com/622480.
+ if (Shell::GetAshConfig() == Config::MASH) {
+ ASSERT_TRUE(ShellPort::Get()->GetDisplayInfo(display_id()).id() !=
+ display_id());
+ return;
+ }
+
+ UpdateDisplay("640x480,800x600");
+ EXPECT_EQ(2U, display_manager()->GetNumDisplays());
+
+ Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(
+ display_manager()->GetDisplayAt(1).id());
+ const unsigned int secondary_display_id =
+ display_manager()->GetDisplayAt(0).id();
+ aura::Window* old_root_window = GetRootWindow(secondary_display_id);
+
+ SetScreenRotationAnimator(
+ display_manager()->GetDisplayAt(0).id(), run_loop_->QuitWhenIdleClosure(),
+ base::Bind(
+ &ScreenRotationAnimatorSmoothAnimationTest::RemoveSecondaryDisplay,
+ base::Unretained(this), "640x480"));
+ SetDisplayRotation(display_manager()->GetDisplayAt(0).id(),
+ display::Display::ROTATE_0);
+ animator()->Rotate(display::Display::ROTATE_90,
+ display::Display::RotationSource::ROTATION_SOURCE_USER);
+ WaitForCopyCallback();
+ EXPECT_EQ(1U, display_manager()->GetNumDisplays());
+ EXPECT_EQ(secondary_display_id, display_manager()->GetDisplayAt(0).id());
+
+ // Rotate again, should finish.
+ animator()->set_intersect_after_callback(base::Bind(
+ &ScreenRotationAnimatorSmoothAnimationTest::QuitWaitForCopyCallback,
+ base::Unretained(this)));
+ animator()->Rotate(display::Display::ROTATE_270,
+ display::Display::RotationSource::ROTATION_SOURCE_USER);
+ WaitForCopyCallback();
+ EXPECT_EQ(display::Display::ROTATE_270,
+ GetDisplayRotation(secondary_display_id));
+ aura::Window* new_root_window = GetRootWindow(secondary_display_id);
+ EXPECT_NE(old_root_window, new_root_window);
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698