Chromium Code Reviews| Index: ui/events/keycodes/keyboard_lookup_win_unittest.cc |
| diff --git a/ui/events/keycodes/keyboard_lookup_win_unittest.cc b/ui/events/keycodes/keyboard_lookup_win_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a3c81a32b761e7220abb44c54f0ae99f303fc089 |
| --- /dev/null |
| +++ b/ui/events/keycodes/keyboard_lookup_win_unittest.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
|
dtapuska
2016/01/21 01:59:36
2016
chongz
2016/01/21 15:47:40
Acknowledged.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/events/keycodes/keyboard_lookup_win.h" |
| + |
| +#include "base/macros.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/events/event_constants.h" |
| +#include "ui/events/keycodes/dom/dom_key.h" |
| +#include "ui/events/keycodes/dom/keycode_converter.h" |
| +#include "ui/events/keycodes/keyboard_codes_win.h" |
| + |
| +namespace ui { |
| + |
| +namespace { |
| + |
| +struct TestKey { |
| + KeyboardCode vk; |
| + DomKey basic_key; |
| + DomKey shifted_key; |
| +}; |
| + |
| +const TestKey USKeys[] = { |
| + {VKEY_2, DomKey::Constant<'2'>::Character, DomKey::Constant<'@'>::Character}, |
| + {VKEY_A, DomKey::Constant<'a'>::Character, DomKey::Constant<'A'>::Character}, |
| + {VKEY_TAB, DomKey::TAB, DomKey::TAB}, |
| + {VKEY_DELETE, DomKey::DEL, DomKey::DEL}, |
| + {VKEY_F16, DomKey::F16, DomKey::F16}, |
| + {VKEY_SHIFT, DomKey::SHIFT, DomKey::SHIFT}, |
| +}; |
| + |
| +} // namespace |
| + |
| +class WindowsKeyboardLookupTest : public testing::Test { |
| + public: |
| + WindowsKeyboardLookupTest() {} |
| + ~WindowsKeyboardLookupTest() override {} |
| + |
| + void SetUp() override {} |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(WindowsKeyboardLookupTest); |
| +}; |
| + |
| +TEST_F(WindowsKeyboardLookupTest, USLayout) { |
| + // Haven't figure how to switch layout |
| + HKL us_iden = ::GetKeyboardLayout(0);//::LoadKeyboardLayout(L"00000409", 0); |
| + WindowsKeyboardLookup *lookup = WindowsKeyboardLookup::Create(us_iden); |
|
dtapuska
2016/01/21 01:59:36
use a scoped_ptr for the keyboard lookup...
chongz
2016/01/21 15:47:40
Acknowledged.
|
| + |
| + for (const auto &k : USKeys) { |
| + EXPECT_EQ(k.basic_key, lookup->VirtualKeyToDomKey(k.vk, EF_NONE)); |
| + EXPECT_EQ(k.shifted_key, lookup->VirtualKeyToDomKey(k.vk, EF_SHIFT_DOWN)); |
| + } |
| + |
| + delete lookup; |
| +} |
| + |
| +} // namespace ui |