| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  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   // Add keyboard layouts to enable the mode indicator. |  128   // Add keyboard layouts to enable the mode indicator. | 
|  129   imm->EnableLayouts("fr", "xkb:fr::fra"); |  129   imm->EnableLayouts("fr", "xkb:fr::fra", true); | 
|  130   ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); |  130   ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); | 
|  131  |  131  | 
|  132   chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = |  132   chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = | 
|  133       chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); |  133       chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); | 
|  134   candidate_window->FocusStateChanged(true); |  134   candidate_window->FocusStateChanged(true); | 
|  135  |  135  | 
|  136   // Check if the size of the mode indicator is expected. |  136   // Check if the size of the mode indicator is expected. | 
|  137   gfx::Rect cursor1_bounds(100, 100, 1, 20); |  137   gfx::Rect cursor1_bounds(100, 100, 1, 20); | 
|  138   gfx::Rect mi1_bounds; |  138   gfx::Rect mi1_bounds; | 
|  139   { |  139   { | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  183   } |  183   } | 
|  184 } |  184 } | 
|  185  |  185  | 
|  186 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) { |  186 IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) { | 
|  187   InitializeIMF(); |  187   InitializeIMF(); | 
|  188  |  188  | 
|  189   InputMethodManager* imm = InputMethodManager::Get(); |  189   InputMethodManager* imm = InputMethodManager::Get(); | 
|  190   ASSERT_TRUE(imm); |  190   ASSERT_TRUE(imm); | 
|  191  |  191  | 
|  192   // Add keyboard layouts to enable the mode indicator. |  192   // Add keyboard layouts to enable the mode indicator. | 
|  193   imm->EnableLayouts("fr", "xkb:fr::fra"); |  193   imm->EnableLayouts("fr", "xkb:fr::fra", true); | 
|  194   ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); |  194   ASSERT_LT(1UL, imm->GetNumActiveInputMethods()); | 
|  195  |  195  | 
|  196   chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = |  196   chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = | 
|  197       chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); |  197       chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); | 
|  198   candidate_window->FocusStateChanged(true); |  198   candidate_window->FocusStateChanged(true); | 
|  199  |  199  | 
|  200   { |  200   { | 
|  201     ScopedModeIndicatorObserverForTesting observer; |  201     ScopedModeIndicatorObserverForTesting observer; | 
|  202  |  202  | 
|  203     EXPECT_TRUE(imm->SwitchToNextInputMethod()); |  203     EXPECT_TRUE(imm->SwitchToNextInputMethod()); | 
|  204     EXPECT_EQ(1UL, observer.max_widget_list_size()); |  204     EXPECT_EQ(1UL, observer.max_widget_list_size()); | 
|  205     const views::Widget* widget1 = observer.widget_list()[0]; |  205     const views::Widget* widget1 = observer.widget_list()[0]; | 
|  206  |  206  | 
|  207     EXPECT_TRUE(imm->SwitchToNextInputMethod()); |  207     EXPECT_TRUE(imm->SwitchToNextInputMethod()); | 
|  208     EXPECT_EQ(2UL, observer.max_widget_list_size()); |  208     EXPECT_EQ(2UL, observer.max_widget_list_size()); | 
|  209  |  209  | 
|  210     // When a new mode indicator is displayed, the previous one should be |  210     // When a new mode indicator is displayed, the previous one should be | 
|  211     // closed. |  211     // closed. | 
|  212     content::RunAllPendingInMessageLoop(); |  212     content::RunAllPendingInMessageLoop(); | 
|  213     EXPECT_EQ(1UL, observer.widget_list_size()); |  213     EXPECT_EQ(1UL, observer.widget_list_size()); | 
|  214     const views::Widget* widget2 = observer.widget_list()[0]; |  214     const views::Widget* widget2 = observer.widget_list()[0]; | 
|  215     EXPECT_NE(widget1, widget2); |  215     EXPECT_NE(widget1, widget2); | 
|  216   } |  216   } | 
|  217 } |  217 } | 
|  218 }  // namespace input_method |  218 }  // namespace input_method | 
|  219 }  // namespace chromeos |  219 }  // namespace chromeos | 
| OLD | NEW |