| Index: content/browser/renderer_host/render_widget_host_view_win_browsertest.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c6a0952c92e15cdf0ed9463e55a6d9872c68a5a7
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc
|
| @@ -0,0 +1,137 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/win/metro.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "content/public/common/content_switches.h"
|
| +#include "content/public/test/test_utils.h"
|
| +#include "content/public/test/browser_test_utils.h"
|
| +#include "content/shell/shell.h"
|
| +#include "content/test/content_browser_test_utils.h"
|
| +#include "content/test/content_browser_test.h"
|
| +#include "ui/base/win/mock_tsf_bridge.h"
|
| +#include "ui/base/win/tsf_bridge.h"
|
| +
|
| +namespace {
|
| +class RenderWidgetHostViewWinTest : public content::ContentBrowserTest {
|
| + public:
|
| + RenderWidgetHostViewWinTest() {}
|
| +
|
| + virtual void SetUpCommandLine(CommandLine* command_line) {
|
| + command_line->AppendSwitch(switches::kEnableTextServiceFramework);
|
| + }
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwichToPasswordField) {
|
| + ui::MockTsfBridge mock_bridge;
|
| + ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
|
| + GURL test_url = content::GetTestUrl("textinput",
|
| + "ime_enable_disable_test.html");
|
| +
|
| + content::NavigateToURL(shell(), test_url);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| +
|
| + EXPECT_FALSE(mock_bridge.is_ime_enabled());
|
| +
|
| + // Focus to the text field, the IME should be enabled.
|
| + bool success = false;
|
| + EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
|
| + shell()->web_contents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(text01_focus());",
|
| + &success));
|
| + EXPECT_TRUE(success);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| + EXPECT_TRUE(mock_bridge.is_ime_enabled());
|
| +
|
| + // Focus to the password field, the IME should be disabled.
|
| + success = false;
|
| + EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
|
| + shell()->web_contents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(password02_focus());",
|
| + &success));
|
| + EXPECT_TRUE(success);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| + EXPECT_FALSE(mock_bridge.is_ime_enabled());
|
| +
|
| + ui::TsfBridge::ReplaceForTesting(old_bridge);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwitchToSameField) {
|
| + ui::MockTsfBridge mock_bridge;
|
| + ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
|
| + GURL test_url = content::GetTestUrl("textinput",
|
| + "ime_enable_disable_test.html");
|
| +
|
| + content::NavigateToURL(shell(), test_url);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| +
|
| + EXPECT_FALSE(mock_bridge.is_ime_enabled());
|
| +
|
| + // Focus to the text field, the IME should be enabled.
|
| + bool success = false;
|
| + EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
|
| + shell()->web_contents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(text01_focus());",
|
| + &success));
|
| + EXPECT_TRUE(success);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| + EXPECT_TRUE(mock_bridge.is_ime_enabled());
|
| +
|
| + // Focus to another text field, the IME should be enabled.
|
| + success = false;
|
| + EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
|
| + shell()->web_contents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(text02_focus());",
|
| + &success));
|
| + EXPECT_TRUE(success);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| + EXPECT_TRUE(mock_bridge.is_ime_enabled());
|
| +
|
| + ui::TsfBridge::ReplaceForTesting(old_bridge);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, SwitchToSamePasswordField) {
|
| + ui::MockTsfBridge mock_bridge;
|
| + ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge);
|
| + GURL test_url = content::GetTestUrl("textinput",
|
| + "ime_enable_disable_test.html");
|
| +
|
| + content::NavigateToURL(shell(), test_url);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| +
|
| + EXPECT_FALSE(mock_bridge.is_ime_enabled());
|
| +
|
| + // Focus to the password field, the IME should be disabled.
|
| + bool success = false;
|
| + EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
|
| + shell()->web_contents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(password01_focus());",
|
| + &success));
|
| + EXPECT_TRUE(success);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| + EXPECT_FALSE(mock_bridge.is_ime_enabled());
|
| +
|
| + // Focus to the another password field, the IME should be disabled.
|
| + success = false;
|
| + EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
|
| + shell()->web_contents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(password02_focus());",
|
| + &success));
|
| + EXPECT_TRUE(success);
|
| + content::WaitForLoadStop(shell()->web_contents());
|
| + content::RunAllPendingInMessageLoop();
|
| + EXPECT_FALSE(mock_bridge.is_ime_enabled());
|
| +
|
| + ui::TsfBridge::ReplaceForTesting(old_bridge);
|
| +}
|
| +} // namespace
|
|
|