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