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

Unified Diff: ui/compositor/layer_unittest.cc

Issue 2815073002: Revert of Remove CompositorObserver::OnCompositingEnded() (Closed)
Patch Set: Fix CompositorObservers test 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
« no previous file with comments | « ui/compositor/compositor_unittest.cc ('k') | ui/compositor/test/draw_waiter_for_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_unittest.cc
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index 865504aa78565625c06fd126db73c69310bbc969..0783ff05ba7638b7d8d2c56af285a0dfeb53479b 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -188,7 +188,7 @@ class LayerWithRealCompositorTest : public testing::Test {
void DrawTree(Layer* root) {
GetCompositor()->SetRootLayer(root);
GetCompositor()->ScheduleDraw();
- WaitForDraw();
+ WaitForSwap();
}
void ReadPixels(SkBitmap* bitmap) {
@@ -222,6 +222,10 @@ class LayerWithRealCompositorTest : public testing::Test {
ui::DrawWaiterForTest::WaitForCompositingStarted(GetCompositor());
}
+ void WaitForSwap() {
+ ui::DrawWaiterForTest::WaitForCompositingEnded(GetCompositor());
+ }
+
void WaitForCommit() {
ui::DrawWaiterForTest::WaitForCommit(GetCompositor());
}
@@ -364,11 +368,12 @@ class TestCompositorObserver : public CompositorObserver {
TestCompositorObserver() = default;
bool committed() const { return committed_; }
- bool started() const { return started_; }
+ bool notified() const { return started_ && ended_; }
void Reset() {
committed_ = false;
started_ = false;
+ ended_ = false;
}
private:
@@ -381,12 +386,15 @@ class TestCompositorObserver : public CompositorObserver {
started_ = true;
}
+ void OnCompositingEnded(Compositor* compositor) override { ended_ = true; }
+
void OnCompositingLockStateChanged(Compositor* compositor) override {}
void OnCompositingShuttingDown(Compositor* compositor) override {}
bool committed_ = false;
bool started_ = false;
+ bool ended_ = false;
DISALLOW_COPY_AND_ASSIGN(TestCompositorObserver);
};
@@ -1309,7 +1317,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
// Explicitly called DrawTree should cause the observers to be notified.
// NOTE: this call to DrawTree sets l1 to be the compositor's root layer.
DrawTree(l1.get());
- EXPECT_TRUE(observer.started());
+ EXPECT_TRUE(observer.notified());
// ScheduleDraw without any visible change should cause a commit.
observer.Reset();
@@ -1320,26 +1328,26 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
// Moving, but not resizing, a layer should alert the observers.
observer.Reset();
l2->SetBounds(gfx::Rect(0, 0, 350, 350));
- WaitForDraw();
- EXPECT_TRUE(observer.started());
+ WaitForSwap();
+ EXPECT_TRUE(observer.notified());
// So should resizing a layer.
observer.Reset();
l2->SetBounds(gfx::Rect(0, 0, 400, 400));
- WaitForDraw();
- EXPECT_TRUE(observer.started());
+ WaitForSwap();
+ EXPECT_TRUE(observer.notified());
// Opacity changes should alert the observers.
observer.Reset();
l2->SetOpacity(0.5f);
- WaitForDraw();
- EXPECT_TRUE(observer.started());
+ WaitForSwap();
+ EXPECT_TRUE(observer.notified());
// So should setting the opacity back.
observer.Reset();
l2->SetOpacity(1.0f);
- WaitForDraw();
- EXPECT_TRUE(observer.started());
+ WaitForSwap();
+ EXPECT_TRUE(observer.notified());
// Setting the transform of a layer should alert the observers.
observer.Reset();
@@ -1348,17 +1356,17 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
transform.Rotate(90.0);
transform.Translate(-200.0, -200.0);
l2->SetTransform(transform);
- WaitForDraw();
- EXPECT_TRUE(observer.started());
+ WaitForSwap();
+ EXPECT_TRUE(observer.notified());
GetCompositor()->RemoveObserver(&observer);
// Opacity changes should no longer alert the removed observer.
observer.Reset();
l2->SetOpacity(0.5f);
- WaitForDraw();
+ WaitForSwap();
- EXPECT_FALSE(observer.started());
+ EXPECT_FALSE(observer.notified());
}
// Checks that modifying the hierarchy correctly affects final composite.
« no previous file with comments | « ui/compositor/compositor_unittest.cc ('k') | ui/compositor/test/draw_waiter_for_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698