Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: ui/base/gtk/menu_label_accelerator_util_unittest.cc

Issue 10316013: linux: Move linux_util.h from gfx/ to ui/base/gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: LinuxUtilTest -> MenuLabelAcceleratorTest Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/gtk/menu_label_accelerator_util.cc ('k') | ui/gfx/linux_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/linux_util.h" 5 #include "ui/base/gtk/menu_label_accelerator_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace gfx { 10 namespace ui {
11 11
12 TEST(LinuxUtilTest, ConvertAcceleratorsFromWindowsStyle) { 12 TEST(MenuLabelAcceleratorTest, ConvertAcceleratorsFromWindowsStyle) {
13 static const struct { 13 static const struct {
14 const char* input; 14 const char* input;
15 const char* output; 15 const char* output;
16 } cases[] = { 16 } cases[] = {
17 { "", "" }, 17 { "", "" },
18 { "nothing", "nothing" }, 18 { "nothing", "nothing" },
19 { "foo &bar", "foo _bar" }, 19 { "foo &bar", "foo _bar" },
20 { "foo &&bar", "foo &bar" }, 20 { "foo &&bar", "foo &bar" },
21 { "foo &&&bar", "foo &_bar" }, 21 { "foo &&&bar", "foo &_bar" },
22 { "&foo &&bar", "_foo &bar" }, 22 { "&foo &&bar", "_foo &bar" },
23 { "&foo &bar", "_foo _bar" }, 23 { "&foo &bar", "_foo _bar" },
24 }; 24 };
25 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 25 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
26 std::string result = ConvertAcceleratorsFromWindowsStyle(cases[i].input); 26 std::string result = ConvertAcceleratorsFromWindowsStyle(cases[i].input);
27 EXPECT_EQ(cases[i].output, result); 27 EXPECT_EQ(cases[i].output, result);
28 } 28 }
29 } 29 }
30 30
31 TEST(LinuxUtilTest, RemoveWindowsStyleAccelerators) { 31 TEST(MenuLabelAcceleratorTest, RemoveWindowsStyleAccelerators) {
32 static const struct { 32 static const struct {
33 const char* input; 33 const char* input;
34 const char* output; 34 const char* output;
35 } cases[] = { 35 } cases[] = {
36 { "", "" }, 36 { "", "" },
37 { "nothing", "nothing" }, 37 { "nothing", "nothing" },
38 { "foo &bar", "foo bar" }, 38 { "foo &bar", "foo bar" },
39 { "foo &&bar", "foo &bar" }, 39 { "foo &&bar", "foo &bar" },
40 { "foo &&&bar", "foo &bar" }, 40 { "foo &&&bar", "foo &bar" },
41 { "&foo &&bar", "foo &bar" }, 41 { "&foo &&bar", "foo &bar" },
42 { "&foo &bar", "foo bar" }, 42 { "&foo &bar", "foo bar" },
43 }; 43 };
44 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 44 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
45 std::string result = RemoveWindowsStyleAccelerators(cases[i].input); 45 std::string result = RemoveWindowsStyleAccelerators(cases[i].input);
46 EXPECT_EQ(cases[i].output, result); 46 EXPECT_EQ(cases[i].output, result);
47 } 47 }
48 } 48 }
49 49
50 TEST(LinuxUtilTest, EscapeWindowsStyleAccelerators) { 50 TEST(MenuLabelAcceleratorTest, EscapeWindowsStyleAccelerators) {
51 static const struct { 51 static const struct {
52 const char* input; 52 const char* input;
53 const char* output; 53 const char* output;
54 } cases[] = { 54 } cases[] = {
55 { "nothing", "nothing" }, 55 { "nothing", "nothing" },
56 { "foo &bar", "foo &&bar" }, 56 { "foo &bar", "foo &&bar" },
57 { "foo &&bar", "foo &&&&bar" }, 57 { "foo &&bar", "foo &&&&bar" },
58 { "foo &&&bar", "foo &&&&&&bar" }, 58 { "foo &&&bar", "foo &&&&&&bar" },
59 { "&foo bar", "&&foo bar" }, 59 { "&foo bar", "&&foo bar" },
60 { "&&foo bar", "&&&&foo bar" }, 60 { "&&foo bar", "&&&&foo bar" },
61 { "&&&foo bar", "&&&&&&foo bar" }, 61 { "&&&foo bar", "&&&&&&foo bar" },
62 { "&foo &bar", "&&foo &&bar" }, 62 { "&foo &bar", "&&foo &&bar" },
63 { "&&foo &&bar", "&&&&foo &&&&bar" }, 63 { "&&foo &&bar", "&&&&foo &&&&bar" },
64 { "f&o&o ba&r", "f&&o&&o ba&&r" }, 64 { "f&o&o ba&r", "f&&o&&o ba&&r" },
65 { "foo_&_bar", "foo_&&_bar" }, 65 { "foo_&_bar", "foo_&&_bar" },
66 { "&_foo_bar_&", "&&_foo_bar_&&" }, 66 { "&_foo_bar_&", "&&_foo_bar_&&" },
67 }; 67 };
68 68
69 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 69 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
70 std::string result = EscapeWindowsStyleAccelerators(cases[i].input); 70 std::string result = EscapeWindowsStyleAccelerators(cases[i].input);
71 EXPECT_EQ(cases[i].output, result); 71 EXPECT_EQ(cases[i].output, result);
72 } 72 }
73 } 73 }
74 74
75 } // namespace gfx 75 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/gtk/menu_label_accelerator_util.cc ('k') | ui/gfx/linux_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698