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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2635 // Check that calling |AddChildView()| does not change the order. | 2635 // Check that calling |AddChildView()| does not change the order. |
2636 v1.AddChildView(&v2); | 2636 v1.AddChildView(&v2); |
2637 EXPECT_EQ(0, v1.GetIndexOf(&v2)); | 2637 EXPECT_EQ(0, v1.GetIndexOf(&v2)); |
2638 EXPECT_EQ(1, v1.GetIndexOf(&v3)); | 2638 EXPECT_EQ(1, v1.GetIndexOf(&v3)); |
2639 v1.AddChildView(&v3); | 2639 v1.AddChildView(&v3); |
2640 EXPECT_EQ(0, v1.GetIndexOf(&v2)); | 2640 EXPECT_EQ(0, v1.GetIndexOf(&v2)); |
2641 EXPECT_EQ(1, v1.GetIndexOf(&v3)); | 2641 EXPECT_EQ(1, v1.GetIndexOf(&v3)); |
2642 } | 2642 } |
2643 | 2643 |
2644 //////////////////////////////////////////////////////////////////////////////// | 2644 //////////////////////////////////////////////////////////////////////////////// |
2645 // FocusManager | |
2646 //////////////////////////////////////////////////////////////////////////////// | |
2647 | |
2648 TEST_F(ViewTest, ReviseFocusedViewForUnfocusableView) { | |
2649 // Create a widget with two views and give the first one focus. | |
2650 Widget widget; | |
2651 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | |
2652 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
2653 widget.Init(params); | |
2654 widget.Activate(); | |
sky
2014/08/07 21:40:34
I suspect doing this is going to require the test
mohsen
2014/08/08 01:32:07
This test is not meant to test activation. It is o
sky
2014/08/08 14:52:30
You're new code triggers calling off to NativeWidg
mohsen
2014/08/08 17:45:07
I guess by NativeWidgetDelegate you mean NativeWid
| |
2655 | |
2656 View* view1 = new View(); | |
2657 view1->SetFocusable(true); | |
2658 widget.GetRootView()->AddChildView(view1); | |
2659 View* view2 = new View(); | |
2660 view2->SetFocusable(true); | |
2661 widget.GetRootView()->AddChildView(view2); | |
2662 | |
2663 FocusManager* focus_manager = widget.GetFocusManager(); | |
2664 ASSERT_TRUE(focus_manager); | |
2665 | |
2666 focus_manager->SetFocusedView(view1); | |
2667 EXPECT_EQ(view1, focus_manager->GetFocusedView()); | |
2668 | |
2669 // Disable the focused view and check if the next view gets focused. | |
2670 view1->SetEnabled(false); | |
2671 EXPECT_EQ(view2, focus_manager->GetFocusedView()); | |
2672 | |
2673 // Re-enable and re-focus. | |
2674 view1->SetEnabled(true); | |
2675 focus_manager->SetFocusedView(view1); | |
2676 EXPECT_EQ(view1, focus_manager->GetFocusedView()); | |
2677 | |
2678 // Hide the focused view and check it the next view gets focused. | |
2679 view1->SetVisible(false); | |
2680 EXPECT_EQ(view2, focus_manager->GetFocusedView()); | |
2681 | |
2682 // Re-show and re-focus. | |
2683 view1->SetVisible(true); | |
2684 focus_manager->SetFocusedView(view1); | |
2685 EXPECT_EQ(view1, focus_manager->GetFocusedView()); | |
2686 | |
2687 // Set the focused view as not focusable and check if the next view gets | |
2688 // focused. | |
2689 view1->SetFocusable(false); | |
2690 EXPECT_EQ(view2, focus_manager->GetFocusedView()); | |
2691 } | |
2692 | |
2693 //////////////////////////////////////////////////////////////////////////////// | |
2645 // Layers | 2694 // Layers |
2646 //////////////////////////////////////////////////////////////////////////////// | 2695 //////////////////////////////////////////////////////////////////////////////// |
2647 | 2696 |
2648 namespace { | 2697 namespace { |
2649 | 2698 |
2650 // Test implementation of LayerAnimator. | 2699 // Test implementation of LayerAnimator. |
2651 class TestLayerAnimator : public ui::LayerAnimator { | 2700 class TestLayerAnimator : public ui::LayerAnimator { |
2652 public: | 2701 public: |
2653 TestLayerAnimator(); | 2702 TestLayerAnimator(); |
2654 | 2703 |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3635 // notification. | 3684 // notification. |
3636 TestView* test_view_child_2 = new TestView(); | 3685 TestView* test_view_child_2 = new TestView(); |
3637 test_view->AddChildView(test_view_child_2); | 3686 test_view->AddChildView(test_view_child_2); |
3638 EXPECT_TRUE(test_view_child_2->native_theme_); | 3687 EXPECT_TRUE(test_view_child_2->native_theme_); |
3639 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); | 3688 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); |
3640 | 3689 |
3641 widget->CloseNow(); | 3690 widget->CloseNow(); |
3642 } | 3691 } |
3643 | 3692 |
3644 } // namespace views | 3693 } // namespace views |
OLD | NEW |