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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 2522093002: Notify WidgetRemovalsObserver when RootView is removed (Closed)
Patch Set: Add test Created 4 years 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 unified diff | Download patch
« no previous file with comments | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 3631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 EXPECT_TRUE(removals_observer.DidRemoveView(parent)); 3642 EXPECT_TRUE(removals_observer.DidRemoveView(parent));
3643 EXPECT_FALSE(removals_observer.DidRemoveView(child)); 3643 EXPECT_FALSE(removals_observer.DidRemoveView(child));
3644 3644
3645 // Calling RemoveChildView() doesn't delete the view, but deleting 3645 // Calling RemoveChildView() doesn't delete the view, but deleting
3646 // |parent| will automatically delete |child|. 3646 // |parent| will automatically delete |child|.
3647 delete parent; 3647 delete parent;
3648 3648
3649 widget->RemoveRemovalsObserver(&removals_observer); 3649 widget->RemoveRemovalsObserver(&removals_observer);
3650 } 3650 }
3651 3651
3652 // Test that WidgetRemovalsObserver::OnWillRemoveView is called when deleting
3653 // the root view.
3654 TEST_F(WidgetTest, WidgetRemovalsObserverCalledWhenRemovingRootView) {
3655 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
3656 TestWidgetRemovalsObserver removals_observer;
3657 widget->AddRemovalsObserver(&removals_observer);
3658 views::View* root_view = widget->GetRootView();
3659
3660 widget.reset();
3661 EXPECT_TRUE(removals_observer.DidRemoveView(root_view));
3662 }
3663
3652 // Test that WidgetRemovalsObserver::OnWillRemoveView is called when moving 3664 // Test that WidgetRemovalsObserver::OnWillRemoveView is called when moving
3653 // a view from one widget to another, but not when moving a view within 3665 // a view from one widget to another, but not when moving a view within
3654 // the same widget. 3666 // the same widget.
3655 TEST_F(WidgetTest, WidgetRemovalsObserverCalledWhenMovingBetweenWidgets) { 3667 TEST_F(WidgetTest, WidgetRemovalsObserverCalledWhenMovingBetweenWidgets) {
3656 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); 3668 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
3657 TestWidgetRemovalsObserver removals_observer; 3669 TestWidgetRemovalsObserver removals_observer;
3658 widget->AddRemovalsObserver(&removals_observer); 3670 widget->AddRemovalsObserver(&removals_observer);
3659 3671
3660 View* parent = new View(); 3672 View* parent = new View();
3661 widget->client_view()->AddChildView(parent); 3673 widget->client_view()->AddChildView(parent);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 Transparency_DesktopWidgetTranslucent 3908 Transparency_DesktopWidgetTranslucent
3897 #endif 3909 #endif
3898 TEST_F(CompositingWidgetTest, MAYBE_Transparency_DesktopWidgetTranslucent) { 3910 TEST_F(CompositingWidgetTest, MAYBE_Transparency_DesktopWidgetTranslucent) {
3899 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW); 3911 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW);
3900 } 3912 }
3901 3913
3902 #endif // !defined(OS_CHROMEOS) 3914 #endif // !defined(OS_CHROMEOS)
3903 3915
3904 } // namespace test 3916 } // namespace test
3905 } // namespace views 3917 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698