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

Unified Diff: ui/display/display_list_unittest.cc

Issue 2378923002: Adds ability to suspend notifying observers when display list is changed (Closed)
Patch Set: feedback Created 4 years, 3 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/display/display_list.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/display_list_unittest.cc
diff --git a/ui/display/display_list_unittest.cc b/ui/display/display_list_unittest.cc
index 9873450bc0ad6fd06728f18047422ec3235e613d..49543db1210afd30e63a7bec3416fef3117acdd2 100644
--- a/ui/display/display_list_unittest.cc
+++ b/ui/display/display_list_unittest.cc
@@ -109,5 +109,31 @@ TEST(DisplayListTest, AddUpdateRemove) {
EXPECT_EQ(3, display_list.GetPrimaryDisplayIterator()->id());
}
+TEST(DisplayListTest, SuspendUpdates) {
+ DisplayList display_list;
+ display_list.AddDisplay(display::Display(2, gfx::Rect(0, 0, 801, 802)),
+ DisplayList::Type::PRIMARY);
+ DisplayObserverImpl observer;
+ display_list.AddObserver(&observer);
+ {
+ // Suspend updates and add a new display.
+ std::unique_ptr<DisplayListObserverLock> lock =
+ display_list.SuspendObserverUpdates();
+ display_list.AddDisplay(display::Display(3, gfx::Rect(0, 0, 809, 802)),
+ DisplayList::Type::NOT_PRIMARY);
+ EXPECT_EQ(2u, display_list.displays().size());
+ // No update should have been generated.
+ EXPECT_TRUE(observer.GetAndClearChanges().empty());
+ }
+ // The lock has been destroyed, but no updates should be sent yet.
+ EXPECT_TRUE(observer.GetAndClearChanges().empty());
+
+ // Update a display and verify observer called.
+ display::Display updated_display = display_list.displays()[0];
+ updated_display.set_bounds(gfx::Rect(0, 0, 803, 802));
+ display_list.UpdateDisplay(updated_display, DisplayList::Type::PRIMARY);
+ EXPECT_EQ("Changed id=2 bounds", observer.GetAndClearChanges());
+}
+
} // namespace
} // namespace display
« no previous file with comments | « ui/display/display_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698