Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / input_method / mode_indicator_browsertest.cc
index 7ec8b6f..5731558 100644 (file)
@@ -5,10 +5,13 @@
 #include <algorithm>
 
 #include "ash/shell.h"
+#include "chrome/browser/chromeos/input_method/input_method_util.h"
 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chromeos/ime/component_extension_ime_manager.h"
+#include "chromeos/ime/extension_ime_util.h"
 #include "chromeos/ime/input_method_manager.h"
+#include "chromeos/ime/input_method_whitelist.h"
 #include "content/public/test/browser_test_utils.h"
 #include "content/public/test/test_utils.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -96,16 +99,9 @@ class ModeIndicatorBrowserTest : public InProcessBrowserTest {
   }
 
   void InitializeIMF() {
-    // Make sure ComponentExtensionIMEManager is initialized.
-    // ComponentExtensionIMEManagerImpl::InitializeAsync posts
-    // ReadComponentExtensionsInfo to the FILE thread for the
-    // initialization.  If it is never initialized for some reasons,
-    // the test is timed out and failed.
-    ComponentExtensionIMEManager* ceimm =
-        InputMethodManager::Get()->GetComponentExtensionIMEManager();
-    while (!ceimm->IsInitialized()) {
-      content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
-    }
+    InputMethodManager::Get()
+        ->GetInputMethodUtil()
+        ->InitXkbInputMethodsForTesting();
   }
 
  private:
@@ -126,13 +122,14 @@ IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) {
   ASSERT_TRUE(imm);
 
   std::vector<std::string> keyboard_layouts;
-  keyboard_layouts.push_back("xkb:fr::fra");
+  keyboard_layouts.push_back(
+      extension_ime_util::GetInputMethodIDByEngineID("xkb:fr::fra"));
 
   // Add keyboard layouts to enable the mode indicator.
-  imm->EnableLoginLayouts("fr", keyboard_layouts);
-  ASSERT_LT(1UL, imm->GetNumActiveInputMethods());
+  imm->GetActiveIMEState()->EnableLoginLayouts("fr", keyboard_layouts);
+  ASSERT_LT(1UL, imm->GetActiveIMEState()->GetNumActiveInputMethods());
 
-  chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window =
+  chromeos::IMECandidateWindowHandlerInterface* candidate_window =
       chromeos::IMEBridge::Get()->GetCandidateWindowHandler();
   candidate_window->FocusStateChanged(true);
 
@@ -142,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) {
   {
     ScopedModeIndicatorObserverForTesting observer;
     candidate_window->SetCursorBounds(cursor1_bounds, cursor1_bounds);
-    EXPECT_TRUE(imm->SwitchToNextInputMethod());
+    EXPECT_TRUE(imm->GetActiveIMEState()->SwitchToNextInputMethod());
     mi1_bounds = observer.last_bounds();
     // The bounds should be bigger than the inner size.
     EXPECT_LE(kInnerSize, mi1_bounds.width());
@@ -157,7 +154,7 @@ IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) {
   {
     ScopedModeIndicatorObserverForTesting observer;
     candidate_window->SetCursorBounds(cursor2_bounds, cursor2_bounds);
-    EXPECT_TRUE(imm->SwitchToNextInputMethod());
+    EXPECT_TRUE(imm->GetActiveIMEState()->SwitchToNextInputMethod());
     mi2_bounds = observer.last_bounds();
     EXPECT_TRUE(observer.is_displayed());
   }
@@ -179,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, Bounds) {
   {
     ScopedModeIndicatorObserverForTesting observer;
     candidate_window->SetCursorBounds(cursor3_bounds, cursor3_bounds);
-    EXPECT_TRUE(imm->SwitchToNextInputMethod());
+    EXPECT_TRUE(imm->GetActiveIMEState()->SwitchToNextInputMethod());
     mi3_bounds = observer.last_bounds();
     EXPECT_TRUE(observer.is_displayed());
     EXPECT_LT(mi3_bounds.bottom(), screen_bounds.bottom());
@@ -193,24 +190,25 @@ IN_PROC_BROWSER_TEST_F(ModeIndicatorBrowserTest, NumOfWidgets) {
   ASSERT_TRUE(imm);
 
   std::vector<std::string> keyboard_layouts;
-  keyboard_layouts.push_back("xkb:fr::fra");
+  keyboard_layouts.push_back(
+      extension_ime_util::GetInputMethodIDByEngineID("xkb:fr::fra"));
 
   // Add keyboard layouts to enable the mode indicator.
-  imm->EnableLoginLayouts("fr", keyboard_layouts);
-  ASSERT_LT(1UL, imm->GetNumActiveInputMethods());
+  imm->GetActiveIMEState()->EnableLoginLayouts("fr", keyboard_layouts);
+  ASSERT_LT(1UL, imm->GetActiveIMEState()->GetNumActiveInputMethods());
 
-  chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window =
+  chromeos::IMECandidateWindowHandlerInterface* candidate_window =
       chromeos::IMEBridge::Get()->GetCandidateWindowHandler();
   candidate_window->FocusStateChanged(true);
 
   {
     ScopedModeIndicatorObserverForTesting observer;
 
-    EXPECT_TRUE(imm->SwitchToNextInputMethod());
+    EXPECT_TRUE(imm->GetActiveIMEState()->SwitchToNextInputMethod());
     EXPECT_EQ(1UL, observer.max_widget_list_size());
     const views::Widget* widget1 = observer.widget_list()[0];
 
-    EXPECT_TRUE(imm->SwitchToNextInputMethod());
+    EXPECT_TRUE(imm->GetActiveIMEState()->SwitchToNextInputMethod());
     EXPECT_EQ(2UL, observer.max_widget_list_size());
 
     // When a new mode indicator is displayed, the previous one should be