| 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 "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
| 16 #include "chrome/browser/chromeos/input_method/mock_input_method_delegate.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
| 19 | 20 |
| 20 #include <X11/Xlib.h> | 21 #include <X11/Xlib.h> |
| 21 | 22 |
| 22 using content::BrowserThread; | 23 using content::BrowserThread; |
| 23 | 24 |
| 24 namespace chromeos { | 25 namespace chromeos { |
| 25 namespace input_method { | 26 namespace input_method { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 class XKeyboardTest : public testing::Test { | 30 class XKeyboardTest : public testing::Test { |
| 30 public: | 31 public: |
| 31 XKeyboardTest() | 32 XKeyboardTest() |
| 32 : util_(whitelist_.GetSupportedInputMethods()), | 33 : util_(&delegate_, whitelist_.GetSupportedInputMethods()), |
| 33 ui_thread_(BrowserThread::UI, &message_loop_) { | 34 ui_thread_(BrowserThread::UI, &message_loop_) { |
| 34 } | 35 } |
| 35 | 36 |
| 36 virtual void SetUp() { | 37 virtual void SetUp() { |
| 37 xkey_.reset(XKeyboard::Create(util_)); | 38 xkey_.reset(XKeyboard::Create(util_)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 virtual void TearDown() { | 41 virtual void TearDown() { |
| 41 xkey_.reset(); | 42 xkey_.reset(); |
| 42 } | 43 } |
| 43 | 44 |
| 45 MockInputMethodDelegate delegate_; |
| 44 InputMethodWhitelist whitelist_; | 46 InputMethodWhitelist whitelist_; |
| 45 InputMethodUtil util_; | 47 InputMethodUtil util_; |
| 46 scoped_ptr<XKeyboard> xkey_; | 48 scoped_ptr<XKeyboard> xkey_; |
| 47 | 49 |
| 48 MessageLoopForUI message_loop_; | 50 MessageLoopForUI message_loop_; |
| 49 content::TestBrowserThread ui_thread_; | 51 content::TestBrowserThread ui_thread_; |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 // Returns true if X display is available. | 54 // Returns true if X display is available. |
| 53 bool DisplayAvailable() { | 55 bool DisplayAvailable() { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 214 |
| 213 // Restore the initial state. | 215 // Restore the initial state. |
| 214 EXPECT_TRUE(XKeyboard::SetAutoRepeatRate(rate)); | 216 EXPECT_TRUE(XKeyboard::SetAutoRepeatRate(rate)); |
| 215 EXPECT_TRUE(XKeyboard::GetAutoRepeatRateForTesting(&tmp)); | 217 EXPECT_TRUE(XKeyboard::GetAutoRepeatRateForTesting(&tmp)); |
| 216 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms); | 218 EXPECT_EQ(rate.initial_delay_in_ms, tmp.initial_delay_in_ms); |
| 217 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms); | 219 EXPECT_EQ(rate.repeat_interval_in_ms, tmp.repeat_interval_in_ms); |
| 218 } | 220 } |
| 219 | 221 |
| 220 } // namespace input_method | 222 } // namespace input_method |
| 221 } // namespace chromeos | 223 } // namespace chromeos |
| OLD | NEW |