gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / ui / gfx / text_utils_unittest.cc
blob1090b388b0488db951dc3b00f995d4c63af303ae
1 // Copyright (c) 2011 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 "ui/gfx/text_utils.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace gfx {
11 namespace {
13 const char16 kAcceleratorChar = '&';
15 TEST(TextUtilsTest, RemoveAcceleratorChar) {
16 struct TestData {
17 const char* input;
18 int accelerated_char_pos;
19 int accelerated_char_span;
20 const char* output;
21 } cases[] = {
22 { "", -1, 0, "" },
23 { "&", -1, 0, "" },
24 { "no accelerator", -1, 0, "no accelerator" },
25 { "&one accelerator", 0, 1, "one accelerator" },
26 { "one &accelerator", 4, 1, "one accelerator" },
27 { "one_accelerator&", -1, 0, "one_accelerator" },
28 { "&two &accelerators", 4, 1, "two accelerators" },
29 { "two &accelerators&", 4, 1, "two accelerators" },
30 { "two& &accelerators", 4, 1, "two accelerators" },
31 { "&&escaping", -1, 0, "&escaping" },
32 { "escap&&ing", -1, 0, "escap&ing" },
33 { "escaping&&", -1, 0, "escaping&" },
34 { "&mix&&ed", 0, 1, "mix&ed" },
35 { "&&m&ix&&e&d&", 6, 1, "&mix&ed" },
36 { "&&m&&ix&ed&&", 5, 1, "&m&ixed&" },
37 { "&m&&ix&ed&&", 4, 1, "m&ixed&" },
38 // U+1D49C MATHEMATICAL SCRIPT CAPITAL A, which occupies two |char16|'s.
39 { "&\xF0\x9D\x92\x9C", 0, 2, "\xF0\x9D\x92\x9C" },
40 { "Test&\xF0\x9D\x92\x9Cing", 4, 2, "Test\xF0\x9D\x92\x9Cing" },
41 { "Test\xF0\x9D\x92\x9C&ing", 6, 1, "Test\xF0\x9D\x92\x9Cing" },
42 { "Test&\xF0\x9D\x92\x9C&ing", 6, 1, "Test\xF0\x9D\x92\x9Cing" },
43 { "Test&\xF0\x9D\x92\x9C&&ing", 4, 2, "Test\xF0\x9D\x92\x9C&ing" },
44 { "Test&\xF0\x9D\x92\x9C&\xF0\x9D\x92\x9Cing", 6, 2,
45 "Test\xF0\x9D\x92\x9C\xF0\x9D\x92\x9Cing" },
48 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
49 int accelerated_char_pos;
50 int accelerated_char_span;
51 base::string16 result = RemoveAcceleratorChar(UTF8ToUTF16(cases[i].input),
52 kAcceleratorChar,
53 &accelerated_char_pos,
54 &accelerated_char_span);
55 EXPECT_EQ(result, UTF8ToUTF16(cases[i].output));
56 EXPECT_EQ(accelerated_char_pos, cases[i].accelerated_char_pos);
57 EXPECT_EQ(accelerated_char_span, cases[i].accelerated_char_span);
61 } // namespace
62 } // namespace gfx