| 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/client/aura_constants.h" |
| 23 #include "ui/aura/window_tree_host.h" |
| 23 #include "ui/base/ime/input_method.h" | 24 #include "ui/base/ime/input_method.h" |
| 24 #include "ui/keyboard/keyboard_controller.h" | 25 #include "ui/keyboard/keyboard_controller.h" |
| 25 #include "ui/keyboard/keyboard_switches.h" | 26 #include "ui/keyboard/keyboard_switches.h" |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 const base::FilePath::CharType kWebuiTestDir[] = FILE_PATH_LITERAL("webui"); | 29 const base::FilePath::CharType kWebuiTestDir[] = FILE_PATH_LITERAL("webui"); |
| 29 | 30 |
| 30 const base::FilePath::CharType kMockController[] = | 31 const base::FilePath::CharType kMockController[] = |
| 31 FILE_PATH_LITERAL("mock_controller.js"); | 32 FILE_PATH_LITERAL("mock_controller.js"); |
| 32 | 33 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 80 |
| 80 ASSERT_TRUE(content::ExecuteScript(web_contents, utf8_content_)); | 81 ASSERT_TRUE(content::ExecuteScript(web_contents, utf8_content_)); |
| 81 | 82 |
| 82 // Inject DOM-automation test harness and run tests. | 83 // Inject DOM-automation test harness and run tests. |
| 83 std::vector<int> resource_ids; | 84 std::vector<int> resource_ids; |
| 84 EXPECT_TRUE(ExecuteWebUIResourceTest(web_contents, resource_ids)); | 85 EXPECT_TRUE(ExecuteWebUIResourceTest(web_contents, resource_ids)); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void VirtualKeyboardBrowserTest::ShowVirtualKeyboard() { | 88 void VirtualKeyboardBrowserTest::ShowVirtualKeyboard() { |
| 88 aura::Window* window = ash::Shell::GetPrimaryRootWindow(); | 89 aura::Window* window = ash::Shell::GetPrimaryRootWindow(); |
| 89 ui::InputMethod* input_method = | 90 ui::InputMethod* input_method = window->GetHost()->GetInputMethod(); |
| 90 window->GetProperty(aura::client::kRootWindowInputMethodKey); | |
| 91 ASSERT_TRUE(input_method); | 91 ASSERT_TRUE(input_method); |
| 92 input_method->ShowImeIfNeeded(); | 92 input_method->ShowImeIfNeeded(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 content::RenderViewHost* VirtualKeyboardBrowserTest::GetKeyboardRenderViewHost( | 95 content::RenderViewHost* VirtualKeyboardBrowserTest::GetKeyboardRenderViewHost( |
| 96 const std::string& id) { | 96 const std::string& id) { |
| 97 ShowVirtualKeyboard(); | 97 ShowVirtualKeyboard(); |
| 98 GURL url = extensions::Extension::GetBaseURLFromExtensionId(id); | 98 GURL url = extensions::Extension::GetBaseURLFromExtensionId(id); |
| 99 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 99 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
| 100 content::RenderWidgetHost::GetRenderWidgetHosts()); | 100 content::RenderWidgetHost::GetRenderWidgetHosts()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 bool success = false; | 186 bool success = false; |
| 187 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 187 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 188 browser_rvh, | 188 browser_rvh, |
| 189 "success ? verifyInput('a') : waitForInput('a');", | 189 "success ? verifyInput('a') : waitForInput('a');", |
| 190 &success)); | 190 &success)); |
| 191 ASSERT_TRUE(success); | 191 ASSERT_TRUE(success); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // TODO(kevers|rsadam|bshe): Add UI tests for remaining virtual keyboard | 194 // TODO(kevers|rsadam|bshe): Add UI tests for remaining virtual keyboard |
| 195 // functionality. | 195 // functionality. |
| OLD | NEW |