| 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..3261fd391dc002386987b933c61253d91f747d25 100644
|
| --- a/ui/display/display_list_unittest.cc
|
| +++ b/ui/display/display_list_unittest.cc
|
| @@ -109,5 +109,50 @@ 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 and should now notify observers.
|
| + EXPECT_EQ("Added id=3", observer.GetAndClearChanges());
|
| +
|
| + // Two locks with an add followed by an update.
|
| + {
|
| + std::unique_ptr<DisplayListObserverLock> lock1 =
|
| + display_list.SuspendObserverUpdates();
|
| + {
|
| + std::unique_ptr<DisplayListObserverLock> lock2 =
|
| + display_list.SuspendObserverUpdates();
|
| + display_list.AddDisplay(display::Display(4, gfx::Rect(0, 0, 809, 802)),
|
| + DisplayList::Type::NOT_PRIMARY);
|
| + EXPECT_TRUE(observer.GetAndClearChanges().empty());
|
| + EXPECT_EQ(3u, display_list.displays().size());
|
| + }
|
| + // No updates should have been generated as there is still a valid lock.
|
| + EXPECT_TRUE(observer.GetAndClearChanges().empty());
|
| +
|
| + // Update the display. Lock still held, so no updates.
|
| + display::Display updated_display = display_list.displays()[2];
|
| + updated_display.set_bounds(gfx::Rect(0, 0, 803, 802));
|
| + display_list.UpdateDisplay(updated_display, DisplayList::Type::NOT_PRIMARY);
|
| + EXPECT_TRUE(observer.GetAndClearChanges().empty());
|
| + }
|
| + // All locks have been destroyed, so observer should be called.
|
| + EXPECT_EQ("Added id=4", observer.GetAndClearChanges());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace display
|
|
|