| OLD | NEW |
| 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 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 EXPECT_EQ(0, v1->GetEventCount(ui::ET_GESTURE_END)); | 2659 EXPECT_EQ(0, v1->GetEventCount(ui::ET_GESTURE_END)); |
| 2660 EXPECT_EQ(0, v2->GetEventCount(ui::ET_GESTURE_END)); | 2660 EXPECT_EQ(0, v2->GetEventCount(ui::ET_GESTURE_END)); |
| 2661 EXPECT_EQ(0, v3->GetEventCount(ui::ET_GESTURE_END)); | 2661 EXPECT_EQ(0, v3->GetEventCount(ui::ET_GESTURE_END)); |
| 2662 EXPECT_EQ(0, v4->GetEventCount(ui::ET_GESTURE_END)); | 2662 EXPECT_EQ(0, v4->GetEventCount(ui::ET_GESTURE_END)); |
| 2663 EXPECT_EQ(NULL, GetGestureHandler(root_view)); | 2663 EXPECT_EQ(NULL, GetGestureHandler(root_view)); |
| 2664 EXPECT_TRUE(end.handled()); | 2664 EXPECT_TRUE(end.handled()); |
| 2665 | 2665 |
| 2666 widget->Close(); | 2666 widget->Close(); |
| 2667 } | 2667 } |
| 2668 | 2668 |
| 2669 // Test the result of Widget::GetAllChildWidgets(). | 2669 // Test the result of Widget::GetAllChildAndOwnedWidgets(). |
| 2670 TEST_F(WidgetTest, GetAllChildWidgets) { | 2670 TEST_F(WidgetTest, GetAllChildAndOwnedWidgets) { |
| 2671 // Create the following widget hierarchy: | 2671 // Create the following widget hierarchy: |
| 2672 // | 2672 // |
| 2673 // toplevel | 2673 // toplevel |
| 2674 // +-- w1 | 2674 // +-- w1 |
| 2675 // +-- w11 | 2675 // +-- w11 |
| 2676 // +-- w2 | 2676 // +-- w2 |
| 2677 // +-- w21 | 2677 // +-- w21 |
| 2678 // +-- w22 | 2678 // +-- w22 |
| 2679 Widget* toplevel = CreateTopLevelPlatformWidget(); | 2679 Widget* toplevel = CreateTopLevelPlatformWidget(); |
| 2680 Widget* w1 = CreateChildPlatformWidget(toplevel->GetNativeView()); | 2680 Widget* w1 = CreateChildPlatformWidget(toplevel->GetNativeView()); |
| 2681 Widget* w11 = CreateChildPlatformWidget(w1->GetNativeView()); | 2681 Widget* w11 = CreateChildPlatformWidget(w1->GetNativeView()); |
| 2682 Widget* w2 = CreateChildPlatformWidget(toplevel->GetNativeView()); | 2682 Widget* w2 = CreateChildPlatformWidget(toplevel->GetNativeView()); |
| 2683 Widget* w21 = CreateChildPlatformWidget(w2->GetNativeView()); | 2683 Widget* w21 = CreateChildPlatformWidget(w2->GetNativeView()); |
| 2684 Widget* w22 = CreateChildPlatformWidget(w2->GetNativeView()); | 2684 Widget* w22 = CreateChildPlatformWidget(w2->GetNativeView()); |
| 2685 | 2685 |
| 2686 std::set<Widget*> expected; | 2686 std::set<Widget*> expected; |
| 2687 expected.insert(toplevel); | 2687 expected.insert(toplevel); |
| 2688 expected.insert(w1); | 2688 expected.insert(w1); |
| 2689 expected.insert(w11); | 2689 expected.insert(w11); |
| 2690 expected.insert(w2); | 2690 expected.insert(w2); |
| 2691 expected.insert(w21); | 2691 expected.insert(w21); |
| 2692 expected.insert(w22); | 2692 expected.insert(w22); |
| 2693 | 2693 |
| 2694 std::set<Widget*> widgets; | 2694 std::set<Widget*> widgets; |
| 2695 Widget::GetAllChildWidgets(toplevel->GetNativeView(), &widgets); | 2695 Widget::GetAllChildAndOwnedWidgets(toplevel->GetNativeView(), &widgets); |
| 2696 | 2696 |
| 2697 EXPECT_EQ(expected.size(), widgets.size()); | 2697 EXPECT_EQ(expected.size(), widgets.size()); |
| 2698 EXPECT_TRUE(std::equal(expected.begin(), expected.end(), widgets.begin())); | 2698 EXPECT_TRUE(std::equal(expected.begin(), expected.end(), widgets.begin())); |
| 2699 } | 2699 } |
| 2700 | 2700 |
| 2701 // Used by DestroyChildWidgetsInOrder. On destruction adds the supplied name to | 2701 // Used by DestroyChildWidgetsInOrder. On destruction adds the supplied name to |
| 2702 // a vector. | 2702 // a vector. |
| 2703 class DestroyedTrackingView : public View { | 2703 class DestroyedTrackingView : public View { |
| 2704 public: | 2704 public: |
| 2705 DestroyedTrackingView(const std::string& name, | 2705 DestroyedTrackingView(const std::string& name, |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3370 | 3370 |
| 3371 EXPECT_EQ(test_rect, root_view->bounds()); | 3371 EXPECT_EQ(test_rect, root_view->bounds()); |
| 3372 widget->ReorderNativeViews(); | 3372 widget->ReorderNativeViews(); |
| 3373 EXPECT_EQ(test_rect, root_view->bounds()); | 3373 EXPECT_EQ(test_rect, root_view->bounds()); |
| 3374 | 3374 |
| 3375 widget->CloseNow(); | 3375 widget->CloseNow(); |
| 3376 } | 3376 } |
| 3377 | 3377 |
| 3378 } // namespace test | 3378 } // namespace test |
| 3379 } // namespace views | 3379 } // namespace views |
| OLD | NEW |