OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Chromium Authors. All rights reserved. | 2 * Copyright 2013 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 #include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h" | 6 #include "chrome/browser/chromeos/extensions/virtual_keyboard_browsertest.h" |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/render_widget_host_iterator.h" | 17 #include "content/public/browser/render_widget_host_iterator.h" |
18 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
21 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
22 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/window_tree_host.h" |
23 #include "ui/base/ime/input_method.h" | 23 #include "ui/base/ime/input_method.h" |
24 #include "ui/keyboard/keyboard_controller.h" | 24 #include "ui/keyboard/keyboard_controller.h" |
25 #include "ui/keyboard/keyboard_switches.h" | 25 #include "ui/keyboard/keyboard_switches.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 const base::FilePath::CharType kWebuiTestDir[] = FILE_PATH_LITERAL("webui"); | 28 const base::FilePath::CharType kWebuiTestDir[] = FILE_PATH_LITERAL("webui"); |
29 | 29 |
30 const base::FilePath::CharType kMockController[] = | 30 const base::FilePath::CharType kMockController[] = |
31 FILE_PATH_LITERAL("mock_controller.js"); | 31 FILE_PATH_LITERAL("mock_controller.js"); |
32 | 32 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 ASSERT_TRUE(content::ExecuteScript(web_contents, utf8_content_)); | 80 ASSERT_TRUE(content::ExecuteScript(web_contents, utf8_content_)); |
81 | 81 |
82 // Inject DOM-automation test harness and run tests. | 82 // Inject DOM-automation test harness and run tests. |
83 std::vector<int> resource_ids; | 83 std::vector<int> resource_ids; |
84 EXPECT_TRUE(ExecuteWebUIResourceTest(web_contents, resource_ids)); | 84 EXPECT_TRUE(ExecuteWebUIResourceTest(web_contents, resource_ids)); |
85 } | 85 } |
86 | 86 |
87 void VirtualKeyboardBrowserTest::ShowVirtualKeyboard() { | 87 void VirtualKeyboardBrowserTest::ShowVirtualKeyboard() { |
88 aura::Window* window = ash::Shell::GetPrimaryRootWindow(); | 88 aura::Window* window = ash::Shell::GetPrimaryRootWindow(); |
89 ui::InputMethod* input_method = | 89 ui::InputMethod* input_method = window->GetHost()->GetInputMethod(); |
90 window->GetProperty(aura::client::kRootWindowInputMethodKey); | |
91 ASSERT_TRUE(input_method); | 90 ASSERT_TRUE(input_method); |
92 input_method->ShowImeIfNeeded(); | 91 input_method->ShowImeIfNeeded(); |
93 } | 92 } |
94 | 93 |
95 content::RenderViewHost* VirtualKeyboardBrowserTest::GetKeyboardRenderViewHost( | 94 content::RenderViewHost* VirtualKeyboardBrowserTest::GetKeyboardRenderViewHost( |
96 const std::string& id) { | 95 const std::string& id) { |
97 ShowVirtualKeyboard(); | 96 ShowVirtualKeyboard(); |
98 GURL url = extensions::Extension::GetBaseURLFromExtensionId(id); | 97 GURL url = extensions::Extension::GetBaseURLFromExtensionId(id); |
99 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 98 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
100 content::RenderWidgetHost::GetRenderWidgetHosts()); | 99 content::RenderWidgetHost::GetRenderWidgetHosts()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 bool success = false; | 185 bool success = false; |
187 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 186 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
188 browser_rvh, | 187 browser_rvh, |
189 "success ? verifyInput('a') : waitForInput('a');", | 188 "success ? verifyInput('a') : waitForInput('a');", |
190 &success)); | 189 &success)); |
191 ASSERT_TRUE(success); | 190 ASSERT_TRUE(success); |
192 } | 191 } |
193 | 192 |
194 // TODO(kevers|rsadam|bshe): Add UI tests for remaining virtual keyboard | 193 // TODO(kevers|rsadam|bshe): Add UI tests for remaining virtual keyboard |
195 // functionality. | 194 // functionality. |
OLD | NEW |