| Index: ui/views/view_unittest.cc
|
| diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
|
| index 264da270b417122b8b93fcd592f2ecdb6b327f47..25b99e75486fc3ff03b168d664e10c6630855ce6 100644
|
| --- a/ui/views/view_unittest.cc
|
| +++ b/ui/views/view_unittest.cc
|
| @@ -2770,9 +2770,9 @@ TEST_F(ViewTest, ReorderChildren) {
|
| child->AddChildView(foo2);
|
| View* foo3 = new View();
|
| child->AddChildView(foo3);
|
| - foo1->set_focusable(true);
|
| - foo2->set_focusable(true);
|
| - foo3->set_focusable(true);
|
| + foo1->SetFocusable(true);
|
| + foo2->SetFocusable(true);
|
| + foo3->SetFocusable(true);
|
|
|
| ASSERT_EQ(0, child->GetIndexOf(foo1));
|
| ASSERT_EQ(1, child->GetIndexOf(foo2));
|
| @@ -2897,6 +2897,50 @@ TEST_F(ViewTest, AddExistingChild) {
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| +// FocusManager
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +
|
| +TEST_F(ViewTest, ClearFocusIfUnfocusable) {
|
| + // Create a View and focus it.
|
| + View* view = new View();
|
| + view->SetFocusable(true);
|
| +
|
| + scoped_ptr<Widget> widget(new Widget());
|
| + Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
|
| + params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| + widget->Init(params);
|
| + widget->GetRootView()->AddChildView(view);
|
| +
|
| + FocusManager* focus_manager = widget->GetFocusManager();
|
| + ASSERT_TRUE(focus_manager);
|
| +
|
| + focus_manager->SetFocusedView(view);
|
| + EXPECT_EQ(view, focus_manager->GetFocusedView());
|
| +
|
| + // Disable the focused view and check if it loses focus.
|
| + view->SetEnabled(false);
|
| + EXPECT_EQ(NULL, focus_manager->GetFocusedView());
|
| +
|
| + // Re-enable and re-focus.
|
| + view->SetEnabled(true);
|
| + focus_manager->SetFocusedView(view);
|
| + EXPECT_EQ(view, focus_manager->GetFocusedView());
|
| +
|
| + // Hide the focused view and check it it loses focus.
|
| + view->SetVisible(false);
|
| + EXPECT_EQ(NULL, focus_manager->GetFocusedView());
|
| +
|
| + // Re-show and re-focus.
|
| + view->SetVisible(true);
|
| + focus_manager->SetFocusedView(view);
|
| + EXPECT_EQ(view, focus_manager->GetFocusedView());
|
| +
|
| + // Set as not focusable and check if it loses focus.
|
| + view->SetFocusable(false);
|
| + EXPECT_EQ(NULL, focus_manager->GetFocusedView());
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| // Layers
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|