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

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

Issue 2354793003: Browser Side TextInputState Tracking for Android (Closed)
Patch Set: Addressing kenrb@'s comments Created 4 years, 1 month 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 bb73b4fe9207709e5c618f3918288c9d45948e4e..036a09f657ec71cd1a01011026c430c245e30890 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
@@ -37,11 +37,6 @@
#include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h"
#endif
-// TODO(ekaramad): The following tests should be active on all platforms. After
-// fixing https://crbug.com/578168, this test file should be built for android
-// as well and most of the following tests should be enabled for all platforms
-//(https://crbug.com/602723).
-
///////////////////////////////////////////////////////////////////////////////
// TextInputManager and IME Tests
//
@@ -577,6 +572,57 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
reset_state_observer.Wait();
}
+// The following test verifies that when the active widget changes value, it is
+// always from nullptr to non-null or vice versa.
+IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
+ ResetTextInputStateOnActiveWidgetChange) {
+ 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());
+ std::vector<std::string> values{"a", "ab", "ac", "aca", "acb", "acd"};
+ for (size_t i = 0; i < frames.size(); ++i)
+ AddInputFieldToFrame(frames[i], "text", values[i], true);
+
+ content::WebContents* web_contents = active_contents();
+
+ auto send_tab_and_wait_for_value =
+ [&web_contents](const std::string& expected_value) {
+ TextInputManagerValueObserver observer(web_contents, expected_value);
+ SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
+ ui::VKEY_TAB, false, false, false, false);
+ observer.Wait();
+ };
+
+ // Record all active view changes.
+ RecordActiveViewsObserver recorder(web_contents);
+ for (auto value : values)
+ send_tab_and_wait_for_value(value);
+
+ // We have covered a total of 6 views, so there should at least be 11 entries
+ // recorded (at least one null between two views).
+ size_t record_count = recorder.active_views()->size();
+ EXPECT_GT(record_count, 10U);
+
+ // Verify we do not have subsequent nullptr or non-nullptrs.
+ for (size_t i = 0; i < record_count - 1U; ++i) {
+ const content::RenderWidgetHostView* current =
+ recorder.active_views()->at(i);
+ const content::RenderWidgetHostView* next =
+ recorder.active_views()->at(i + 1U);
+ EXPECT_TRUE((current != nullptr && next == nullptr) ||
+ (current == nullptr && next != nullptr));
+ }
+}
+
+// TODO(ekaramad): Some of the following tests should be active on Android as
+// well. Enable them when the corresponding feature is implemented for Android
+// (https://crbug.com/602723).
+#if !defined(OS_ANDROID)
// 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, the test
@@ -702,57 +748,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
}
}
-// The following test verifies that when the active widget changes value, it is
-// always from nullptr to non-null or vice versa.
-IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
- ResetTextInputStateOnActiveWidgetChange) {
- 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());
- std::vector<std::string> values{"a", "ab", "ac", "aca", "acb", "acd"};
- for (size_t i = 0; i < frames.size(); ++i)
- AddInputFieldToFrame(frames[i], "text", values[i], true);
-
- content::WebContents* web_contents = active_contents();
-
- auto send_tab_and_wait_for_value =
- [&web_contents](const std::string& expected_value) {
- TextInputManagerValueObserver observer(web_contents, expected_value);
- SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
- ui::VKEY_TAB, false, false, false, false);
- observer.Wait();
- };
-
- // Record all active view changes.
- RecordActiveViewsObserver recorder(web_contents);
- for (auto value : values)
- send_tab_and_wait_for_value(value);
-
- // We have covered a total of 6 views, so there should at least be 11 entries
- // recorded (at least one null between two views).
- size_t record_count = recorder.active_views()->size();
- EXPECT_GT(record_count, 10U);
-
- // Verify we do not have subsequent nullptr or non-nullptrs.
- for (size_t i = 0; i < record_count - 1U; ++i) {
- const content::RenderWidgetHostView* current =
- recorder.active_views()->at(i);
- const content::RenderWidgetHostView* next =
- recorder.active_views()->at(i + 1U);
- EXPECT_TRUE((current != nullptr && next == nullptr) ||
- (current == nullptr && next != nullptr));
- }
-}
// 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).
-
#if defined(USE_AURA)
// -----------------------------------------------------------------------------
// Input Method Observer Tests
@@ -1130,3 +1129,4 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
content::SetBrowserClientForTesting(old_browser_client);
}
#endif
Charlie Reis 2016/11/02 22:23:13 nit: Can you add a comment here about which ifdef
EhsanK 2016/11/18 19:55:59 Done.
+#endif // !defined(OS_ANDROID)
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | content/browser/renderer_host/render_widget_host_view_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698