OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "ui/base/clipboard/clipboard.h" | 10 #include "ui/base/clipboard/clipboard.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 TEST_F(ViewTest, MouseEvent) { | 289 TEST_F(ViewTest, MouseEvent) { |
290 TestView* v1 = new TestView(); | 290 TestView* v1 = new TestView(); |
291 v1->SetBounds(0, 0, 300, 300); | 291 v1->SetBounds(0, 0, 300, 300); |
292 | 292 |
293 TestView* v2 = new TestView(); | 293 TestView* v2 = new TestView(); |
294 v2->SetBounds(100, 100, 100, 100); | 294 v2->SetBounds(100, 100, 100, 100); |
295 | 295 |
296 scoped_ptr<Widget> widget(new Widget); | 296 scoped_ptr<Widget> widget(new Widget); |
297 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 297 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
298 params.delete_on_destroy = false; | 298 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
299 params.bounds = gfx::Rect(50, 50, 650, 650); | 299 params.bounds = gfx::Rect(50, 50, 650, 650); |
300 widget->Init(params); | 300 widget->Init(params); |
301 View* root = widget->GetRootView(); | 301 View* root = widget->GetRootView(); |
302 | 302 |
303 root->AddChildView(v1); | 303 root->AddChildView(v1); |
304 v1->AddChildView(v2); | 304 v1->AddChildView(v2); |
305 | 305 |
306 v1->Reset(); | 306 v1->Reset(); |
307 v2->Reset(); | 307 v2->Reset(); |
308 | 308 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 v1->SetBounds(0, 0, 300, 300); | 397 v1->SetBounds(0, 0, 300, 300); |
398 | 398 |
399 TestView* v2 = new TestView(); | 399 TestView* v2 = new TestView(); |
400 v2->SetBounds(100, 100, 100, 100); | 400 v2->SetBounds(100, 100, 100, 100); |
401 | 401 |
402 TestView* v3 = new TestViewIgnoreTouch(); | 402 TestView* v3 = new TestViewIgnoreTouch(); |
403 v3->SetBounds(0, 0, 100, 100); | 403 v3->SetBounds(0, 0, 100, 100); |
404 | 404 |
405 scoped_ptr<Widget> widget(new Widget()); | 405 scoped_ptr<Widget> widget(new Widget()); |
406 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 406 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
407 params.delete_on_destroy = false; | 407 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
408 params.bounds = gfx::Rect(50, 50, 650, 650); | 408 params.bounds = gfx::Rect(50, 50, 650, 650); |
409 widget->Init(params); | 409 widget->Init(params); |
410 View* root = widget->GetRootView(); | 410 View* root = widget->GetRootView(); |
411 | 411 |
412 root->AddChildView(v1); | 412 root->AddChildView(v1); |
413 static_cast<internal::RootView*>(root)->SetGestureManager(gm); | 413 static_cast<internal::RootView*>(root)->SetGestureManager(gm); |
414 v1->AddChildView(v2); | 414 v1->AddChildView(v2); |
415 v2->AddChildView(v3); | 415 v2->AddChildView(v3); |
416 | 416 |
417 // |v3| completely obscures |v2|, but all the touch events on |v3| should | 417 // |v3| completely obscures |v2|, but all the touch events on |v3| should |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 // Register a keyboard accelerator before the view is added to a window. | 928 // Register a keyboard accelerator before the view is added to a window. |
929 Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); | 929 Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); |
930 TestView* view = new TestView(); | 930 TestView* view = new TestView(); |
931 view->Reset(); | 931 view->Reset(); |
932 view->AddAccelerator(return_accelerator); | 932 view->AddAccelerator(return_accelerator); |
933 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0); | 933 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0); |
934 | 934 |
935 // Create a window and add the view as its child. | 935 // Create a window and add the view as its child. |
936 scoped_ptr<Widget> widget(new Widget); | 936 scoped_ptr<Widget> widget(new Widget); |
937 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 937 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
938 params.delete_on_destroy = false; | 938 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
939 params.bounds = gfx::Rect(0, 0, 100, 100); | 939 params.bounds = gfx::Rect(0, 0, 100, 100); |
940 widget->Init(params); | 940 widget->Init(params); |
941 View* root = widget->GetRootView(); | 941 View* root = widget->GetRootView(); |
942 root->AddChildView(view); | 942 root->AddChildView(view); |
943 | 943 |
944 // Get the focus manager. | 944 // Get the focus manager. |
945 FocusManager* focus_manager = FocusManager::GetFocusManagerForNativeView( | 945 FocusManager* focus_manager = FocusManager::GetFocusManagerForNativeView( |
946 widget->GetNativeView()); | 946 widget->GetNativeView()); |
947 ASSERT_TRUE(focus_manager); | 947 ASSERT_TRUE(focus_manager); |
948 | 948 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 #if defined(OS_WIN) | 993 #if defined(OS_WIN) |
994 TEST_F(ViewTest, HiddenViewWithAccelerator) { | 994 TEST_F(ViewTest, HiddenViewWithAccelerator) { |
995 Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); | 995 Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); |
996 TestView* view = new TestView(); | 996 TestView* view = new TestView(); |
997 view->Reset(); | 997 view->Reset(); |
998 view->AddAccelerator(return_accelerator); | 998 view->AddAccelerator(return_accelerator); |
999 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0); | 999 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0); |
1000 | 1000 |
1001 scoped_ptr<Widget> widget(new Widget); | 1001 scoped_ptr<Widget> widget(new Widget); |
1002 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 1002 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
1003 params.delete_on_destroy = false; | 1003 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
1004 params.bounds = gfx::Rect(0, 0, 100, 100); | 1004 params.bounds = gfx::Rect(0, 0, 100, 100); |
1005 widget->Init(params); | 1005 widget->Init(params); |
1006 View* root = widget->GetRootView(); | 1006 View* root = widget->GetRootView(); |
1007 root->AddChildView(view); | 1007 root->AddChildView(view); |
1008 | 1008 |
1009 FocusManager* focus_manager = FocusManager::GetFocusManagerForNativeView( | 1009 FocusManager* focus_manager = FocusManager::GetFocusManagerForNativeView( |
1010 widget->GetNativeView()); | 1010 widget->GetNativeView()); |
1011 ASSERT_TRUE(focus_manager); | 1011 ASSERT_TRUE(focus_manager); |
1012 | 1012 |
1013 view->SetVisible(false); | 1013 view->SetVisible(false); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView); | 1815 DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView); |
1816 }; | 1816 }; |
1817 | 1817 |
1818 #if defined(OS_WIN) | 1818 #if defined(OS_WIN) |
1819 // TODO(beng): This can be cross platform when widget construction/init is. | 1819 // TODO(beng): This can be cross platform when widget construction/init is. |
1820 TEST_F(ViewTest, OnVisibleBoundsChanged) { | 1820 TEST_F(ViewTest, OnVisibleBoundsChanged) { |
1821 gfx::Rect viewport_bounds(0, 0, 100, 100); | 1821 gfx::Rect viewport_bounds(0, 0, 100, 100); |
1822 | 1822 |
1823 scoped_ptr<Widget> widget(new Widget); | 1823 scoped_ptr<Widget> widget(new Widget); |
1824 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 1824 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
1825 params.delete_on_destroy = false; | 1825 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
1826 params.bounds = viewport_bounds; | 1826 params.bounds = viewport_bounds; |
1827 widget->Init(params); | 1827 widget->Init(params); |
1828 widget->GetRootView()->SetBoundsRect(viewport_bounds); | 1828 widget->GetRootView()->SetBoundsRect(viewport_bounds); |
1829 | 1829 |
1830 View* viewport = new View; | 1830 View* viewport = new View; |
1831 widget->SetContentsView(viewport); | 1831 widget->SetContentsView(viewport); |
1832 View* contents = new View; | 1832 View* contents = new View; |
1833 viewport->AddChildView(contents); | 1833 viewport->AddChildView(contents); |
1834 viewport->SetBoundsRect(viewport_bounds); | 1834 viewport->SetBoundsRect(viewport_bounds); |
1835 contents->SetBounds(0, 0, 100, 200); | 1835 contents->SetBounds(0, 0, 100, 200); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 EXPECT_TRUE(v2->Contains(v2)); | 2006 EXPECT_TRUE(v2->Contains(v2)); |
2007 EXPECT_FALSE(v2->Contains(&v1)); | 2007 EXPECT_FALSE(v2->Contains(&v1)); |
2008 EXPECT_TRUE(v2->Contains(v3)); | 2008 EXPECT_TRUE(v2->Contains(v3)); |
2009 EXPECT_FALSE(v3->Contains(NULL)); | 2009 EXPECT_FALSE(v3->Contains(NULL)); |
2010 EXPECT_TRUE(v3->Contains(v3)); | 2010 EXPECT_TRUE(v3->Contains(v3)); |
2011 EXPECT_FALSE(v3->Contains(&v1)); | 2011 EXPECT_FALSE(v3->Contains(&v1)); |
2012 EXPECT_FALSE(v3->Contains(v2)); | 2012 EXPECT_FALSE(v3->Contains(v2)); |
2013 } | 2013 } |
2014 | 2014 |
2015 } // namespace views | 2015 } // namespace views |
OLD | NEW |