| OLD | NEW |
| 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 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 14 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 15 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
| 15 #include "content/test/test_browser_thread.h" | 16 #include "content/test/test_browser_thread.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/base/x/x11_util.h" | 18 #include "ui/base/x/x11_util.h" |
| 18 | 19 |
| 19 #include <X11/Xlib.h> | 20 #include <X11/Xlib.h> |
| 20 | 21 |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 | 23 |
| 23 #if defined(USE_VIRTUAL_KEYBOARD) | 24 #if defined(USE_VIRTUAL_KEYBOARD) |
| 24 // Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we | 25 // Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we |
| 25 // skip the tests for now. | 26 // skip the tests for now. |
| 26 #define TestCreateFullXkbLayoutNameKeepAlt \ | 27 #define TestCreateFullXkbLayoutNameKeepAlt \ |
| 27 DISABLED_TestCreateFullXkbLayoutNameKeepAlt | 28 DISABLED_TestCreateFullXkbLayoutNameKeepAlt |
| 28 #define TestCreateFullXkbLayoutNameKeepCapsLock \ | 29 #define TestCreateFullXkbLayoutNameKeepCapsLock \ |
| 29 DISABLED_TestCreateFullXkbLayoutNameKeepCapsLock | 30 DISABLED_TestCreateFullXkbLayoutNameKeepCapsLock |
| 30 #endif // USE_VIRTUAL_KEYBOARD | 31 #endif // USE_VIRTUAL_KEYBOARD |
| 31 | 32 |
| 32 namespace chromeos { | 33 namespace chromeos { |
| 33 namespace input_method { | 34 namespace input_method { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 class XKeyboardTest : public testing::Test { | 38 class XKeyboardTest : public testing::Test { |
| 38 public: | 39 public: |
| 39 XKeyboardTest() | 40 XKeyboardTest() |
| 40 : controller_(IBusController::Create()), | 41 : util_(whitelist_.GetSupportedInputMethods()), |
| 41 util_(controller_->GetSupportedInputMethods()), | |
| 42 ui_thread_(BrowserThread::UI, &message_loop_) { | 42 ui_thread_(BrowserThread::UI, &message_loop_) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual void SetUp() { | 45 virtual void SetUp() { |
| 46 xkey_.reset(XKeyboard::Create(util_)); | 46 xkey_.reset(XKeyboard::Create(util_)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void TearDown() { | 49 virtual void TearDown() { |
| 50 xkey_.reset(); | 50 xkey_.reset(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 scoped_ptr<IBusController> controller_; | 53 InputMethodWhitelist whitelist_; |
| 54 InputMethodUtil util_; | 54 InputMethodUtil util_; |
| 55 scoped_ptr<XKeyboard> xkey_; | 55 scoped_ptr<XKeyboard> xkey_; |
| 56 | 56 |
| 57 MessageLoopForUI message_loop_; | 57 MessageLoopForUI message_loop_; |
| 58 content::TestBrowserThread ui_thread_; | 58 content::TestBrowserThread ui_thread_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Returns a ModifierMap object that contains the following mapping: | 61 // Returns a ModifierMap object that contains the following mapping: |
| 62 // - kSearchKey is mapped to |search|. | 62 // - kSearchKey is mapped to |search|. |
| 63 // - kLeftControl key is mapped to |control|. | 63 // - kLeftControl key is mapped to |control|. |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 // Restore the initial state. | 407 // Restore the initial state. |
| 408 EXPECT_TRUE(XKeyboard::SetAutoRepeatRate(rate)); | 408 EXPECT_TRUE(XKeyboard::SetAutoRepeatRate(rate)); |
| 409 EXPECT_TRUE(XKeyboard::GetAutoRepeatRateForTesting(&tmp)); | 409 EXPECT_TRUE(XKeyboard::GetAutoRepeatRateForTesting(&tmp)); |
| 410 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms); | 410 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms); |
| 411 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms); | 411 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms); |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace input_method | 414 } // namespace input_method |
| 415 } // namespace chromeos | 415 } // namespace chromeos |
| OLD | NEW |