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

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

Issue 8497003: Add unit tests for SetAutoRepeatEnabled and SetAutoRepeatRate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, review fix 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 <queue> 7 #include <queue>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 XAutoRepeatOn(ui::GetXDisplay()); 348 XAutoRepeatOn(ui::GetXDisplay());
349 } else { 349 } else {
350 XAutoRepeatOff(ui::GetXDisplay()); 350 XAutoRepeatOff(ui::GetXDisplay());
351 } 351 }
352 DLOG(INFO) << "Set auto-repeat mode to: " << (enabled ? "on" : "off"); 352 DLOG(INFO) << "Set auto-repeat mode to: " << (enabled ? "on" : "off");
353 return true; 353 return true;
354 } 354 }
355 355
356 // static 356 // static
357 bool XKeyboard::SetAutoRepeatRate(const AutoRepeatRate& rate) { 357 bool XKeyboard::SetAutoRepeatRate(const AutoRepeatRate& rate) {
358 // TODO(yusukes): write auto tests for the function.
359 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 358 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
360 DLOG(INFO) << "Set auto-repeat rate to: " 359 DLOG(INFO) << "Set auto-repeat rate to: "
361 << rate.initial_delay_in_ms << " ms delay, " 360 << rate.initial_delay_in_ms << " ms delay, "
362 << rate.repeat_interval_in_ms << " ms interval"; 361 << rate.repeat_interval_in_ms << " ms interval";
363 if (XkbSetAutoRepeatRate(ui::GetXDisplay(), XkbUseCoreKbd, 362 if (XkbSetAutoRepeatRate(ui::GetXDisplay(), XkbUseCoreKbd,
364 rate.initial_delay_in_ms, 363 rate.initial_delay_in_ms,
365 rate.repeat_interval_in_ms) != True) { 364 rate.repeat_interval_in_ms) != True) {
366 LOG(ERROR) << "Failed to set auto-repeat rate"; 365 LOG(ERROR) << "Failed to set auto-repeat rate";
367 return false; 366 return false;
368 } 367 }
369 return true; 368 return true;
370 } 369 }
371 370
371 // static
372 bool XKeyboard::GetAutoRepeatEnabled() {
373 XKeyboardState state = {};
374 XGetKeyboardControl(ui::GetXDisplay(), &state);
375 return state.global_auto_repeat != AutoRepeatModeOff;
376 }
377
378 // static
379 bool XKeyboard::GetAutoRepeatRate(AutoRepeatRate* out_rate) {
380 return XkbGetAutoRepeatRate(ui::GetXDisplay(), XkbUseCoreKbd,
381 &(out_rate->initial_delay_in_ms),
382 &(out_rate->repeat_interval_in_ms)) == True;
383 }
384
372 void XKeyboard::SetLockedModifiers(ModifierLockStatus new_caps_lock_status, 385 void XKeyboard::SetLockedModifiers(ModifierLockStatus new_caps_lock_status,
373 ModifierLockStatus new_num_lock_status) { 386 ModifierLockStatus new_num_lock_status) {
374 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 387 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
375 if (!num_lock_mask_) { 388 if (!num_lock_mask_) {
376 LOG(ERROR) << "Cannot set locked modifiers. Num Lock mask unknown."; 389 LOG(ERROR) << "Cannot set locked modifiers. Num Lock mask unknown.";
377 return; 390 return;
378 } 391 }
379 392
380 unsigned int affect_mask = 0; 393 unsigned int affect_mask = 0;
381 unsigned int value_mask = 0; 394 unsigned int value_mask = 0;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 case kCapsLockKey: 529 case kCapsLockKey:
517 return "capslock"; 530 return "capslock";
518 case kNumModifierKeys: 531 case kNumModifierKeys:
519 break; 532 break;
520 } 533 }
521 return ""; 534 return "";
522 } 535 }
523 536
524 } // namespace input_method 537 } // namespace input_method
525 } // namespace chromeos 538 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/xkeyboard.h ('k') | chrome/browser/chromeos/input_method/xkeyboard_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698