| 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/extensions/extension_apitest.h" |   5 #include "chrome/browser/extensions/extension_apitest.h" | 
|   6  |   6  | 
|   7 #include "base/command_line.h" |   7 #include "base/command_line.h" | 
|   8 #include "base/memory/ref_counted.h" |   8 #include "base/memory/ref_counted.h" | 
|   9 #include "base/strings/stringprintf.h" |   9 #include "base/strings/stringprintf.h" | 
|  10 #include "chrome/browser/chrome_notification_types.h" |  10 #include "chrome/browser/chrome_notification_types.h" | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  26 const char kSetInputMethodDone[] = "done"; |  26 const char kSetInputMethodDone[] = "done"; | 
|  27  |  27  | 
|  28 // Class that listens for the JS message then changes input method and replies |  28 // Class that listens for the JS message then changes input method and replies | 
|  29 // back. |  29 // back. | 
|  30 class SetInputMethodListener : public content::NotificationObserver { |  30 class SetInputMethodListener : public content::NotificationObserver { | 
|  31  public: |  31  public: | 
|  32   // Creates listener, which should reply exactly |count_| times. |  32   // Creates listener, which should reply exactly |count_| times. | 
|  33   explicit SetInputMethodListener(int count) : count_(count) { |  33   explicit SetInputMethodListener(int count) : count_(count) { | 
|  34     registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, |  34     registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 
|  35                    content::NotificationService::AllSources()); |  35                    content::NotificationService::AllSources()); | 
|  36     chromeos::input_method::InputMethodManager::Get()-> |  36     chromeos::input_method::InputMethodManager::Get()->EnableLayouts( | 
|  37         EnableLayouts(kLoginScreenUILanguage, kInitialInputMethodOnLoginScreen); |  37         kLoginScreenUILanguage, | 
 |  38         kInitialInputMethodOnLoginScreen, | 
 |  39         true /* login_layouts_only */); | 
|  38   } |  40   } | 
|  39  |  41  | 
|  40   virtual ~SetInputMethodListener() { |  42   virtual ~SetInputMethodListener() { | 
|  41     EXPECT_EQ(0, count_); |  43     EXPECT_EQ(0, count_); | 
|  42   } |  44   } | 
|  43  |  45  | 
|  44   // Implements the content::NotificationObserver interface. |  46   // Implements the content::NotificationObserver interface. | 
|  45   virtual void Observe(int type, |  47   virtual void Observe(int type, | 
|  46                        const content::NotificationSource& source, |  48                        const content::NotificationSource& source, | 
|  47                        const content::NotificationDetails& details) OVERRIDE { |  49                        const content::NotificationDetails& details) OVERRIDE { | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|  75 }; |  77 }; | 
|  76  |  78  | 
|  77 }  // namespace |  79 }  // namespace | 
|  78  |  80  | 
|  79 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { |  81 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { | 
|  80   // Two test, two calls. See JS code for more info. |  82   // Two test, two calls. See JS code for more info. | 
|  81   SetInputMethodListener listener(2); |  83   SetInputMethodListener listener(2); | 
|  82  |  84  | 
|  83   ASSERT_TRUE(RunExtensionTest("input_method")) << message_; |  85   ASSERT_TRUE(RunExtensionTest("input_method")) << message_; | 
|  84 } |  86 } | 
| OLD | NEW |