Home | History | Annotate | Download | only in linux
      1 // Copyright 2014 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 "remoting/host/linux/unicode_to_keysym.h"
      6 
      7 #include <algorithm>
      8 
      9 #include "base/macros.h"
     10 #include "testing/gtest/include/gtest/gtest.h"
     11 
     12 namespace remoting {
     13 
     14 TEST(GetKeySymsForUnicode, Map) {
     15   const static struct Test {
     16     uint32_t code_point;
     17     uint32_t expected_keysyms[4];
     18   } kTests[] = {
     19     { 0x0040, { 0x0040, 0x01000040, 0 } },
     20     { 0x00b0, { 0x00b0, 0x010000b0, 0 } },
     21     { 0x0100, { 0x03c0, 0x01000100, 0 } },
     22     { 0x038e, { 0x07a8, 0x0100038e, 0 } },
     23     { 0x22a3, { 0x0bdc, 0x010022a3, 0 } },
     24     { 0x30bd, { 0x04bf, 0x010030bd, 0 } },
     25     { 0x3171, { 0x0ef0, 0x01003171, 0 } },
     26     { 0x318e, { 0x0ef7, 0x0100318e, 0 } },
     27 
     28     // Characters with 3 distinct keysyms.
     29     { 0x0030, { 0x0030, 0xffb0, 0x01000030, 0 } },
     30     { 0x005f, { 0x005f, 0x0bc6, 0x0100005f, 0 } },
     31 
     32     // Characters for which there are no regular keysyms.
     33     { 0x4444, { 0x01004444, 0 } },
     34   };
     35 
     36   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) {
     37     std::vector<uint32_t> keysyms;
     38     GetKeySymsForUnicode(kTests[i].code_point, &keysyms);
     39 
     40     std::vector<uint32_t> expected(
     41         kTests[i].expected_keysyms,
     42         std::find(
     43             kTests[i].expected_keysyms, kTests[i].expected_keysyms + 4, 0));
     44     EXPECT_EQ(expected, keysyms);
     45   }
     46 }
     47 
     48 }  // namespace remoting
     49