| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 toplevel->SetContentsView(container); | 1022 toplevel->SetContentsView(container); |
| 1023 | 1023 |
| 1024 Textfield* textfield = new Textfield(); | 1024 Textfield* textfield = new Textfield(); |
| 1025 textfield->SetText(ASCIIToUTF16("some text")); | 1025 textfield->SetText(ASCIIToUTF16("some text")); |
| 1026 container->AddChildView(textfield); | 1026 container->AddChildView(textfield); |
| 1027 toplevel->Show(); | 1027 toplevel->Show(); |
| 1028 textfield->RequestFocus(); | 1028 textfield->RequestFocus(); |
| 1029 | 1029 |
| 1030 // The press gets handled. The release doesn't have an effect. | 1030 // The press gets handled. The release doesn't have an effect. |
| 1031 ui::KeyEvent backspace_p(ui::ET_KEY_PRESSED, ui::VKEY_DELETE, 0, false); | 1031 ui::KeyEvent backspace_p(ui::ET_KEY_PRESSED, ui::VKEY_DELETE, 0, false); |
| 1032 EXPECT_TRUE(toplevel->OnKeyEvent(backspace_p)); | 1032 toplevel->OnKeyEvent(&backspace_p); |
| 1033 EXPECT_TRUE(backspace_p.stopped_propagation()); |
| 1033 ui::KeyEvent backspace_r(ui::ET_KEY_RELEASED, ui::VKEY_DELETE, 0, false); | 1034 ui::KeyEvent backspace_r(ui::ET_KEY_RELEASED, ui::VKEY_DELETE, 0, false); |
| 1034 EXPECT_FALSE(toplevel->OnKeyEvent(backspace_r)); | 1035 toplevel->OnKeyEvent(&backspace_r); |
| 1036 EXPECT_FALSE(backspace_r.handled()); |
| 1035 | 1037 |
| 1036 toplevel->Close(); | 1038 toplevel->Close(); |
| 1037 } | 1039 } |
| 1038 | 1040 |
| 1039 // Verifies bubbles result in a focus lost when shown. | 1041 // Verifies bubbles result in a focus lost when shown. |
| 1040 TEST_F(WidgetTest, FocusChangesOnBubble) { | 1042 TEST_F(WidgetTest, FocusChangesOnBubble) { |
| 1041 // Create a widget, show and activate it and focus the contents view. | 1043 // Create a widget, show and activate it and focus the contents view. |
| 1042 View* contents_view = new View; | 1044 View* contents_view = new View; |
| 1043 contents_view->set_focusable(true); | 1045 contents_view->set_focusable(true); |
| 1044 Widget widget; | 1046 Widget widget; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1072 bubble_widget->CloseNow(); | 1074 bubble_widget->CloseNow(); |
| 1073 | 1075 |
| 1074 // Closing the bubble should result in focus going back to the contents view. | 1076 // Closing the bubble should result in focus going back to the contents view. |
| 1075 EXPECT_TRUE(contents_view->HasFocus()); | 1077 EXPECT_TRUE(contents_view->HasFocus()); |
| 1076 } | 1078 } |
| 1077 | 1079 |
| 1078 #endif // defined(USE_AURA) | 1080 #endif // defined(USE_AURA) |
| 1079 | 1081 |
| 1080 } // namespace | 1082 } // namespace |
| 1081 } // namespace views | 1083 } // namespace views |
| OLD | NEW |