Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3933)

Unified Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 2929543002: Request Composition Range Updates for Focused GuestViews based on BrowserPlugins (Closed)
Patch Set: Adding a test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
diff --git a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
index f6f563556e77ab03c263eeaa4243b5551fb07f67..a26330a0e01cb1b6c073f3c1d1fae3f4fa4adfaf 100644
--- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
@@ -566,7 +566,50 @@ class WebViewDragDropInteractiveTest : public WebViewInteractiveTest {};
class WebViewNewWindowInteractiveTest : public WebViewInteractiveTest {};
class WebViewFocusInteractiveTest : public WebViewInteractiveTest {};
class WebViewPointerLockInteractiveTest : public WebViewInteractiveTest {};
-class WebViewImeInteractiveTest : public WebViewInteractiveTest {};
+class WebViewImeInteractiveTest : public WebViewInteractiveTest {
+ protected:
+ // This class observers all the composition range updates associated with the
Charlie Reis 2017/06/09 21:38:17 nit: observes :)
EhsanK 2017/06/12 13:41:22 Thanks! Sorry! My signature typo again.
+ // TextInputManager of the provided WebContents. The WebContents should be an
+ // outer most WebContents.
+ class CompositionRangeUpdateObserver {
+ public:
+ explicit CompositionRangeUpdateObserver(content::WebContents* web_contents)
+ : tester_(web_contents) {
+ tester_.SetOnImeCompositionRangeChangedCallback(
+ base::Bind(&CompositionRangeUpdateObserver::OnCompositionRangeUpdated,
+ base::Unretained(this)));
+ }
+ ~CompositionRangeUpdateObserver() {}
+
+ // Wait until a composition range update with a range length equal to
+ // |length| is received.
+ void WaitForCompositionRangeLength(uint32_t length) {
+ if (did_update_composition_range_ &&
+ last_composition_range_length_ == length)
+ return;
+ expected_length_ = length;
+ run_loop_.reset(new base::RunLoop());
+ run_loop_->Run();
+ }
+
+ private:
+ void OnCompositionRangeUpdated() {
+ did_update_composition_range_ = tester_.GetLastCompositionRangeLength(
+ &last_composition_range_length_);
+ ASSERT_TRUE(did_update_composition_range_);
+ if (last_composition_range_length_ == expected_length_)
+ run_loop_->Quit();
+ }
+
+ content::TextInputManagerTester tester_;
+ std::unique_ptr<base::RunLoop> run_loop_;
+ bool did_update_composition_range_ = false;
+ uint32_t last_composition_range_length_ = 0;
+ uint32_t expected_length_ = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(CompositionRangeUpdateObserver);
+ };
+};
// The tests below aren't needed in --use-cross-process-frames-for-guests.
class WebViewContextMenuInteractiveTest : public WebViewInteractiveTestBase {};
@@ -1689,3 +1732,52 @@ IN_PROC_BROWSER_TEST_P(WebViewImeInteractiveTest,
EXPECT_EQ("A B C D", value);
}
#endif // OS_MACOSX
+
+IN_PROC_BROWSER_TEST_P(WebViewImeInteractiveTest, CompositionRangeUpdates) {
+ ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
+ LoadAndLaunchPlatformApp("web_view/ime", "WebViewImeTest.Launched");
+ ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(GetPlatformAppWindow()));
+
+ // Flush any pending events to make sure we start with a clean slate.
+ content::RunAllPendingInMessageLoop();
+
+ content::WebContents* guest_web_contents =
+ GetGuestViewManager()->GetLastGuestCreated();
+
+ // Click the <input> element inside the <webview>. In its focus handle, the
+ // <input> inside the <webview> initializes its value to "A B X D".
+ ExtensionTestMessageListener focus_listener("WebViewImeTest.InputFocused",
+ false);
+ content::WebContents* embedder_web_contents =
+ guest_view::GuestViewBase::FromWebContents(guest_web_contents)
+ ->embedder_web_contents();
+ content::WebContents* target_web_contents =
+ GetParam() ? guest_web_contents : embedder_web_contents;
+
+ content::SimulateMouseClickAt(target_web_contents, 0,
+ blink::WebMouseEvent::Button::kLeft,
+ gfx::Point(50, 50));
+ focus_listener.WaitUntilSatisfied();
+
+ // Clear the string as it already contains some text.
+ // Verify the text inside the <input> is "A B X D".
Charlie Reis 2017/06/09 21:38:17 I don't see anything verifying this. Is the comme
EhsanK 2017/06/12 13:41:22 Thanks! It should be empty "" instead.
+ std::string value;
+ ASSERT_TRUE(ExecuteScriptAndExtractString(
+ guest_web_contents,
+ "var input = document.querySelector('input');"
+ "input.value = '';"
+ "window.domAutomationController."
+ "send(document.querySelector('"
+ "input').value)",
+ &value));
+ EXPECT_EQ("", value);
+
+ // Now set some composition text which should lead to an update in composition
+ // range information.
+ CompositionRangeUpdateObserver observer(embedder_web_contents);
+ content::SendImeSetCompositionTextToWidget(
+ target_web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost(),
+ base::UTF8ToUTF16("ABC"), std::vector<ui::CompositionUnderline>(),
+ gfx::Range::InvalidRange(), 0, 3);
+ observer.WaitForCompositionRangeLength(3U);
+}
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698