Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / ash / ime_controller_chromeos_unittest.cc
blob560039e26a561e13f787faaf47e814e1f270262c
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/ime_controller_chromeos.h"
7 #include "base/basictypes.h"
8 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
9 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/base/accelerators/accelerator.h"
12 #include "ui/events/event_constants.h"
13 #include "ui/events/keycodes/keyboard_codes.h"
15 class ImeControllerTest : public testing::Test {
16 public:
17 ImeControllerTest() : mock_input_method_manager_(NULL) {}
18 virtual ~ImeControllerTest() {}
20 virtual void SetUp() OVERRIDE {
21 mock_input_method_manager_ =
22 new chromeos::input_method::MockInputMethodManager;
23 chromeos::input_method::InitializeForTesting(
24 mock_input_method_manager_);
27 virtual void TearDown() OVERRIDE {
28 chromeos::input_method::Shutdown();
29 mock_input_method_manager_ = NULL;
32 protected:
33 ImeController controller_;
34 chromeos::input_method::MockInputMethodManager* mock_input_method_manager_;
36 private:
37 DISALLOW_COPY_AND_ASSIGN(ImeControllerTest);
40 TEST_F(ImeControllerTest, TestRemapAccelerator) {
41 mock_input_method_manager_->SetCurrentInputMethodId("xkb:us::eng");
43 ui::Accelerator accel(ui::VKEY_A, ui::EF_CONTROL_DOWN);
44 ui::Accelerator remapped = controller_.RemapAccelerator(accel);
45 EXPECT_EQ(accel, remapped);
46 accel.set_type(ui::ET_KEY_RELEASED);
47 remapped = controller_.RemapAccelerator(accel);
48 EXPECT_EQ(accel, remapped); // crbug.com/130519
50 mock_input_method_manager_->SetCurrentInputMethodId("xkb:fr::fra");
52 // Control+A shouldn't be remapped even when the current layout is FR.
53 ui::Accelerator accel(ui::VKEY_A, ui::EF_CONTROL_DOWN);
54 ui::Accelerator remapped = controller_.RemapAccelerator(accel);
55 EXPECT_EQ(accel, remapped);
56 accel.set_type(ui::ET_KEY_RELEASED);
57 remapped = controller_.RemapAccelerator(accel);
58 EXPECT_EQ(accel, remapped);
61 // Shift+A shouldn't be remapped even when the current layout is FR.
62 ui::Accelerator accel(ui::VKEY_A, ui::EF_SHIFT_DOWN);
63 ui::Accelerator remapped = controller_.RemapAccelerator(accel);
64 EXPECT_EQ(accel, remapped);
65 accel.set_type(ui::ET_KEY_RELEASED);
66 remapped = controller_.RemapAccelerator(accel);
67 EXPECT_EQ(accel, remapped);
70 // Shift+1 should be remapped when the current layout is FR.
71 ui::Accelerator accel(ui::VKEY_1, ui::EF_SHIFT_DOWN);
72 ui::Accelerator remapped = controller_.RemapAccelerator(accel);
73 ui::Accelerator expected(ui::VKEY_1, 0);
74 EXPECT_EQ(expected, remapped);
75 accel.set_type(ui::ET_KEY_RELEASED);
76 remapped = controller_.RemapAccelerator(accel);
77 expected.set_type(ui::ET_KEY_RELEASED);
78 EXPECT_EQ(expected, remapped);