summaryrefslogtreecommitdiffstats
path: root/ui/views/focus
diff options
context:
space:
mode:
authorsaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-19 18:18:48 +0000
committersaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-19 18:18:48 +0000
commit077d56ae8b021a85c94010af48daee477972ea04 (patch)
tree3fe72977892dccfda8fe138ec1cd02bdda23d6e6 /ui/views/focus
parent484a65aef61f9809cbe083ef93fb66ff016d5776 (diff)
downloadchromium_src-077d56ae8b021a85c94010af48daee477972ea04.zip
chromium_src-077d56ae8b021a85c94010af48daee477972ea04.tar.gz
chromium_src-077d56ae8b021a85c94010af48daee477972ea04.tar.bz2
Removing deprecated GTK-Views code.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9728002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/focus')
-rw-r--r--ui/views/focus/accelerator_handler_gtk.cc22
-rw-r--r--ui/views/focus/accelerator_handler_gtk_unittest.cc204
2 files changed, 0 insertions, 226 deletions
diff --git a/ui/views/focus/accelerator_handler_gtk.cc b/ui/views/focus/accelerator_handler_gtk.cc
deleted file mode 100644
index 2191686..0000000
--- a/ui/views/focus/accelerator_handler_gtk.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/focus/accelerator_handler.h"
-
-#include <gtk/gtk.h>
-
-#include "ui/views/focus/focus_manager.h"
-
-namespace views {
-
-AcceleratorHandler::AcceleratorHandler() {}
-
-bool AcceleratorHandler::Dispatch(GdkEvent* event) {
- // The logic for handling keyboard accelerators has been moved into
- // NativeWidgetGtk::OnEventKey handler (views/widget/widget_gtk.cc).
- gtk_main_do_event(event);
- return true;
-}
-
-} // namespace views
diff --git a/ui/views/focus/accelerator_handler_gtk_unittest.cc b/ui/views/focus/accelerator_handler_gtk_unittest.cc
deleted file mode 100644
index 187273e..0000000
--- a/ui/views/focus/accelerator_handler_gtk_unittest.cc
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <gdk/gdkkeysyms.h>
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/accelerators/accelerator.h"
-#include "ui/gfx/rect.h"
-#include "ui/views/focus/accelerator_handler.h"
-#include "ui/views/focus/focus_manager.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/widget/widget_delegate.h"
-
-namespace views {
-
-class AcceleratorHandlerGtkTest
- : public testing::Test,
- public WidgetDelegate,
- public ui::AcceleratorTarget {
- public:
- AcceleratorHandlerGtkTest()
- : kMenuAccelerator(ui::VKEY_MENU, false, false, false),
- kHomepageAccelerator(ui::VKEY_HOME, false, false, true),
- content_view_(NULL) {
- }
-
- virtual void SetUp() {
- window_ = Widget::CreateWindowWithBounds(this, gfx::Rect(0, 0, 500, 500));
- window_->Show();
- FocusManager* focus_manager = window_->GetFocusManager();
- focus_manager->RegisterAccelerator(
- kMenuAccelerator, ui::AcceleratorManager::kNormalPriority, this);
- focus_manager->RegisterAccelerator(
- kHomepageAccelerator, ui::AcceleratorManager::kNormalPriority, this);
- menu_pressed_ = false;
- home_pressed_ = false;
- }
-
- virtual void TearDown() {
- window_->Close();
-
- // Flush the message loop to make application verifiers happy.
- message_loop_.RunAllPending();
- }
-
- GdkEventKey CreateKeyEvent(GdkEventType type, guint keyval, guint state) {
- GdkEventKey evt;
- memset(&evt, 0, sizeof(evt));
- evt.type = type;
- evt.keyval = keyval;
- // The keyval won't be a "correct" hardware keycode for any real hardware,
- // but the code should never depend on exact hardware keycodes, just the
- // fact that the code for presses and releases of the same key match.
- evt.hardware_keycode = keyval;
- evt.state = state;
- GtkWidget* widget = GTK_WIDGET(window_->GetNativeWindow());
- evt.window = widget->window;
- return evt;
- }
-
- // AcceleratorTarget implementation.
- virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) {
- if (accelerator == kMenuAccelerator)
- menu_pressed_ = true;
- else if (accelerator == kHomepageAccelerator)
- home_pressed_ = true;
- return true;
- }
- virtual bool CanHandleAccelerators() const {
- return true;
- }
-
- // WidgetDelegate Implementation.
- virtual View* GetContentsView() {
- if (!content_view_)
- content_view_ = new View();
- return content_view_;
- }
- virtual const views::Widget* GetWidget() const {
- return content_view_->GetWidget();
- }
- virtual views::Widget* GetWidget() {
- return content_view_->GetWidget();
- }
-
- virtual void InitContentView() {
- }
-
- protected:
- bool menu_pressed_;
- bool home_pressed_;
-
- private:
- ui::Accelerator kMenuAccelerator;
- ui::Accelerator kHomepageAccelerator;
- Widget* window_;
- View* content_view_;
- MessageLoopForUI message_loop_;
- DISALLOW_COPY_AND_ASSIGN(AcceleratorHandlerGtkTest);
-};
-
-// Test that the homepage accelerator (Alt+Home) is activated on key down
-// and that the menu accelerator (Alt) is never activated.
-TEST_F(AcceleratorHandlerGtkTest, TestHomepageAccelerator) {
- AcceleratorHandler handler;
- GdkEventKey evt;
-
- ASSERT_FALSE(menu_pressed_);
- ASSERT_FALSE(home_pressed_);
-
- evt = CreateKeyEvent(GDK_KEY_PRESS, GDK_Alt_L, 0);
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_FALSE(menu_pressed_);
- ASSERT_FALSE(home_pressed_);
-
- evt = CreateKeyEvent(GDK_KEY_PRESS, GDK_Home, GDK_MOD1_MASK);
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_FALSE(menu_pressed_);
- ASSERT_TRUE(home_pressed_);
-
- evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Home, GDK_MOD1_MASK);
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
- evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Alt_L, 0);
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_FALSE(menu_pressed_);
- ASSERT_TRUE(home_pressed_);
-}
-
-// Test that the menu accelerator is activated on key up and not key down.
-TEST_F(AcceleratorHandlerGtkTest, TestMenuAccelerator) {
- AcceleratorHandler handler;
- GdkEventKey evt;
-
- ASSERT_FALSE(menu_pressed_);
-
- evt = CreateKeyEvent(GDK_KEY_PRESS, GDK_Alt_L, 0);
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_FALSE(menu_pressed_);
-
- evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Alt_L, 0);
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_TRUE(menu_pressed_);
-}
-
-// Test that the menu accelerator isn't confused by the interaction of the
-// Alt and Shift keys. Try the following sequence on Linux:
-// Press Alt
-// Press Shift
-// Release Alt
-// Release Shift
-// The key codes for pressing Alt and releasing Alt are different! This
-// caused a bug in a previous version of the code, which is now fixed by
-// keeping track of hardware keycodes, which are consistent.
-TEST_F(AcceleratorHandlerGtkTest, TestAltShiftInteraction) {
- AcceleratorHandler handler;
- GdkEventKey evt;
-
- ASSERT_FALSE(menu_pressed_);
-
- // Press Shift.
- evt = CreateKeyEvent(GDK_KEY_PRESS, GDK_Shift_L, 0);
- evt.hardware_keycode = 0x32;
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
- // Press Alt - but GDK calls this Meta when Shift is also down.
- evt = CreateKeyEvent(GDK_KEY_PRESS, GDK_Meta_L, 0);
- evt.hardware_keycode = 0x40;
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- // Release Shift.
- evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Shift_L, 0);
- evt.hardware_keycode = 0x32;
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
- // Release Alt - with Shift not down, the keyval is now Alt, but
- // the hardware keycode is unchanged.
- evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Alt_L, 0);
- evt.hardware_keycode = 0x40;
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_FALSE(menu_pressed_);
-
- // Press Alt by itself.
- evt = CreateKeyEvent(GDK_KEY_PRESS, GDK_Alt_L, 0);
- evt.hardware_keycode = 0x40;
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- // This line fails if we don't keep track of hardware keycodes.
- ASSERT_FALSE(menu_pressed_);
-
- // Release Alt - now this should trigger the menu shortcut.
- evt = CreateKeyEvent(GDK_KEY_RELEASE, GDK_Alt_L, 0);
- evt.hardware_keycode = 0x40;
- EXPECT_TRUE(handler.Dispatch(reinterpret_cast<GdkEvent*>(&evt)));
-
- ASSERT_TRUE(menu_pressed_);
-}
-
-} // namespace views