| Index: ui/views/view_unittest.cc
|
| diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
|
| index 7e7560af9cfee9105a994187c878550563f08f8e..608a67f3e66c1181a0926033936303e432a1ec72 100644
|
| --- a/ui/views/view_unittest.cc
|
| +++ b/ui/views/view_unittest.cc
|
| @@ -1711,7 +1711,7 @@ class DefaultButtonTest : public ViewTest {
|
| ViewTest::TearDown();
|
| }
|
|
|
| - void SimulatePressingEnterAndCheckDefaultButton(ButtonID button_id) {
|
| + void SimulatePressingEnterAndCheckHandledButton(ButtonID button_id) {
|
| ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false);
|
| focus_manager_->OnKeyEvent(event);
|
| switch (button_id) {
|
| @@ -1749,50 +1749,50 @@ class DefaultButtonTest : public ViewTest {
|
| };
|
|
|
| TEST_F(DefaultButtonTest, DialogDefaultButtonTest) {
|
| - // Window has just been shown, we expect the default button specified in the
|
| - // DialogDelegate.
|
| + // The dialog should initially honor the delegate's specified default button.
|
| EXPECT_TRUE(ok_button_->is_default());
|
| + EXPECT_FALSE(test_dialog_->button1_->is_default());
|
| + EXPECT_FALSE(test_dialog_->button2_->is_default());
|
|
|
| // Simulate pressing enter, that should trigger the OK button.
|
| - SimulatePressingEnterAndCheckDefaultButton(OK);
|
| + SimulatePressingEnterAndCheckHandledButton(OK);
|
|
|
| - // Simulate focusing another button, it should become the default button.
|
| - client_view_->OnWillChangeFocus(ok_button_, test_dialog_->button1_);
|
| - EXPECT_FALSE(ok_button_->is_default());
|
| - EXPECT_TRUE(test_dialog_->button1_->is_default());
|
| + // Focusing another button changes enter handling, but not the default button.
|
| + FocusManager* focus_manager = client_view_->GetFocusManager();
|
| + focus_manager->SetFocusedView(test_dialog_->button1_);
|
| + EXPECT_TRUE(ok_button_->is_default());
|
| + EXPECT_FALSE(test_dialog_->button1_->is_default());
|
| + EXPECT_FALSE(test_dialog_->button2_->is_default());
|
| // Simulate pressing enter, that should trigger button1.
|
| - SimulatePressingEnterAndCheckDefaultButton(BUTTON1);
|
| + SimulatePressingEnterAndCheckHandledButton(BUTTON1);
|
|
|
| - // Now select something that is not a button, the OK should become the default
|
| - // button again.
|
| - client_view_->OnWillChangeFocus(test_dialog_->button1_,
|
| - test_dialog_->checkbox_);
|
| + // Focusing a non-button view invokes OK.
|
| + focus_manager->SetFocusedView(test_dialog_->checkbox_);
|
| EXPECT_TRUE(ok_button_->is_default());
|
| EXPECT_FALSE(test_dialog_->button1_->is_default());
|
| - SimulatePressingEnterAndCheckDefaultButton(OK);
|
| + EXPECT_FALSE(test_dialog_->button2_->is_default());
|
| + SimulatePressingEnterAndCheckHandledButton(OK);
|
|
|
| - // Select yet another button.
|
| - client_view_->OnWillChangeFocus(test_dialog_->checkbox_,
|
| - test_dialog_->button2_);
|
| - EXPECT_FALSE(ok_button_->is_default());
|
| + // Focus yet another button.
|
| + focus_manager->SetFocusedView(test_dialog_->button2_);
|
| + EXPECT_TRUE(ok_button_->is_default());
|
| EXPECT_FALSE(test_dialog_->button1_->is_default());
|
| - EXPECT_TRUE(test_dialog_->button2_->is_default());
|
| - SimulatePressingEnterAndCheckDefaultButton(BUTTON2);
|
| + EXPECT_FALSE(test_dialog_->button2_->is_default());
|
| + SimulatePressingEnterAndCheckHandledButton(BUTTON2);
|
|
|
| // Focus nothing.
|
| - client_view_->OnWillChangeFocus(test_dialog_->button2_, NULL);
|
| + focus_manager->ClearFocus();
|
| EXPECT_TRUE(ok_button_->is_default());
|
| EXPECT_FALSE(test_dialog_->button1_->is_default());
|
| EXPECT_FALSE(test_dialog_->button2_->is_default());
|
| - SimulatePressingEnterAndCheckDefaultButton(OK);
|
| + SimulatePressingEnterAndCheckHandledButton(OK);
|
|
|
| // Focus the cancel button.
|
| - client_view_->OnWillChangeFocus(NULL, cancel_button_);
|
| - EXPECT_FALSE(ok_button_->is_default());
|
| - EXPECT_TRUE(cancel_button_->is_default());
|
| + focus_manager->SetFocusedView(cancel_button_);
|
| + EXPECT_TRUE(ok_button_->is_default());
|
| EXPECT_FALSE(test_dialog_->button1_->is_default());
|
| EXPECT_FALSE(test_dialog_->button2_->is_default());
|
| - SimulatePressingEnterAndCheckDefaultButton(CANCEL);
|
| + SimulatePressingEnterAndCheckHandledButton(CANCEL);
|
| }
|
|
|
| class ButtonDropDownTest : public ViewTest {
|
|
|