File: unicode_to_keysym_unittest.cc

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (50 lines) | stat: -rw-r--r-- 1,471 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/linux/unicode_to_keysym.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>

#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace remoting {

TEST(GetKeySymsForUnicode, Map) {
  const static struct Test {
    uint32_t code_point;
    uint32_t expected_keysyms[4];
  } kTests[] = {
    { 0x0040, { 0x0040, 0x01000040, 0 } },
    { 0x00b0, { 0x00b0, 0x010000b0, 0 } },
    { 0x0100, { 0x03c0, 0x01000100, 0 } },
    { 0x038e, { 0x07a8, 0x0100038e, 0 } },
    { 0x22a3, { 0x0bdc, 0x010022a3, 0 } },
    { 0x30bd, { 0x04bf, 0x010030bd, 0 } },
    { 0x3171, { 0x0ef0, 0x01003171, 0 } },
    { 0x318e, { 0x0ef7, 0x0100318e, 0 } },

    // Characters with 3 distinct keysyms.
    { 0x0030, { 0x0030, 0xffb0, 0x01000030, 0 } },
    { 0x005f, { 0x005f, 0x0bc6, 0x0100005f, 0 } },

    // Characters for which there are no regular keysyms.
    { 0x4444, { 0x01004444, 0 } },
  };

  for (size_t i = 0; i < arraysize(kTests); ++i) {
    std::vector<uint32_t> keysyms = GetKeySymsForUnicode(kTests[i].code_point);

    std::vector<uint32_t> expected(
        kTests[i].expected_keysyms,
        std::find(
            kTests[i].expected_keysyms, kTests[i].expected_keysyms + 4, 0));
    EXPECT_EQ(expected, keysyms);
  }
}

}  // namespace remoting