| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #include "app/keyboard_code_conversion.h" | |
| 6 #include "app/keyboard_codes.h" | |
| 7 #include "base/logging.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace app { | |
| 11 | |
| 12 TEST(KeyCodeFromKeyIdentifierTest, MatchOnIdentifier) { | |
| 13 EXPECT_EQ(app::VKEY_APPS, KeyCodeFromKeyIdentifier("Apps")); | |
| 14 EXPECT_EQ(app::VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("Nonsense")); | |
| 15 } | |
| 16 | |
| 17 TEST(KeyCodeFromKeyIdentifierTest, MatchOnCharacter) { | |
| 18 EXPECT_EQ(app::VKEY_A, KeyCodeFromKeyIdentifier("a")); | |
| 19 EXPECT_EQ(app::VKEY_A, KeyCodeFromKeyIdentifier("A")); | |
| 20 EXPECT_EQ(app::VKEY_OEM_PERIOD, KeyCodeFromKeyIdentifier(">")); | |
| 21 | |
| 22 std::string non_printing_char(" "); | |
| 23 non_printing_char[0] = static_cast<char>(1); | |
| 24 EXPECT_EQ(app::VKEY_UNKNOWN, KeyCodeFromKeyIdentifier(non_printing_char)); | |
| 25 } | |
| 26 | |
| 27 TEST(KeyCodeFromKeyIdentifierTest, MatchOnUnicodeCodepoint) { | |
| 28 EXPECT_EQ(app::VKEY_A, KeyCodeFromKeyIdentifier("U+0041")); | |
| 29 EXPECT_EQ(app::VKEY_A, KeyCodeFromKeyIdentifier("U+0061")); | |
| 30 EXPECT_EQ(app::VKEY_DELETE, KeyCodeFromKeyIdentifier("U+007F")); | |
| 31 | |
| 32 // this one exists in the map, but has no valid VKEY | |
| 33 EXPECT_EQ(app::VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("U+030A")); | |
| 34 | |
| 35 // this one is not in the map | |
| 36 EXPECT_EQ(app::VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("U+0001")); | |
| 37 } | |
| 38 | |
| 39 TEST(KeyCodeFromKeyIdentifierTest, DoesNotMatchEmptyString) { | |
| 40 EXPECT_EQ(app::VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("")); | |
| 41 } | |
| 42 | |
| 43 } // namespace app | |
| OLD | NEW |