| Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| index 58a75966423ff4aff7f230279fa15dc416a54ba3..498765c494f0557c0107431e90d662fa51c71d3e 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| @@ -2608,22 +2608,14 @@ TEST_P(WebViewTest, ShowPressOnTransformedLink) {
|
| class MockAutofillClient : public WebAutofillClient {
|
| public:
|
| MockAutofillClient()
|
| - : m_ignoreTextChanges(false),
|
| + : m_textChanges(0),
|
| m_textChangesFromUserGesture(0),
|
| - m_textChangesWhileIgnored(0),
|
| - m_textChangesWhileNotIgnored(0),
|
| m_userGestureNotificationsCount(0) {}
|
|
|
| ~MockAutofillClient() override {}
|
|
|
| - void setIgnoreTextChanges(bool ignore) override {
|
| - m_ignoreTextChanges = ignore;
|
| - }
|
| void textFieldDidChange(const WebFormControlElement&) override {
|
| - if (m_ignoreTextChanges)
|
| - ++m_textChangesWhileIgnored;
|
| - else
|
| - ++m_textChangesWhileNotIgnored;
|
| + ++m_textChanges;
|
|
|
| if (UserGestureIndicator::processingUserGesture())
|
| ++m_textChangesFromUserGesture;
|
| @@ -2632,23 +2624,17 @@ class MockAutofillClient : public WebAutofillClient {
|
| ++m_userGestureNotificationsCount;
|
| }
|
|
|
| - void clearChangeCounts() {
|
| - m_textChangesWhileIgnored = 0;
|
| - m_textChangesWhileNotIgnored = 0;
|
| - }
|
| + void clearChangeCounts() { m_textChanges = 0; }
|
|
|
| + int textChanges() { return m_textChanges; }
|
| int textChangesFromUserGesture() { return m_textChangesFromUserGesture; }
|
| - int textChangesWhileIgnored() { return m_textChangesWhileIgnored; }
|
| - int textChangesWhileNotIgnored() { return m_textChangesWhileNotIgnored; }
|
| int getUserGestureNotificationsCount() {
|
| return m_userGestureNotificationsCount;
|
| }
|
|
|
| private:
|
| - bool m_ignoreTextChanges;
|
| + int m_textChanges;
|
| int m_textChangesFromUserGesture;
|
| - int m_textChangesWhileIgnored;
|
| - int m_textChangesWhileNotIgnored;
|
| int m_userGestureNotificationsCount;
|
| };
|
|
|
| @@ -2675,7 +2661,7 @@ TEST_P(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) {
|
| // trigger a text changed notification for autofill.
|
| client.clearChangeCounts();
|
| webView->setFocus(false);
|
| - EXPECT_EQ(0, client.textChangesWhileNotIgnored());
|
| + EXPECT_EQ(0, client.textChanges());
|
|
|
| frame->setAutofillClient(0);
|
| }
|
| @@ -2740,7 +2726,7 @@ TEST_P(WebViewTest, CompositionNotCancelledByBackspace) {
|
| frame->setAutofillClient(0);
|
| }
|
|
|
| -TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) {
|
| +TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) {
|
| registerMockedHttpURLLoad("input_field_populated.html");
|
| MockAutofillClient client;
|
| WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
|
| @@ -2748,6 +2734,11 @@ TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) {
|
| WebLocalFrameImpl* frame = webView->mainFrameImpl();
|
| frame->setAutofillClient(&client);
|
| webView->setInitialFocus(false);
|
| +
|
| + WebDocument document = webView->mainFrame()->document();
|
| + HTMLFormControlElement* form =
|
| + toHTMLFormControlElement(document.getElementById("sample"));
|
| +
|
| WebInputMethodController* activeInputMethodController =
|
| frame->frameWidget()->getActiveWebInputMethodController();
|
| // Set up a composition that needs to be committed.
|
| @@ -2764,16 +2755,20 @@ TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) {
|
| EXPECT_EQ(0, info.compositionStart);
|
| EXPECT_EQ((int)compositionText.length(), info.compositionEnd);
|
|
|
| + form->setAutofilled(true);
|
| client.clearChangeCounts();
|
| +
|
| activeInputMethodController->finishComposingText(
|
| WebInputMethodController::KeepSelection);
|
| - EXPECT_EQ(0, client.textChangesWhileIgnored());
|
| - EXPECT_EQ(1, client.textChangesWhileNotIgnored());
|
| + EXPECT_EQ(0, client.textChanges());
|
| +
|
| + EXPECT_TRUE(form->isAutofilled());
|
|
|
| frame->setAutofillClient(0);
|
| }
|
|
|
| -TEST_P(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) {
|
| +TEST_P(WebViewTest,
|
| + SetCompositionFromExistingTextDoesntTriggerAutofillTextChange) {
|
| registerMockedHttpURLLoad("input_field_populated.html");
|
| MockAutofillClient client;
|
| WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
|
| @@ -2793,8 +2788,7 @@ TEST_P(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) {
|
| EXPECT_EQ(8, info.compositionStart);
|
| EXPECT_EQ(12, info.compositionEnd);
|
|
|
| - EXPECT_EQ(0, client.textChangesWhileIgnored());
|
| - EXPECT_EQ(0, client.textChangesWhileNotIgnored());
|
| + EXPECT_EQ(0, client.textChanges());
|
|
|
| WebDocument document = webView->mainFrame()->document();
|
| EXPECT_EQ(WebString::fromUTF8("none"),
|
|
|