| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/renderer_host/gtk_key_bindings_handler.h" | 4 |
| 5 #include "content/browser/renderer_host/gtk_key_bindings_handler.h" |
| 5 | 6 |
| 6 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 7 #include <string> | 8 #include <string> |
| 8 #include <utility> | 9 #include <utility> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 16 #include "chrome/common/chrome_paths.h" | 17 #include "content/common/content_paths.h" |
| 17 #include "content/common/edit_command.h" | 18 #include "content/common/edit_command.h" |
| 18 #include "content/common/native_web_keyboard_event.h" | 19 #include "content/common/native_web_keyboard_event.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 class GtkKeyBindingsHandlerTest : public testing::Test { | 22 class GtkKeyBindingsHandlerTest : public testing::Test { |
| 22 protected: | 23 protected: |
| 23 struct EditCommand { | 24 struct EditCommand { |
| 24 const char* name; | 25 const char* name; |
| 25 const char* value; | 26 const char* value; |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 GtkKeyBindingsHandlerTest() | 29 GtkKeyBindingsHandlerTest() |
| 29 : window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)), | 30 : window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)), |
| 30 handler_(NULL) { | 31 handler_(NULL) { |
| 31 FilePath gtkrc; | 32 FilePath gtkrc; |
| 32 PathService::Get(chrome::DIR_TEST_DATA, >krc); | 33 PathService::Get(content::DIR_TEST_DATA, >krc); |
| 33 gtkrc = gtkrc.AppendASCII("gtk_key_bindings_test_gtkrc"); | 34 gtkrc = gtkrc.AppendASCII("gtk_key_bindings_test_gtkrc"); |
| 35 EXPECT_TRUE(file_util::PathExists(gtkrc)); |
| 34 | 36 |
| 35 gtk_rc_parse(gtkrc.value().c_str()); | 37 gtk_rc_parse(gtkrc.value().c_str()); |
| 36 | 38 |
| 37 GtkWidget* fixed = gtk_fixed_new(); | 39 GtkWidget* fixed = gtk_fixed_new(); |
| 38 handler_ = new GtkKeyBindingsHandler(fixed); | 40 handler_ = new GtkKeyBindingsHandler(fixed); |
| 39 gtk_container_add(GTK_CONTAINER(window_), fixed); | 41 gtk_container_add(GTK_CONTAINER(window_), fixed); |
| 40 gtk_widget_show(fixed); | 42 gtk_widget_show(fixed); |
| 41 gtk_widget_show(window_); | 43 gtk_widget_show(window_); |
| 42 } | 44 } |
| 43 ~GtkKeyBindingsHandlerTest() { | 45 ~GtkKeyBindingsHandlerTest() { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 }; | 213 }; |
| 212 TestKeyBinding(NewNativeWebKeyboardEvent(GDK_8, GDK_CONTROL_MASK), | 214 TestKeyBinding(NewNativeWebKeyboardEvent(GDK_8, GDK_CONTROL_MASK), |
| 213 kSelectAll, arraysize(kSelectAll)); | 215 kSelectAll, arraysize(kSelectAll)); |
| 214 | 216 |
| 215 static const EditCommand kSetAnchor[] = { | 217 static const EditCommand kSetAnchor[] = { |
| 216 { "SetMark", "" } | 218 { "SetMark", "" } |
| 217 }; | 219 }; |
| 218 TestKeyBinding(NewNativeWebKeyboardEvent(GDK_9, GDK_CONTROL_MASK), | 220 TestKeyBinding(NewNativeWebKeyboardEvent(GDK_9, GDK_CONTROL_MASK), |
| 219 kSetAnchor, arraysize(kSetAnchor)); | 221 kSetAnchor, arraysize(kSetAnchor)); |
| 220 } | 222 } |
| OLD | NEW |