diff options
author | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-02 19:22:15 +0000 |
---|---|---|
committer | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-02 19:22:15 +0000 |
commit | 2b7c9492e9a8794e2124da62bfce91fe3a1b2a77 (patch) | |
tree | f13a5c7961e2655f63916216223d16fa86454a3d /views/focus | |
parent | 010e37516995713253daa8df6f7ba1c2b12ccd1d (diff) | |
download | chromium_src-2b7c9492e9a8794e2124da62bfce91fe3a1b2a77.zip chromium_src-2b7c9492e9a8794e2124da62bfce91fe3a1b2a77.tar.gz chromium_src-2b7c9492e9a8794e2124da62bfce91fe3a1b2a77.tar.bz2 |
Revert 58215 - Revert 58186 - Move the keyboard files from base/ to app/.
Also moves the associated classes/enums from base:: to app::.
TEST=try bots compile
BUG=NONE
Review URL: http://codereview.chromium.org/3165064
TBR=bryeung@chromium.org
TBR=phajdan.jr@chromium.org
Review URL: http://codereview.chromium.org/3361003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r-- | views/focus/accelerator_handler_gtk_unittest.cc | 4 | ||||
-rw-r--r-- | views/focus/accelerator_handler_win.cc | 5 | ||||
-rw-r--r-- | views/focus/focus_manager.cc | 12 | ||||
-rw-r--r-- | views/focus/focus_manager_unittest.cc | 90 |
4 files changed, 56 insertions, 55 deletions
diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/views/focus/accelerator_handler_gtk_unittest.cc index 78e9110..baa11bc 100644 --- a/views/focus/accelerator_handler_gtk_unittest.cc +++ b/views/focus/accelerator_handler_gtk_unittest.cc @@ -19,8 +19,8 @@ class AcceleratorHandlerGtkTest public AcceleratorTarget { public: AcceleratorHandlerGtkTest() - : kMenuAccelerator(base::VKEY_MENU, false, false, false), - kHomepageAccelerator(base::VKEY_HOME, false, false, true), + : kMenuAccelerator(app::VKEY_MENU, false, false, false), + kHomepageAccelerator(app::VKEY_HOME, false, false, true), content_view_(NULL) { } diff --git a/views/focus/accelerator_handler_win.cc b/views/focus/accelerator_handler_win.cc index 64b51f4..496acd4 100644 --- a/views/focus/accelerator_handler_win.cc +++ b/views/focus/accelerator_handler_win.cc @@ -4,7 +4,8 @@ #include "views/focus/accelerator_handler.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_code_conversion_win.h" +#include "app/keyboard_codes.h" #include "base/win_util.h" #include "views/event.h" #include "views/focus/focus_manager.h" @@ -25,7 +26,7 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { KeyEvent event(Event::ET_KEY_PRESSED, - win_util::WinToKeyboardCode(msg.wParam), + app::KeyboardCodeForWindowsKeyCode(msg.wParam), KeyEvent::GetKeyStateFlags(), msg.lParam & 0xFFFF, (msg.lParam & 0xFFFF0000) >> 16); diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index f0f5f99..3751ace 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -12,7 +12,7 @@ #include <gtk/gtk.h> #endif -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "views/accelerator.h" #include "views/focus/focus_search.h" @@ -109,11 +109,11 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) { #endif // Intercept arrow key messages to switch between grouped views. - base::KeyboardCode key_code = event.GetKeyCode(); + app::KeyboardCode key_code = event.GetKeyCode(); if (focused_view_ && focused_view_->GetGroup() != -1 && - (key_code == base::VKEY_UP || key_code == base::VKEY_DOWN || - key_code == base::VKEY_LEFT || key_code == base::VKEY_RIGHT)) { - bool next = (key_code == base::VKEY_RIGHT || key_code == base::VKEY_DOWN); + (key_code == app::VKEY_UP || key_code == app::VKEY_DOWN || + key_code == app::VKEY_LEFT || key_code == app::VKEY_RIGHT)) { + bool next = (key_code == app::VKEY_RIGHT || key_code == app::VKEY_DOWN); std::vector<View*> views; focused_view_->GetParent()->GetViewsWithGroup(focused_view_->GetGroup(), &views); @@ -494,7 +494,7 @@ AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( // static bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) { - return key_event.GetKeyCode() == base::VKEY_TAB && + return key_event.GetKeyCode() == app::VKEY_TAB && !key_event.IsControlDown(); } diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index a711538..c7a3cf4 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -5,7 +5,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "app/combobox_model.h" -#include "base/keyboard_codes.h" +#include "app/keyboard_codes.h" #include "base/logging.h" #include "base/string16.h" #include "base/string_number_conversions.h" @@ -36,7 +36,7 @@ #include "views/widget/widget_win.h" #include "views/window/window_win.h" #elif defined(OS_LINUX) -#include "base/keyboard_code_conversion_gtk.h" +#include "app/keyboard_code_conversion_gtk.h" #include "views/window/window_gtk.h" #endif @@ -209,23 +209,23 @@ class FocusManagerTest : public testing::Test, public WindowDelegate { } #if defined(OS_WIN) - void PostKeyDown(base::KeyboardCode key_code) { + void PostKeyDown(app::KeyboardCode key_code) { ::PostMessage(window_->GetNativeWindow(), WM_KEYDOWN, key_code, 0); } - void PostKeyUp(base::KeyboardCode key_code) { + void PostKeyUp(app::KeyboardCode key_code) { ::PostMessage(window_->GetNativeWindow(), WM_KEYUP, key_code, 0); } #elif defined(OS_LINUX) - void PostKeyDown(base::KeyboardCode key_code) { + void PostKeyDown(app::KeyboardCode key_code) { PostKeyEvent(key_code, true); } - void PostKeyUp(base::KeyboardCode key_code) { + void PostKeyUp(app::KeyboardCode key_code) { PostKeyEvent(key_code, false); } - void PostKeyEvent(base::KeyboardCode key_code, bool pressed) { + void PostKeyEvent(app::KeyboardCode key_code, bool pressed) { int keyval = GdkKeyCodeForWindowsKeyCode(key_code, false); GdkKeymapKey* keys; gint n_keys; @@ -1300,8 +1300,8 @@ class TestAcceleratorTarget : public AcceleratorTarget { TEST_F(FocusManagerTest, CallsNormalAcceleratorTarget) { FocusManager* focus_manager = GetFocusManager(); - Accelerator return_accelerator(base::VKEY_RETURN, false, false, false); - Accelerator escape_accelerator(base::VKEY_ESCAPE, false, false, false); + Accelerator return_accelerator(app::VKEY_RETURN, false, false, false); + Accelerator escape_accelerator(app::VKEY_ESCAPE, false, false, false); TestAcceleratorTarget return_target(true); TestAcceleratorTarget escape_target(true); @@ -1418,7 +1418,7 @@ class SelfUnregisteringAcceleratorTarget : public AcceleratorTarget { TEST_F(FocusManagerTest, CallsSelfDeletingAcceleratorTarget) { FocusManager* focus_manager = GetFocusManager(); - Accelerator return_accelerator(base::VKEY_RETURN, false, false, false); + Accelerator return_accelerator(app::VKEY_RETURN, false, false, false); SelfUnregisteringAcceleratorTarget target(return_accelerator, focus_manager); EXPECT_EQ(target.accelerator_count(), 0); EXPECT_EQ(NULL, @@ -1466,11 +1466,11 @@ class MessageTrackingView : public View { keys_released_.clear(); } - const std::vector<base::KeyboardCode>& keys_pressed() const { + const std::vector<app::KeyboardCode>& keys_pressed() const { return keys_pressed_; } - const std::vector<base::KeyboardCode>& keys_released() const { + const std::vector<app::KeyboardCode>& keys_released() const { return keys_released_; } @@ -1480,8 +1480,8 @@ class MessageTrackingView : public View { private: bool accelerator_pressed_; - std::vector<base::KeyboardCode> keys_pressed_; - std::vector<base::KeyboardCode> keys_released_; + std::vector<app::KeyboardCode> keys_pressed_; + std::vector<app::KeyboardCode> keys_released_; DISALLOW_COPY_AND_ASSIGN(MessageTrackingView); }; @@ -1494,53 +1494,53 @@ class MessageTrackingView : public View { TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { FocusManager* focus_manager = GetFocusManager(); MessageTrackingView* mtv = new MessageTrackingView(); - mtv->AddAccelerator(Accelerator(base::VKEY_0, false, false, false)); - mtv->AddAccelerator(Accelerator(base::VKEY_1, false, false, false)); + mtv->AddAccelerator(Accelerator(app::VKEY_0, false, false, false)); + mtv->AddAccelerator(Accelerator(app::VKEY_1, false, false, false)); content_view_->AddChildView(mtv); focus_manager->SetFocusedView(mtv); // First send a non-accelerator key sequence. - PostKeyDown(base::VKEY_9); - PostKeyUp(base::VKEY_9); + PostKeyDown(app::VKEY_9); + PostKeyUp(app::VKEY_9); AcceleratorHandler accelerator_handler; MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); // Make sure we get a key-up and key-down. ASSERT_EQ(1U, mtv->keys_pressed().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(0)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(0)); ASSERT_EQ(1U, mtv->keys_released().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_released().at(0)); + EXPECT_EQ(app::VKEY_9, mtv->keys_released().at(0)); EXPECT_FALSE(mtv->accelerator_pressed()); mtv->Reset(); // Same thing with repeat and more than one key at once. - PostKeyDown(base::VKEY_9); - PostKeyDown(base::VKEY_9); - PostKeyDown(base::VKEY_8); - PostKeyDown(base::VKEY_9); - PostKeyDown(base::VKEY_7); - PostKeyUp(base::VKEY_9); - PostKeyUp(base::VKEY_7); - PostKeyUp(base::VKEY_8); + PostKeyDown(app::VKEY_9); + PostKeyDown(app::VKEY_9); + PostKeyDown(app::VKEY_8); + PostKeyDown(app::VKEY_9); + PostKeyDown(app::VKEY_7); + PostKeyUp(app::VKEY_9); + PostKeyUp(app::VKEY_7); + PostKeyUp(app::VKEY_8); MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); // Make sure we get a key-up and key-down. ASSERT_EQ(5U, mtv->keys_pressed().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(0)); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(1)); - EXPECT_EQ(base::VKEY_8, mtv->keys_pressed().at(2)); - EXPECT_EQ(base::VKEY_9, mtv->keys_pressed().at(3)); - EXPECT_EQ(base::VKEY_7, mtv->keys_pressed().at(4)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(0)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(1)); + EXPECT_EQ(app::VKEY_8, mtv->keys_pressed().at(2)); + EXPECT_EQ(app::VKEY_9, mtv->keys_pressed().at(3)); + EXPECT_EQ(app::VKEY_7, mtv->keys_pressed().at(4)); ASSERT_EQ(3U, mtv->keys_released().size()); - EXPECT_EQ(base::VKEY_9, mtv->keys_released().at(0)); - EXPECT_EQ(base::VKEY_7, mtv->keys_released().at(1)); - EXPECT_EQ(base::VKEY_8, mtv->keys_released().at(2)); + EXPECT_EQ(app::VKEY_9, mtv->keys_released().at(0)); + EXPECT_EQ(app::VKEY_7, mtv->keys_released().at(1)); + EXPECT_EQ(app::VKEY_8, mtv->keys_released().at(2)); EXPECT_FALSE(mtv->accelerator_pressed()); mtv->Reset(); // Now send an accelerator key sequence. - PostKeyDown(base::VKEY_0); - PostKeyUp(base::VKEY_0); + PostKeyDown(app::VKEY_0); + PostKeyUp(app::VKEY_0); MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); EXPECT_TRUE(mtv->keys_pressed().empty()); @@ -1549,13 +1549,13 @@ TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { mtv->Reset(); // Same thing with repeat and more than one key at once. - PostKeyDown(base::VKEY_0); - PostKeyDown(base::VKEY_1); - PostKeyDown(base::VKEY_1); - PostKeyDown(base::VKEY_0); - PostKeyDown(base::VKEY_0); - PostKeyUp(base::VKEY_1); - PostKeyUp(base::VKEY_0); + PostKeyDown(app::VKEY_0); + PostKeyDown(app::VKEY_1); + PostKeyDown(app::VKEY_1); + PostKeyDown(app::VKEY_0); + PostKeyDown(app::VKEY_0); + PostKeyUp(app::VKEY_1); + PostKeyUp(app::VKEY_0); MessageLoopForUI::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoopForUI::current()->Run(&accelerator_handler); EXPECT_TRUE(mtv->keys_pressed().empty()); |