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

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

Issue 351603004: Revert of MacViews: Implement Set/Get*Bounds for NativeWidgetMac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/native_widget_mac.mm ('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 <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 child2->OnNativeWidgetMove(); 848 child2->OnNativeWidgetMove();
849 EXPECT_EQ(child2, widget_bounds_changed()); 849 EXPECT_EQ(child2, widget_bounds_changed());
850 850
851 child1->OnNativeWidgetSizeChanged(gfx::Size()); 851 child1->OnNativeWidgetSizeChanged(gfx::Size());
852 EXPECT_EQ(child1, widget_bounds_changed()); 852 EXPECT_EQ(child1, widget_bounds_changed());
853 853
854 child2->OnNativeWidgetSizeChanged(gfx::Size()); 854 child2->OnNativeWidgetSizeChanged(gfx::Size());
855 EXPECT_EQ(child2, widget_bounds_changed()); 855 EXPECT_EQ(child2, widget_bounds_changed());
856 } 856 }
857 857
858 // Tests that SetBounds() and GetWindowBoundsInScreen() is symmetric when the
859 // widget is visible and not maximized or fullscreen.
860 TEST_F(WidgetTest, GetWindowBoundsInScreen) {
861 // Choose test coordinates away from edges and dimensions that are "small"
862 // (but not too small) to ensure the OS doesn't try to adjust them.
863 const gfx::Rect kTestBounds(150, 150, 400, 300);
864 const gfx::Size kTestSize(200, 180);
865
866 // First test a toplevel widget.
867 Widget* widget = CreateTopLevelPlatformWidget();
868 widget->Show();
869
870 EXPECT_NE(kTestSize.ToString(),
871 widget->GetWindowBoundsInScreen().size().ToString());
872 widget->SetSize(kTestSize);
873 EXPECT_EQ(kTestSize.ToString(),
874 widget->GetWindowBoundsInScreen().size().ToString());
875
876 EXPECT_NE(kTestBounds.ToString(),
877 widget->GetWindowBoundsInScreen().ToString());
878 widget->SetBounds(kTestBounds);
879 EXPECT_EQ(kTestBounds.ToString(),
880 widget->GetWindowBoundsInScreen().ToString());
881
882 // Changing just the size should not change the origin.
883 widget->SetSize(kTestSize);
884 EXPECT_EQ(kTestBounds.origin().ToString(),
885 widget->GetWindowBoundsInScreen().origin().ToString());
886
887 widget->CloseNow();
888
889 // Same tests with a frameless window.
890 widget = CreateTopLevelFramelessPlatformWidget();
891 widget->Show();
892
893 EXPECT_NE(kTestSize.ToString(),
894 widget->GetWindowBoundsInScreen().size().ToString());
895 widget->SetSize(kTestSize);
896 EXPECT_EQ(kTestSize.ToString(),
897 widget->GetWindowBoundsInScreen().size().ToString());
898
899 EXPECT_NE(kTestBounds.ToString(),
900 widget->GetWindowBoundsInScreen().ToString());
901 widget->SetBounds(kTestBounds);
902 EXPECT_EQ(kTestBounds.ToString(),
903 widget->GetWindowBoundsInScreen().ToString());
904
905 // For a frameless widget, the client bounds should also match.
906 EXPECT_EQ(kTestBounds.ToString(),
907 widget->GetClientAreaBoundsInScreen().ToString());
908
909 // Verify origin is stable for a frameless window as well.
910 widget->SetSize(kTestSize);
911 EXPECT_EQ(kTestBounds.origin().ToString(),
912 widget->GetWindowBoundsInScreen().origin().ToString());
913
914 widget->CloseNow();
915 }
916
917 #if defined(false) 858 #if defined(false)
918 // Aura needs shell to maximize/fullscreen window. 859 // Aura needs shell to maximize/fullscreen window.
919 // NativeWidgetGtk doesn't implement GetRestoredBounds. 860 // NativeWidgetGtk doesn't implement GetRestoredBounds.
920 TEST_F(WidgetTest, GetRestoredBounds) { 861 TEST_F(WidgetTest, GetRestoredBounds) {
921 Widget* toplevel = CreateTopLevelPlatformWidget(); 862 Widget* toplevel = CreateTopLevelPlatformWidget();
922 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(), 863 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(),
923 toplevel->GetRestoredBounds().ToString()); 864 toplevel->GetRestoredBounds().ToString());
924 toplevel->Show(); 865 toplevel->Show();
925 toplevel->Maximize(); 866 toplevel->Maximize();
926 RunPendingMessages(); 867 RunPendingMessages();
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_PRESSED)); 2420 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_PRESSED));
2480 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_RELEASED)); 2421 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_RELEASED));
2481 EXPECT_EQ(1, view->GetEventCount(ui::ET_MOUSE_DRAGGED)); 2422 EXPECT_EQ(1, view->GetEventCount(ui::ET_MOUSE_DRAGGED));
2482 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, view->last_flags()); 2423 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, view->last_flags());
2483 2424
2484 widget->CloseNow(); 2425 widget->CloseNow();
2485 } 2426 }
2486 2427
2487 } // namespace test 2428 } // namespace test
2488 } // namespace views 2429 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698