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

Unified Diff: ash/rotator/screen_rotation_animator_unittest.cc

Issue 2790583004: Add second copy request after screen rotation to flatten the layers in animation. (Closed)
Patch Set: Add a copy request after screen rotation to flatten the layers in animation. 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 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 ec03db5a54162820456ae57d7db196a89ca5d9ac..9c918620b0cbca31a4082fc6769807c0a8e88581 100644
--- a/ash/rotator/screen_rotation_animator_unittest.cc
+++ b/ash/rotator/screen_rotation_animator_unittest.cc
@@ -57,39 +57,67 @@ class AnimationObserver : public ScreenRotationAnimatorObserver {
class TestScreenRotationAnimator : public ScreenRotationAnimator {
public:
- TestScreenRotationAnimator(int64_t display_id, const base::Closure& callback);
+ TestScreenRotationAnimator(int64_t display_id,
+ const base::Closure& before_callback,
+ const base::Closure& after_callback);
~TestScreenRotationAnimator() override {}
private:
- CopyCallback CreateAfterCopyCallback(
+ CopyCallback CreateAfterCopyCallbackBeforeRotation(
+ std::unique_ptr<ScreenRotationRequest> rotation_request) override;
+ CopyCallback CreateAfterCopyCallbackAfterRotation(
std::unique_ptr<ScreenRotationRequest> rotation_request) override;
void IntersectBefore(CopyCallback next_callback,
std::unique_ptr<cc::CopyOutputResult> result);
+ void IntersectAfter(CopyCallback next_callback,
+ std::unique_ptr<cc::CopyOutputResult> result);
- base::Closure intersect_callback_;
+ base::Closure intersect_before_callback_;
+ base::Closure intersect_after_callback_;
DISALLOW_COPY_AND_ASSIGN(TestScreenRotationAnimator);
};
TestScreenRotationAnimator::TestScreenRotationAnimator(
int64_t display_id,
- const base::Closure& callback)
- : ScreenRotationAnimator(display_id), intersect_callback_(callback) {}
+ const base::Closure& before_callback,
+ const base::Closure& after_callback)
+ : ScreenRotationAnimator(display_id),
+ intersect_before_callback_(before_callback),
+ intersect_after_callback_(after_callback) {}
ScreenRotationAnimator::CopyCallback
-TestScreenRotationAnimator::CreateAfterCopyCallback(
+TestScreenRotationAnimator::CreateAfterCopyCallbackBeforeRotation(
std::unique_ptr<ScreenRotationRequest> rotation_request) {
- CopyCallback next_callback = ScreenRotationAnimator::CreateAfterCopyCallback(
- std::move(rotation_request));
+ CopyCallback next_callback =
+ ScreenRotationAnimator::CreateAfterCopyCallbackBeforeRotation(
+ std::move(rotation_request));
return base::Bind(&TestScreenRotationAnimator::IntersectBefore,
base::Unretained(this), next_callback);
}
+ScreenRotationAnimator::CopyCallback
+TestScreenRotationAnimator::CreateAfterCopyCallbackAfterRotation(
+ std::unique_ptr<ScreenRotationRequest> rotation_request) {
+ CopyCallback next_callback =
+ ScreenRotationAnimator::CreateAfterCopyCallbackAfterRotation(
+ std::move(rotation_request));
+ return base::Bind(&TestScreenRotationAnimator::IntersectAfter,
+ base::Unretained(this), next_callback);
+}
+
void TestScreenRotationAnimator::IntersectBefore(
CopyCallback next_callback,
std::unique_ptr<cc::CopyOutputResult> result) {
- intersect_callback_.Run();
+ intersect_before_callback_.Run();
+ next_callback.Run(std::move(result));
+}
+
+void TestScreenRotationAnimator::IntersectAfter(
+ CopyCallback next_callback,
+ std::unique_ptr<cc::CopyOutputResult> result) {
+ intersect_after_callback_.Run();
next_callback.Run(std::move(result));
}
@@ -104,6 +132,7 @@ class ScreenRotationAnimatorTest : public test::AshTestBase {
void SetUp() override;
void RemoveSecondaryDisplay(const std::string& specs);
+ void QuitWaitForCopyCallback();
protected:
int64_t display_id() const { return display_.id(); }
@@ -111,7 +140,9 @@ class ScreenRotationAnimatorTest : public test::AshTestBase {
TestScreenRotationAnimator* animator() { return animator_.get(); }
void SetScreenRotationAnimator(int64_t display_id,
- const base::Closure& callback);
+ const base::Closure& before_callback,
+
+ const base::Closure& after_callback);
test::ScreenRotationAnimatorTestApi* test_api() { return test_api_.get(); }
@@ -134,6 +165,10 @@ class ScreenRotationAnimatorTest : public test::AshTestBase {
void ScreenRotationAnimatorTest::RemoveSecondaryDisplay(
const std::string& specs) {
UpdateDisplay(specs);
+ QuitWaitForCopyCallback();
+}
+
+void ScreenRotationAnimatorTest::QuitWaitForCopyCallback() {
run_loop_->QuitWhenIdle();
}
@@ -142,7 +177,8 @@ void ScreenRotationAnimatorTest::SetUp() {
display_ = display::Screen::GetScreen()->GetPrimaryDisplay();
run_loop_ = base::MakeUnique<base::RunLoop>();
- SetScreenRotationAnimator(display_.id(), run_loop_->QuitWhenIdleClosure());
+ SetScreenRotationAnimator(display_.id(), run_loop_->QuitWhenIdleClosure(),
+ run_loop_->QuitWhenIdleClosure());
non_zero_duration_mode_ =
base::MakeUnique<ui::ScopedAnimationDurationScaleMode>(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
@@ -150,15 +186,17 @@ void ScreenRotationAnimatorTest::SetUp() {
void ScreenRotationAnimatorTest::SetScreenRotationAnimator(
int64_t display_id,
- const base::Closure& callback) {
- animator_ =
- base::MakeUnique<TestScreenRotationAnimator>(display_id, callback);
+ const base::Closure& before_callback,
+ const base::Closure& after_callback) {
+ animator_ = base::MakeUnique<TestScreenRotationAnimator>(
+ display_id, before_callback, after_callback);
test_api_ =
base::MakeUnique<test::ScreenRotationAnimatorTestApi>(animator_.get());
test_api()->DisableAnimationTimers();
}
void ScreenRotationAnimatorTest::WaitForCopyCallback() {
+ run_loop_.reset(new base::RunLoop());
run_loop_->Run();
}
@@ -303,6 +341,10 @@ TEST_F(ScreenRotationAnimatorTest, RotatesToDifferentRotationWithCopyCallback) {
return;
}
+ SetScreenRotationAnimator(
+ display_manager()->GetDisplayAt(0).id(), run_loop_->QuitWhenIdleClosure(),
+ base::Bind(&ScreenRotationAnimatorTest::QuitWaitForCopyCallback,
+ base::Unretained(this)));
SetDisplayRotation(display_id(), display::Display::ROTATE_0);
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kAshEnableSmoothScreenRotation);
@@ -332,7 +374,8 @@ TEST_F(ScreenRotationAnimatorTest, RemoveSecondaryDisplayAfterCopyCallback) {
SetScreenRotationAnimator(
display_manager()->GetDisplayAt(1).id(),
base::Bind(&ScreenRotationAnimatorTest::RemoveSecondaryDisplay,
- base::Unretained(this), "640x480"));
+ base::Unretained(this), "640x480"),
+ run_loop_->QuitWhenIdleClosure());
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kAshEnableSmoothScreenRotation);
SetDisplayRotation(display_manager()->GetDisplayAt(1).id(),

Powered by Google App Engine
This is Rietveld 408576698