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

Side by Side Diff: chrome/browser/chromeos/input_method/xkeyboard_unittest.cc

Issue 10456055: Stop using "+chromeos(...)" in an XKB layout name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « chrome/browser/chromeos/input_method/xkeyboard.cc ('k') | no next file » | 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 "chrome/browser/chromeos/input_method/xkeyboard.h" 5 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 content::TestBrowserThread ui_thread_; 49 content::TestBrowserThread ui_thread_;
50 }; 50 };
51 51
52 // Returns true if X display is available. 52 // Returns true if X display is available.
53 bool DisplayAvailable() { 53 bool DisplayAvailable() {
54 return ui::GetXDisplay() ? true : false; 54 return ui::GetXDisplay() ? true : false;
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 // Tests CreateFullXkbLayoutName() function. 59 // Tests CheckLayoutName() function.
60 TEST_F(XKeyboardTest, TestCreateFullXkbLayoutNameBasic) { 60 TEST_F(XKeyboardTest, TestCheckLayoutName) {
61 // CreateFullXkbLayoutName should not accept non-alphanumeric characters 61 // CheckLayoutName should not accept non-alphanumeric characters
62 // except "()-_". 62 // except "()-_".
63 EXPECT_EQ("", xkey_->CreateFullXkbLayoutName("us!")); 63 EXPECT_FALSE(XKeyboard::CheckLayoutNameForTesting("us!"));
64 EXPECT_EQ("", xkey_->CreateFullXkbLayoutName("us; /bin/sh")); 64 EXPECT_FALSE(XKeyboard::CheckLayoutNameForTesting("us; /bin/sh"));
65 EXPECT_EQ("ab-c_12+chromeos(search_leftcontrol_leftalt_keepralt)", 65 EXPECT_TRUE(XKeyboard::CheckLayoutNameForTesting("ab-c_12"));
66 xkey_->CreateFullXkbLayoutName("ab-c_12"));
67 66
68 // CreateFullXkbLayoutName should not accept upper-case ascii characters. 67 // CheckLayoutName should not accept upper-case ascii characters.
69 EXPECT_EQ("", xkey_->CreateFullXkbLayoutName("US")); 68 EXPECT_FALSE(XKeyboard::CheckLayoutNameForTesting("US"));
70 69
71 // CreateFullXkbLayoutName should accept lower-case ascii characters. 70 // CheckLayoutName should accept lower-case ascii characters.
72 for (int c = 'a'; c <= 'z'; ++c) { 71 for (int c = 'a'; c <= 'z'; ++c) {
73 EXPECT_NE("", xkey_->CreateFullXkbLayoutName(std::string(3, c))); 72 EXPECT_TRUE(XKeyboard::CheckLayoutNameForTesting(std::string(3, c)));
74 } 73 }
75 74
76 // CreateFullXkbLayoutName should accept numbers. 75 // CheckLayoutName should accept numbers.
77 for (int c = '0'; c <= '9'; ++c) { 76 for (int c = '0'; c <= '9'; ++c) {
78 EXPECT_NE("", xkey_->CreateFullXkbLayoutName(std::string(3, c))); 77 EXPECT_TRUE(XKeyboard::CheckLayoutNameForTesting(std::string(3, c)));
79 } 78 }
80 79
81 // CreateFullXkbLayoutName should accept a layout with a variant name. 80 // CheckLayoutName should accept a layout with a variant name.
82 EXPECT_EQ("us(dvorak)+chromeos(search_leftcontrol_leftalt_keepralt)", 81 EXPECT_TRUE(XKeyboard::CheckLayoutNameForTesting("us(dvorak)"));
83 xkey_->CreateFullXkbLayoutName("us(dvorak)")); 82 EXPECT_TRUE(XKeyboard::CheckLayoutNameForTesting("jp"));
84 EXPECT_EQ("jp+chromeos(search_leftcontrol_leftalt_keepralt)",
85 xkey_->CreateFullXkbLayoutName("jp"));
86 } 83 }
87 84
88 TEST_F(XKeyboardTest, TestSetCapsLockEnabled) { 85 TEST_F(XKeyboardTest, TestSetCapsLockEnabled) {
89 if (!DisplayAvailable()) { 86 if (!DisplayAvailable()) {
90 // Do not fail the test to allow developers to run unit_tests without an X 87 // Do not fail the test to allow developers to run unit_tests without an X
91 // server (e.g. via ssh). Note that both try bots and waterfall always have 88 // server (e.g. via ssh). Note that both try bots and waterfall always have
92 // an X server for running browser_tests. 89 // an X server for running browser_tests.
93 DVLOG(1) << "X server is not available. Skip the test."; 90 DVLOG(1) << "X server is not available. Skip the test.";
94 return; 91 return;
95 } 92 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 212
216 // Restore the initial state. 213 // Restore the initial state.
217 EXPECT_TRUE(XKeyboard::SetAutoRepeatRate(rate)); 214 EXPECT_TRUE(XKeyboard::SetAutoRepeatRate(rate));
218 EXPECT_TRUE(XKeyboard::GetAutoRepeatRateForTesting(&tmp)); 215 EXPECT_TRUE(XKeyboard::GetAutoRepeatRateForTesting(&tmp));
219 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms); 216 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms);
220 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms); 217 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms);
221 } 218 }
222 219
223 } // namespace input_method 220 } // namespace input_method
224 } // namespace chromeos 221 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/xkeyboard.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698