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

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

Issue 8497003: Add unit tests for SetAutoRepeatEnabled and SetAutoRepeatRate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 24 matching lines...) Expand all
35 namespace { 35 namespace {
36 36
37 class TestableXKeyboard : public XKeyboard { 37 class TestableXKeyboard : public XKeyboard {
38 public: 38 public:
39 explicit TestableXKeyboard(const InputMethodUtil& util) : XKeyboard(util) { 39 explicit TestableXKeyboard(const InputMethodUtil& util) : XKeyboard(util) {
40 } 40 }
41 41
42 // Change access rights. 42 // Change access rights.
43 using XKeyboard::CreateFullXkbLayoutName; 43 using XKeyboard::CreateFullXkbLayoutName;
44 using XKeyboard::ContainsModifierKeyAsReplacement; 44 using XKeyboard::ContainsModifierKeyAsReplacement;
45 using XKeyboard::GetAutoRepeatEnabled;
46 using XKeyboard::GetAutoRepeatRate;
45 }; 47 };
46 48
47 class XKeyboardTest : public testing::Test { 49 class XKeyboardTest : public testing::Test {
48 public: 50 public:
49 XKeyboardTest() 51 XKeyboardTest()
50 : controller_(IBusController::Create()), 52 : controller_(IBusController::Create()),
51 util_(controller_->GetSupportedInputMethods()), 53 util_(controller_->GetSupportedInputMethods()),
52 ui_thread_(BrowserThread::UI, &message_loop_) { 54 ui_thread_(BrowserThread::UI, &message_loop_) {
53 } 55 }
54 56
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement( 348 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement(
347 GetMap(kVoidKey, kVoidKey, kCapsLockKey), kCapsLockKey)); 349 GetMap(kVoidKey, kVoidKey, kCapsLockKey), kCapsLockKey));
348 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement( 350 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement(
349 GetMap(kCapsLockKey, kCapsLockKey, kVoidKey), kCapsLockKey)); 351 GetMap(kCapsLockKey, kCapsLockKey, kVoidKey), kCapsLockKey));
350 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement( 352 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement(
351 GetMap(kCapsLockKey, kCapsLockKey, kCapsLockKey), kCapsLockKey)); 353 GetMap(kCapsLockKey, kCapsLockKey, kCapsLockKey), kCapsLockKey));
352 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement( 354 EXPECT_TRUE(TestableXKeyboard::ContainsModifierKeyAsReplacement(
353 GetMap(kSearchKey, kVoidKey, kVoidKey), kSearchKey)); 355 GetMap(kSearchKey, kVoidKey, kVoidKey), kSearchKey));
354 } 356 }
355 357
358 TEST_F(XKeyboardTest, TestSetAutoRepeatEnabled) {
359 if (!DisplayAvailable()) {
Zachary Kuznia 2011/11/08 03:55:17 Should this fail the test?
Yusuke Sato 2011/11/13 23:24:56 The intension of this check is that to allow devel
360 return;
361 }
362 const bool state = TestableXKeyboard::GetAutoRepeatEnabled();
363 TestableXKeyboard::SetAutoRepeatEnabled(!state);
364 EXPECT_EQ(!state, TestableXKeyboard::GetAutoRepeatEnabled());
365 // Restore the initial state.
366 TestableXKeyboard::SetAutoRepeatEnabled(state);
367 EXPECT_EQ(state, TestableXKeyboard::GetAutoRepeatEnabled());
368 }
369
370 TEST_F(XKeyboardTest, TestSetAutoRepeatRate) {
371 if (!DisplayAvailable()) {
Zachary Kuznia 2011/11/08 03:55:17 ditto
Yusuke Sato 2011/11/13 23:24:56 the same as above.
372 return;
373 }
374 AutoRepeatRate rate;
375 EXPECT_TRUE(TestableXKeyboard::GetAutoRepeatRate(&rate));
376
377 AutoRepeatRate tmp(rate);
378 ++tmp.initial_delay_in_ms;
379 ++tmp.repeat_interval_in_ms;
380 EXPECT_TRUE(TestableXKeyboard::SetAutoRepeatRate(tmp));
381 EXPECT_TRUE(TestableXKeyboard::GetAutoRepeatRate(&tmp));
382 EXPECT_EQ(rate.initial_delay_in_ms + 1, tmp.initial_delay_in_ms);
383 EXPECT_EQ(rate.repeat_interval_in_ms + 1, tmp.repeat_interval_in_ms);
384
385 // Restore the initial state.
386 EXPECT_TRUE(TestableXKeyboard::SetAutoRepeatRate(rate));
387 EXPECT_TRUE(TestableXKeyboard::GetAutoRepeatRate(&tmp));
388 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms);
389 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms);
390 }
391
356 } // namespace input_method 392 } // namespace input_method
357 } // namespace chromeos 393 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698