Chromium Code Reviews| Index: ui/views/view_unittest.cc |
| diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc |
| index 544e9997450b7643b940e0d388a0c42600f241ec..b2712487278df19f61d22aa0e584253b49977a7b 100644 |
| --- a/ui/views/view_unittest.cc |
| +++ b/ui/views/view_unittest.cc |
| @@ -2642,6 +2642,55 @@ TEST_F(ViewTest, AddExistingChild) { |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| +// FocusManager |
| +//////////////////////////////////////////////////////////////////////////////// |
| + |
| +TEST_F(ViewTest, ReviseFocusedViewForUnfocusableView) { |
| + // Create a widget with two views and give the first one focus. |
| + Widget widget; |
| + Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| + params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + widget.Init(params); |
| + 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
|
| + |
| + View* view1 = new View(); |
| + view1->SetFocusable(true); |
| + widget.GetRootView()->AddChildView(view1); |
| + View* view2 = new View(); |
| + view2->SetFocusable(true); |
| + widget.GetRootView()->AddChildView(view2); |
| + |
| + FocusManager* focus_manager = widget.GetFocusManager(); |
| + ASSERT_TRUE(focus_manager); |
| + |
| + focus_manager->SetFocusedView(view1); |
| + EXPECT_EQ(view1, focus_manager->GetFocusedView()); |
| + |
| + // Disable the focused view and check if the next view gets focused. |
| + view1->SetEnabled(false); |
| + EXPECT_EQ(view2, focus_manager->GetFocusedView()); |
| + |
| + // Re-enable and re-focus. |
| + view1->SetEnabled(true); |
| + focus_manager->SetFocusedView(view1); |
| + EXPECT_EQ(view1, focus_manager->GetFocusedView()); |
| + |
| + // Hide the focused view and check it the next view gets focused. |
| + view1->SetVisible(false); |
| + EXPECT_EQ(view2, focus_manager->GetFocusedView()); |
| + |
| + // Re-show and re-focus. |
| + view1->SetVisible(true); |
| + focus_manager->SetFocusedView(view1); |
| + EXPECT_EQ(view1, focus_manager->GetFocusedView()); |
| + |
| + // Set the focused view as not focusable and check if the next view gets |
| + // focused. |
| + view1->SetFocusable(false); |
| + EXPECT_EQ(view2, focus_manager->GetFocusedView()); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| // Layers |
| //////////////////////////////////////////////////////////////////////////////// |