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/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
11 #include "chrome/browser/extensions/extension_test_api.h" | 11 #include "chrome/browser/extensions/api/test/test_api.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char kLoginScreenUILanguage[] = "ru"; | 21 const char kLoginScreenUILanguage[] = "ru"; |
(...skipping 23 matching lines...) Expand all Loading... |
45 const content::NotificationSource& source, | 45 const content::NotificationSource& source, |
46 const content::NotificationDetails& details) { | 46 const content::NotificationDetails& details) { |
47 const std::string& content = *content::Details<std::string>(details).ptr(); | 47 const std::string& content = *content::Details<std::string>(details).ptr(); |
48 const std::string expected_message = StringPrintf("%s:%s", | 48 const std::string expected_message = StringPrintf("%s:%s", |
49 kSetInputMethodMessage, | 49 kSetInputMethodMessage, |
50 kNewInputMethod); | 50 kNewInputMethod); |
51 if (content == expected_message) { | 51 if (content == expected_message) { |
52 chromeos::input_method::InputMethodManager::GetInstance()-> | 52 chromeos::input_method::InputMethodManager::GetInstance()-> |
53 ChangeInputMethod(StringPrintf("xkb:%s", kNewInputMethod)); | 53 ChangeInputMethod(StringPrintf("xkb:%s", kNewInputMethod)); |
54 | 54 |
55 ExtensionTestSendMessageFunction* function = | 55 extensions::TestSendMessageFunction* function = |
56 content::Source<ExtensionTestSendMessageFunction>(source).ptr(); | 56 content::Source<extensions::TestSendMessageFunction>( |
| 57 source).ptr(); |
57 EXPECT_GT(count_--, 0); | 58 EXPECT_GT(count_--, 0); |
58 function->Reply(kSetInputMethodDone); | 59 function->Reply(kSetInputMethodDone); |
59 } | 60 } |
60 } | 61 } |
61 | 62 |
62 private: | 63 private: |
63 content::NotificationRegistrar registrar_; | 64 content::NotificationRegistrar registrar_; |
64 | 65 |
65 int count_; | 66 int count_; |
66 }; | 67 }; |
67 | 68 |
68 class ExtensionInputMethodApiTest : public ExtensionApiTest { | 69 class ExtensionInputMethodApiTest : public ExtensionApiTest { |
69 virtual void SetUpCommandLine(CommandLine* command_line) { | 70 virtual void SetUpCommandLine(CommandLine* command_line) { |
70 ExtensionApiTest::SetUpCommandLine(command_line); | 71 ExtensionApiTest::SetUpCommandLine(command_line); |
71 command_line->AppendSwitchASCII( | 72 command_line->AppendSwitchASCII( |
72 switches::kWhitelistedExtensionID, "ilanclmaeigfpnmdlgelmhkpkegdioip"); | 73 switches::kWhitelistedExtensionID, "ilanclmaeigfpnmdlgelmhkpkegdioip"); |
73 } | 74 } |
74 }; | 75 }; |
75 | 76 |
76 } // namespace | 77 } // namespace |
77 | 78 |
78 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { | 79 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { |
79 // Two test, two calls. See JS code for more info. | 80 // Two test, two calls. See JS code for more info. |
80 SetInputMethodListener listener(2); | 81 SetInputMethodListener listener(2); |
81 | 82 |
82 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; | 83 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; |
83 } | 84 } |
OLD | NEW |