OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <gdk/gdkkeysyms.h> | 5 #include <gdk/gdkkeysyms.h> |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/rect.h" | 8 #include "ui/gfx/rect.h" |
9 #include "views/focus/accelerator_handler.h" | 9 #include "views/focus/accelerator_handler.h" |
10 #include "views/focus/focus_manager.h" | 10 #include "views/focus/focus_manager.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 FocusManager* focus_manager = window_->GetFocusManager(); | 31 FocusManager* focus_manager = window_->GetFocusManager(); |
32 focus_manager->RegisterAccelerator(kMenuAccelerator, this); | 32 focus_manager->RegisterAccelerator(kMenuAccelerator, this); |
33 focus_manager->RegisterAccelerator(kHomepageAccelerator, this); | 33 focus_manager->RegisterAccelerator(kHomepageAccelerator, this); |
34 menu_pressed_ = false; | 34 menu_pressed_ = false; |
35 home_pressed_ = false; | 35 home_pressed_ = false; |
36 } | 36 } |
37 | 37 |
38 virtual void TearDown() { | 38 virtual void TearDown() { |
39 window_->Close(); | 39 window_->Close(); |
40 | 40 |
41 // Flush the message loop to make Purify happy. | 41 // Flush the message loop to make application verifiers happy. |
42 message_loop_.RunAllPending(); | 42 message_loop_.RunAllPending(); |
43 } | 43 } |
44 | 44 |
45 GdkEventKey CreateKeyEvent(GdkEventType type, guint keyval, guint state) { | 45 GdkEventKey CreateKeyEvent(GdkEventType type, guint keyval, guint state) { |
46 GdkEventKey evt; | 46 GdkEventKey evt; |
47 memset(&evt, 0, sizeof(evt)); | 47 memset(&evt, 0, sizeof(evt)); |
48 evt.type = type; | 48 evt.type = type; |
49 evt.keyval = keyval; | 49 evt.keyval = keyval; |
50 // The keyval won't be a "correct" hardware keycode for any real hardware, | 50 // The keyval won't be a "correct" hardware keycode for any real hardware, |
51 // but the code should never depend on exact hardware keycodes, just the | 51 // but the code should never depend on exact hardware keycodes, just the |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // Release Alt - now this should trigger the menu shortcut. | 190 // Release Alt - now this should trigger the menu shortcut. |
191 evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Alt_L, 0); | 191 evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Alt_L, 0); |
192 evt.hardware_keycode = 0x40; | 192 evt.hardware_keycode = 0x40; |
193 EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt))); | 193 EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt))); |
194 | 194 |
195 ASSERT_TRUE(menu_pressed_); | 195 ASSERT_TRUE(menu_pressed_); |
196 } | 196 } |
197 | 197 |
198 } // namespace views | 198 } // namespace views |
OLD | NEW |