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

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

Issue 2083923002: MacViews: Fix WidgetObserverTest.WidgetBoundsChangedNative after r400463 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More focused Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 // An extension to WidgetBoundsChanged to ensure notifications are forwarded 881 // An extension to WidgetBoundsChanged to ensure notifications are forwarded
882 // by the NativeWidget implementation. 882 // by the NativeWidget implementation.
883 TEST_F(WidgetObserverTest, WidgetBoundsChangedNative) { 883 TEST_F(WidgetObserverTest, WidgetBoundsChangedNative) {
884 // Don't use NewWidget(), so that the Init() flow can be observed to ensure 884 // Don't use NewWidget(), so that the Init() flow can be observed to ensure
885 // consistency across platforms. 885 // consistency across platforms.
886 Widget* widget = new Widget(); // Note: owned by NativeWidget. 886 Widget* widget = new Widget(); // Note: owned by NativeWidget.
887 widget->AddObserver(this); 887 widget->AddObserver(this);
888 888
889 EXPECT_FALSE(widget_bounds_changed()); 889 EXPECT_FALSE(widget_bounds_changed());
890 890
891 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
892
893 // Use an origin within the work area since platforms (e.g. Mac) may move a
894 // window into the work area when showing, triggering a bounds change.
895 params.bounds = gfx::Rect(50, 50, 100, 100);
896
891 // Init causes a bounds change, even while not showing. Note some platforms 897 // Init causes a bounds change, even while not showing. Note some platforms
892 // cause a bounds change even when the bounds are empty. Mac does not. 898 // cause a bounds change even when the bounds are empty. Mac does not.
893 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
894 params.bounds = gfx::Rect(0, 0, 100, 100);
895 widget->Init(params); 899 widget->Init(params);
896 EXPECT_TRUE(widget_bounds_changed()); 900 EXPECT_TRUE(widget_bounds_changed());
897 reset(); 901 reset();
898 902
899 // Resizing while hidden, triggers a change. 903 // Resizing while hidden, triggers a change.
900 widget->SetSize(gfx::Size(160, 100)); 904 widget->SetSize(gfx::Size(160, 100));
901 EXPECT_FALSE(widget->IsVisible()); 905 EXPECT_FALSE(widget->IsVisible());
902 EXPECT_TRUE(widget_bounds_changed()); 906 EXPECT_TRUE(widget_bounds_changed());
903 reset(); 907 reset();
904 908
(...skipping 11 matching lines...) Expand all
916 // Resizing while shown. 920 // Resizing while shown.
917 widget->SetSize(gfx::Size(170, 100)); 921 widget->SetSize(gfx::Size(170, 100));
918 EXPECT_TRUE(widget_bounds_changed()); 922 EXPECT_TRUE(widget_bounds_changed());
919 reset(); 923 reset();
920 924
921 // Resize to the same thing while shown does nothing. 925 // Resize to the same thing while shown does nothing.
922 widget->SetSize(gfx::Size(170, 100)); 926 widget->SetSize(gfx::Size(170, 100));
923 EXPECT_FALSE(widget_bounds_changed()); 927 EXPECT_FALSE(widget_bounds_changed());
924 reset(); 928 reset();
925 929
930 // Move, but don't change the size.
931 widget->SetBounds(gfx::Rect(110, 110, 170, 100));
932 // Currently fails on Mus. http://crbug.com/622575.
933 if (IsMus())
934 EXPECT_FALSE(widget_bounds_changed());
935 else
936 EXPECT_TRUE(widget_bounds_changed());
937 reset();
938
939 // Moving to the same place does nothing.
940 widget->SetBounds(gfx::Rect(110, 110, 170, 100));
941 EXPECT_FALSE(widget_bounds_changed());
942 reset();
943
926 // No bounds change when closing. 944 // No bounds change when closing.
927 widget->CloseNow(); 945 widget->CloseNow();
928 EXPECT_FALSE(widget_bounds_changed()); 946 EXPECT_FALSE(widget_bounds_changed());
929 } 947 }
930 948
931 // Test correct behavior when widgets close themselves in response to visibility 949 // Test correct behavior when widgets close themselves in response to visibility
932 // changes. 950 // changes.
933 TEST_F(WidgetObserverTest, ClosingOnHiddenParent) { 951 TEST_F(WidgetObserverTest, ClosingOnHiddenParent) {
934 WidgetAutoclosePtr parent(NewWidget()); 952 WidgetAutoclosePtr parent(NewWidget());
935 Widget* child = CreateChildPlatformWidget(parent->GetNativeView()); 953 Widget* child = CreateChildPlatformWidget(parent->GetNativeView());
(...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 EXPECT_FALSE(!!IsWindow(owned_hwnd)); 3718 EXPECT_FALSE(!!IsWindow(owned_hwnd));
3701 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd)); 3719 EXPECT_TRUE(!!IsWindowEnabled(top_hwnd));
3702 3720
3703 top_level_widget.CloseNow(); 3721 top_level_widget.CloseNow();
3704 } 3722 }
3705 3723
3706 #endif // defined(OS_WIN) 3724 #endif // defined(OS_WIN)
3707 3725
3708 } // namespace test 3726 } // namespace test
3709 } // namespace views 3727 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698