Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / ash / ime_controller_chromeos_unittest.cc
blob39217f18b2f2ece5fce6cd826ddafda5f7e9ba49
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 ~ImeControllerTest() override {}
20 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 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);
82 // Test that remapping the accelerator preserves the accelerator's IsRepeat
83 // property.
84 TEST_F(ImeControllerTest, TestRemapAcceleratorPreservesIsRepeat) {
85 mock_input_method_manager_->SetCurrentInputMethodId("xkb:us::eng");
87 ui::Accelerator accel(ui::VKEY_A, ui::EF_CONTROL_DOWN);
88 accel.set_is_repeat(true);
89 ui::Accelerator remapped = controller_.RemapAccelerator(accel);
90 EXPECT_EQ(accel, remapped);
91 // The Accelerator's equality operator ignores whether an accelerator is
92 // repeated.
93 EXPECT_TRUE(remapped.IsRepeat());
96 ui::Accelerator accel(ui::VKEY_A, ui::EF_CONTROL_DOWN);
97 EXPECT_FALSE(accel.IsRepeat());
98 ui::Accelerator remapped = controller_.RemapAccelerator(accel);
99 EXPECT_EQ(accel, remapped);
100 EXPECT_FALSE(remapped.IsRepeat());