| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ui/views/controls/button/text_button.h" | 8 #include "ui/views/controls/button/text_button.h" |
| 9 #include "ui/views/focus/accelerator_handler.h" | 9 #include "ui/views/focus/accelerator_handler.h" |
| 10 #include "ui/views/focus/focus_manager_test.h" | 10 #include "ui/views/focus/focus_manager_test.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // Access the shared focus manager indirectly from the second view handle. | 194 // Access the shared focus manager indirectly from the second view handle. |
| 195 native_view = widget2->GetNativeView(); | 195 native_view = widget2->GetNativeView(); |
| 196 widget = views::Widget::GetTopLevelWidgetForNativeView(native_view); | 196 widget = views::Widget::GetTopLevelWidgetForNativeView(native_view); |
| 197 EXPECT_EQ(widget->GetFocusManager(), focus_manager1); | 197 EXPECT_EQ(widget->GetFocusManager(), focus_manager1); |
| 198 | 198 |
| 199 DestroyWindow(hwnd); | 199 DestroyWindow(hwnd); |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Tests that the keyup messages are eaten for accelerators. | 202 // Tests that the keyup messages are eaten for accelerators. |
| 203 // Windows-only, Windows is the only platform that handles accelerators in | 203 // Windows-only, Windows is the only platform that handles accelerators in |
| 204 // AcceleratorHandler. NativeWidgetAura/NativeWidgetGtk::OnKeyEvent handles | 204 // AcceleratorHandler. NativeWidgetAura::OnKeyEvent handles them in other |
| 205 // them in other configurations. | 205 // configurations. |
| 206 TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { | 206 TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { |
| 207 FocusManager* focus_manager = GetFocusManager(); | 207 FocusManager* focus_manager = GetFocusManager(); |
| 208 MessageTrackingView* mtv = new MessageTrackingView(); | 208 MessageTrackingView* mtv = new MessageTrackingView(); |
| 209 mtv->AddAccelerator(ui::Accelerator(ui::VKEY_0, false, false, false)); | 209 mtv->AddAccelerator(ui::Accelerator(ui::VKEY_0, false, false, false)); |
| 210 mtv->AddAccelerator(ui::Accelerator(ui::VKEY_1, false, false, false)); | 210 mtv->AddAccelerator(ui::Accelerator(ui::VKEY_1, false, false, false)); |
| 211 GetContentsView()->AddChildView(mtv); | 211 GetContentsView()->AddChildView(mtv); |
| 212 focus_manager->SetFocusedView(mtv); | 212 focus_manager->SetFocusedView(mtv); |
| 213 | 213 |
| 214 // First send a non-accelerator key sequence. | 214 // First send a non-accelerator key sequence. |
| 215 PostKeyDown(ui::VKEY_9); | 215 PostKeyDown(ui::VKEY_9); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 PostKeyUp(ui::VKEY_0); | 270 PostKeyUp(ui::VKEY_0); |
| 271 MessageLoopForUI::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 271 MessageLoopForUI::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 272 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); | 272 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); |
| 273 EXPECT_TRUE(mtv->keys_pressed().empty()); | 273 EXPECT_TRUE(mtv->keys_pressed().empty()); |
| 274 EXPECT_TRUE(mtv->keys_released().empty()); | 274 EXPECT_TRUE(mtv->keys_released().empty()); |
| 275 EXPECT_TRUE(mtv->accelerator_pressed()); | 275 EXPECT_TRUE(mtv->accelerator_pressed()); |
| 276 mtv->Reset(); | 276 mtv->Reset(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace views | 279 } // namespace views |
| OLD | NEW |