1 // Copyright 2013 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/base/accelerators/menu_label_accelerator_util_linux.h"
7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(MenuLabelAcceleratorTest
, ConvertAcceleratorsFromWindowsStyle
) {
18 { "nothing", "nothing" },
19 { "foo &bar", "foo _bar" },
20 { "foo &&bar", "foo &bar" },
21 { "foo &&&bar", "foo &_bar" },
22 { "&foo &&bar", "_foo &bar" },
23 { "&foo &bar", "_foo _bar" },
25 for (size_t i
= 0; i
< arraysize(cases
); ++i
) {
26 std::string result
= ConvertAcceleratorsFromWindowsStyle(cases
[i
].input
);
27 EXPECT_EQ(cases
[i
].output
, result
);
31 TEST(MenuLabelAcceleratorTest
, RemoveWindowsStyleAccelerators
) {
37 { "nothing", "nothing" },
38 { "foo &bar", "foo bar" },
39 { "foo &&bar", "foo &bar" },
40 { "foo &&&bar", "foo &bar" },
41 { "&foo &&bar", "foo &bar" },
42 { "&foo &bar", "foo bar" },
44 for (size_t i
= 0; i
< arraysize(cases
); ++i
) {
45 std::string result
= RemoveWindowsStyleAccelerators(cases
[i
].input
);
46 EXPECT_EQ(cases
[i
].output
, result
);
50 TEST(MenuLabelAcceleratorTest
, EscapeWindowsStyleAccelerators
) {
55 { "nothing", "nothing" },
56 { "foo &bar", "foo &&bar" },
57 { "foo &&bar", "foo &&&&bar" },
58 { "foo &&&bar", "foo &&&&&&bar" },
59 { "&foo bar", "&&foo bar" },
60 { "&&foo bar", "&&&&foo bar" },
61 { "&&&foo bar", "&&&&&&foo bar" },
62 { "&foo &bar", "&&foo &&bar" },
63 { "&&foo &&bar", "&&&&foo &&&&bar" },
64 { "f&o&o ba&r", "f&&o&&o ba&&r" },
65 { "foo_&_bar", "foo_&&_bar" },
66 { "&_foo_bar_&", "&&_foo_bar_&&" },
69 for (size_t i
= 0; i
< arraysize(cases
); ++i
) {
70 std::string result
= EscapeWindowsStyleAccelerators(cases
[i
].input
);
71 EXPECT_EQ(cases
[i
].output
, result
);