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

Unified Diff: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc

Issue 2057803002: Tracking SelectionBounds for all RenderWidgets on the Browser Side (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing creis@'s comments Created 4 years, 5 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
Index: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
diff --git a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
index 35e9c65e9a42d329cf15962b56c3b85127294559..47eca0fa291d09583e9f4e61a666c18900533d03 100644
--- a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
+++ b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
@@ -98,8 +98,7 @@ class TextInputManagerValueObserver : public TextInputManagerObserverBase {
}
private:
- void VerifyValue(content::TextInputManagerTester* text_input_manager_tester) {
- ASSERT_EQ(tester(), text_input_manager_tester);
+ void VerifyValue() {
std::string value;
if (tester()->GetTextInputValue(&value) && expected_value_ == value)
OnSuccess();
@@ -122,8 +121,7 @@ class TextInputManagerTypeObserver : public TextInputManagerObserverBase {
}
private:
- void VerifyType(content::TextInputManagerTester* text_input_manager_tester) {
- ASSERT_EQ(tester(), text_input_manager_tester);
+ void VerifyType() {
ui::TextInputType type =
tester()->GetTextInputType(&type) ? type : ui::TEXT_INPUT_TYPE_NONE;
if (expected_type_ == type)
@@ -145,9 +143,7 @@ class TextInputManagerChangeObserver : public TextInputManagerObserverBase {
}
private:
- void VerifyChange(
- content::TextInputManagerTester* text_input_manager_tester) {
- ASSERT_EQ(tester(), text_input_manager_tester);
+ void VerifyChange() {
if (tester()->IsTextInputStateChanged())
OnSuccess();
}
@@ -170,7 +166,7 @@ class ViewTextInputTypeObserver : public TextInputManagerObserverBase {
}
private:
- void VerifyType(content::TextInputManagerTester* tester) {
+ void VerifyType() {
ui::TextInputType type;
if (!content::GetTextInputTypeForView(web_contents_, view_, &type))
return;
@@ -185,6 +181,31 @@ class ViewTextInputTypeObserver : public TextInputManagerObserverBase {
DISALLOW_COPY_AND_ASSIGN(ViewTextInputTypeObserver);
};
+// This class observes the |expected_view| for the first change in its
+// selection bounds.
+class ViewSelectionBoundsChangedObserver : public TextInputManagerObserverBase {
+ public:
+ ViewSelectionBoundsChangedObserver(
+ content::WebContents* web_contents,
+ content::RenderWidgetHostView* expected_view)
+ : TextInputManagerObserverBase(web_contents),
+ expected_view_(expected_view) {
+ tester()->SetOnSelectionBoundsChangedCallback(
+ base::Bind(&ViewSelectionBoundsChangedObserver::VerifyChange,
+ base::Unretained(this)));
+ }
+
+ private:
+ void VerifyChange() {
+ if (expected_view_ == tester()->GetUpdatedView())
+ OnSuccess();
+ }
+
+ const content::RenderWidgetHostView* const expected_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewSelectionBoundsChangedObserver);
+};
+
} // namespace
// Main class for all TextInputState and IME related tests.
@@ -456,6 +477,44 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
reset_state_observer.Wait();
}
+// This test creates a page with multiple child frames and adds an <input> to
+// each frame. Then, sequentially, each <input> is focused by sending a tab key.
+// Then, after |TextInputState.type| for a view is changed to text, another key
+// is pressed (a character) and then the test verifies that TextInputManager
+// receives the corresponding update on the change in selection bounds on the
+// browser side.
+IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
+ TrackSelectionBoundsForChildFrames) {
+ CreateIframePage("a(b,c(a,b),d)");
+ std::vector<content::RenderFrameHost*> frames{
+ GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
+ GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
+ GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
+ std::vector<content::RenderWidgetHostView*> views;
+ for (auto frame : frames)
+ views.push_back(frame->GetView());
+ for (size_t i = 0; i < frames.size(); ++i)
+ AddInputFieldToFrame(frames[i], "text", "", true);
+
+ content::WebContents* web_contents = active_contents();
+
+ auto send_tab_insert_text_wait_for_bounds_change = [&web_contents](
+ content::RenderWidgetHostView* view) {
+ ViewTextInputTypeObserver type_observer(web_contents, view,
+ ui::TEXT_INPUT_TYPE_TEXT);
+ SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
+ ui::VKEY_TAB, false, false, false, false);
+ type_observer.Wait();
+ ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view);
+ SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'),
+ ui::DomCode::US_E, ui::VKEY_E, false, false, false, false);
+ bounds_observer.Wait();
+ };
+
+ for (auto view : views)
+ send_tab_insert_text_wait_for_bounds_change(view);
+}
+
// TODO(ekaramad): The following tests are specifically written for Aura and are
// based on InputMethodObserver. Write similar tests for Mac/Android/Mus
// (crbug.com/602723).
« no previous file with comments | « chrome/browser/renderer_host/OWNERS ('k') | content/browser/frame_host/render_widget_host_view_child_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698