| 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 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/render_widget_host_iterator.h" | 16 #include "content/public/browser/render_widget_host_iterator.h" |
| 16 #include "content/public/browser/site_instance.h" | 17 #include "content/public/browser/site_instance.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
| 20 #include "ui/aura/client/aura_constants.h" |
| 21 #include "ui/base/ime/input_method.h" |
| 22 #include "ui/keyboard/keyboard_controller.h" |
| 19 #include "ui/keyboard/keyboard_switches.h" | 23 #include "ui/keyboard/keyboard_switches.h" |
| 20 | 24 |
| 21 namespace { | 25 namespace { |
| 22 | 26 |
| 23 const base::FilePath kWebuiTestDir = | 27 const base::FilePath kWebuiTestDir = |
| 24 base::FilePath(FILE_PATH_LITERAL("webui")); | 28 base::FilePath(FILE_PATH_LITERAL("webui")); |
| 25 | 29 |
| 26 const base::FilePath kVirtualKeyboardTestDir = | 30 const base::FilePath kVirtualKeyboardTestDir = |
| 27 base::FilePath(FILE_PATH_LITERAL("chromeos/virtual_keyboard")); | 31 base::FilePath(FILE_PATH_LITERAL("chromeos/virtual_keyboard")); |
| 28 | 32 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 InjectJavascript(kVirtualKeyboardTestDir, kBaseKeyboardTestFramework); | 64 InjectJavascript(kVirtualKeyboardTestDir, kBaseKeyboardTestFramework); |
| 61 InjectJavascript(kVirtualKeyboardTestDir, file); | 65 InjectJavascript(kVirtualKeyboardTestDir, file); |
| 62 | 66 |
| 63 ASSERT_TRUE(content::ExecuteScript(rvh, utf8_content_)); | 67 ASSERT_TRUE(content::ExecuteScript(rvh, utf8_content_)); |
| 64 | 68 |
| 65 // Inject DOM-automation test harness and run tests. | 69 // Inject DOM-automation test harness and run tests. |
| 66 std::vector<int> resource_ids; | 70 std::vector<int> resource_ids; |
| 67 EXPECT_TRUE(ExecuteWebUIResourceTest(rvh, resource_ids)); | 71 EXPECT_TRUE(ExecuteWebUIResourceTest(rvh, resource_ids)); |
| 68 } | 72 } |
| 69 | 73 |
| 74 void showVirtualKeyboard() { |
| 75 aura::Window *window = ash::Shell::GetPrimaryRootWindow(); |
| 76 ui::InputMethod* input_method = window->GetProperty( |
| 77 aura::client::kRootWindowInputMethodKey); |
| 78 ASSERT_TRUE(input_method); |
| 79 input_method->ShowImeIfNeeded(); |
| 80 } |
| 81 |
| 70 content::RenderViewHost* GetKeyboardRenderViewHost() { | 82 content::RenderViewHost* GetKeyboardRenderViewHost() { |
| 83 showVirtualKeyboard(); |
| 71 std::string kVirtualKeyboardURL = | 84 std::string kVirtualKeyboardURL = |
| 72 "chrome-extension://mppnpdlheglhdfmldimlhpnegondlapf/"; | 85 "chrome-extension://mppnpdlheglhdfmldimlhpnegondlapf/"; |
| 73 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 86 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
| 74 content::RenderWidgetHost::GetRenderWidgetHosts()); | 87 content::RenderWidgetHost::GetRenderWidgetHosts()); |
| 75 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 88 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 76 if (widget->IsRenderView()) { | 89 if (widget->IsRenderView()) { |
| 77 content::RenderViewHost* view = content::RenderViewHost::From(widget); | 90 content::RenderViewHost* view = content::RenderViewHost::From(widget); |
| 78 std::string url = view->GetSiteInstance()->GetSiteURL().spec(); | 91 std::string url = view->GetSiteInstance()->GetSiteURL().spec(); |
| 79 if (url == kVirtualKeyboardURL) { | 92 if (url == kVirtualKeyboardURL) { |
| 80 content::WebContents* wc = | 93 content::WebContents* wc = |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 bool success = false; | 179 bool success = false; |
| 167 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 180 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 168 browser_rvh, | 181 browser_rvh, |
| 169 "success ? verifyInput('a') : waitForInput('a');", | 182 "success ? verifyInput('a') : waitForInput('a');", |
| 170 &success)); | 183 &success)); |
| 171 ASSERT_TRUE(success); | 184 ASSERT_TRUE(success); |
| 172 } | 185 } |
| 173 | 186 |
| 174 // TODO(kevers|rsadam|bshe): Add UI tests for remaining virtual keyboard | 187 // TODO(kevers|rsadam|bshe): Add UI tests for remaining virtual keyboard |
| 175 // functionality. | 188 // functionality. |
| OLD | NEW |