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

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

Issue 353643002: MacViews: Implement Set/Get*Bounds for NativeWidgetMac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refine 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
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 widget->CloseNow();
882
883 // Same tests with a frameless window.
884 widget = CreateTopLevelFramelessPlatformWidget();
885 widget->Show();
886
887 EXPECT_NE(kTestSize.ToString(),
888 widget->GetWindowBoundsInScreen().size().ToString());
889 widget->SetSize(kTestSize);
890 EXPECT_EQ(kTestSize.ToString(),
891 widget->GetWindowBoundsInScreen().size().ToString());
892
893 EXPECT_NE(kTestBounds.ToString(),
894 widget->GetWindowBoundsInScreen().ToString());
895 widget->SetBounds(kTestBounds);
896 EXPECT_EQ(kTestBounds.ToString(),
897 widget->GetWindowBoundsInScreen().ToString());
898
899 // For a frameless widget, the client bounds should also match.
900 EXPECT_EQ(kTestBounds.ToString(),
901 widget->GetClientAreaBoundsInScreen().ToString());
902
903 widget->CloseNow();
904 }
905
858 #if defined(false) 906 #if defined(false)
859 // Aura needs shell to maximize/fullscreen window. 907 // Aura needs shell to maximize/fullscreen window.
860 // NativeWidgetGtk doesn't implement GetRestoredBounds. 908 // NativeWidgetGtk doesn't implement GetRestoredBounds.
861 TEST_F(WidgetTest, GetRestoredBounds) { 909 TEST_F(WidgetTest, GetRestoredBounds) {
862 Widget* toplevel = CreateTopLevelPlatformWidget(); 910 Widget* toplevel = CreateTopLevelPlatformWidget();
863 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(), 911 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(),
864 toplevel->GetRestoredBounds().ToString()); 912 toplevel->GetRestoredBounds().ToString());
865 toplevel->Show(); 913 toplevel->Show();
866 toplevel->Maximize(); 914 toplevel->Maximize();
867 RunPendingMessages(); 915 RunPendingMessages();
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_PRESSED)); 2468 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_PRESSED));
2421 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_RELEASED)); 2469 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_RELEASED));
2422 EXPECT_EQ(1, view->GetEventCount(ui::ET_MOUSE_DRAGGED)); 2470 EXPECT_EQ(1, view->GetEventCount(ui::ET_MOUSE_DRAGGED));
2423 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, view->last_flags()); 2471 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, view->last_flags());
2424 2472
2425 widget->CloseNow(); 2473 widget->CloseNow();
2426 } 2474 }
2427 2475
2428 } // namespace test 2476 } // namespace test
2429 } // namespace views 2477 } // namespace views
OLDNEW
« ui/views/widget/native_widget_mac.mm ('K') | « 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