| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h" | 8 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chromeos/ime/component_extension_ime_manager.h" | 10 #include "chromeos/ime/component_extension_ime_manager.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // mode_indicator_delegate_view.cc. | 118 // mode_indicator_delegate_view.cc. |
| 119 const int kInnerSize = 43; | 119 const int kInnerSize = 43; |
| 120 } // namespace | 120 } // namespace |
| 121 | 121 |
| 122 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) { | 122 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) { |
| 123 InitializeIMF(); | 123 InitializeIMF(); |
| 124 | 124 |
| 125 InputMethodManager* imm = InputMethodManager::Get(); | 125 InputMethodManager* imm = InputMethodManager::Get(); |
| 126 ASSERT_TRUE(imm); | 126 ASSERT_TRUE(imm); |
| 127 | 127 |
| 128 std::vector<std::string> keyboard_layouts; |
| 129 keyboard_layouts.push_back("xkb:fr::fra"); |
| 130 |
| 128 // Add keyboard layouts to enable the mode indicator. | 131 // Add keyboard layouts to enable the mode indicator. |
| 129 imm->EnableLoginLayouts("fr", "xkb:fr::fra"); | 132 imm->EnableLoginLayouts("fr", keyboard_layouts); |
| 130 ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); | 133 ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); |
| 131 | 134 |
| 132 chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = | 135 chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = |
| 133 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); | 136 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); |
| 134 candidate_window->FocusStateChanged(true); | 137 candidate_window->FocusStateChanged(true); |
| 135 | 138 |
| 136 // Check if the size of the mode indicator is expected. | 139 // Check if the size of the mode indicator is expected. |
| 137 gfx::Rect cursor1_bounds(100, 100, 1, 20); | 140 gfx::Rect cursor1_bounds(100, 100, 1, 20); |
| 138 gfx::Rect mi1_bounds; | 141 gfx::Rect mi1_bounds; |
| 139 { | 142 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 EXPECT_LT(mi3_bounds.bottom(), screen_bounds.bottom()); | 185 EXPECT_LT(mi3_bounds.bottom(), screen_bounds.bottom()); |
| 183 } | 186 } |
| 184 } | 187 } |
| 185 | 188 |
| 186 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) { | 189 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) { |
| 187 InitializeIMF(); | 190 InitializeIMF(); |
| 188 | 191 |
| 189 InputMethodManager* imm = InputMethodManager::Get(); | 192 InputMethodManager* imm = InputMethodManager::Get(); |
| 190 ASSERT_TRUE(imm); | 193 ASSERT_TRUE(imm); |
| 191 | 194 |
| 195 std::vector<std::string> keyboard_layouts; |
| 196 keyboard_layouts.push_back("xkb:fr::fra"); |
| 197 |
| 192 // Add keyboard layouts to enable the mode indicator. | 198 // Add keyboard layouts to enable the mode indicator. |
| 193 imm->EnableLoginLayouts("fr", "xkb:fr::fra"); | 199 imm->EnableLoginLayouts("fr", keyboard_layouts); |
| 194 ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); | 200 ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); |
| 195 | 201 |
| 196 chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = | 202 chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = |
| 197 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); | 203 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); |
| 198 candidate_window->FocusStateChanged(true); | 204 candidate_window->FocusStateChanged(true); |
| 199 | 205 |
| 200 { | 206 { |
| 201 ScopedModeIndicatorObserverForTesting observer; | 207 ScopedModeIndicatorObserverForTesting observer; |
| 202 | 208 |
| 203 EXPECT_TRUE(imm->SwitchToNextInputMethod()); | 209 EXPECT_TRUE(imm->SwitchToNextInputMethod()); |
| 204 EXPECT_EQ(1UL, observer.max_widget_list_size()); | 210 EXPECT_EQ(1UL, observer.max_widget_list_size()); |
| 205 const views::Widget* widget1 = observer.widget_list()[0]; | 211 const views::Widget* widget1 = observer.widget_list()[0]; |
| 206 | 212 |
| 207 EXPECT_TRUE(imm->SwitchToNextInputMethod()); | 213 EXPECT_TRUE(imm->SwitchToNextInputMethod()); |
| 208 EXPECT_EQ(2UL, observer.max_widget_list_size()); | 214 EXPECT_EQ(2UL, observer.max_widget_list_size()); |
| 209 | 215 |
| 210 // When a new mode indicator is displayed, the previous one should be | 216 // When a new mode indicator is displayed, the previous one should be |
| 211 // closed. | 217 // closed. |
| 212 content::RunAllPendingInMessageLoop(); | 218 content::RunAllPendingInMessageLoop(); |
| 213 EXPECT_EQ(1UL, observer.widget_list_size()); | 219 EXPECT_EQ(1UL, observer.widget_list_size()); |
| 214 const views::Widget* widget2 = observer.widget_list()[0]; | 220 const views::Widget* widget2 = observer.widget_list()[0]; |
| 215 EXPECT_NE(widget1, widget2); | 221 EXPECT_NE(widget1, widget2); |
| 216 } | 222 } |
| 217 } | 223 } |
| 218 } // namespace input_method | 224 } // namespace input_method |
| 219 } // namespace chromeos | 225 } // namespace chromeos |
| OLD | NEW |