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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2315223003: Move didUpdateTextOfFocusedElementByNonUserInput from WebViewClient to WebWidgetClient. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 2707
2708 // For oilpan we have to force a GC to ensure the event handlers have been r emoved when 2708 // For oilpan we have to force a GC to ensure the event handlers have been r emoved when
2709 // checking below. We do a precise GC (collectAllGarbage does not scan the s tack) 2709 // checking below. We do a precise GC (collectAllGarbage does not scan the s tack)
2710 // to ensure the div element dies. This is also why the Document is in a Per sistent 2710 // to ensure the div element dies. This is also why the Document is in a Per sistent
2711 // since we want that to stay around. 2711 // since we want that to stay around.
2712 ThreadHeap::collectAllGarbage(); 2712 ThreadHeap::collectAllGarbage();
2713 2713
2714 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); 2714 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent));
2715 } 2715 }
2716 2716
2717 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView Client { 2717 class NonUserInputTextUpdateWebWidgetClient: public FrameTestHelpers::TestWebWid getClient {
2718 public: 2718 public:
2719 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } 2719 NonUserInputTextUpdateWebWidgetClient() : m_textIsUpdated(false) { }
2720 2720
2721 // WebWidgetClient methods 2721 // WebWidgetClient methods
2722 void didUpdateTextOfFocusedElementByNonUserInput() override 2722 void didUpdateTextOfFocusedElementByNonUserInput() override
2723 { 2723 {
2724 m_textIsUpdated = true; 2724 m_textIsUpdated = true;
2725 } 2725 }
2726 2726
2727 void reset() 2727 void reset()
2728 { 2728 {
2729 m_textIsUpdated = false; 2729 m_textIsUpdated = false;
2730 } 2730 }
2731 2731
2732 bool textIsUpdated() const 2732 bool textIsUpdated() const
2733 { 2733 {
2734 return m_textIsUpdated; 2734 return m_textIsUpdated;
2735 } 2735 }
2736 2736
2737 private: 2737 private:
2738 int m_textIsUpdated; 2738 int m_textIsUpdated;
2739 }; 2739 };
2740 2740
2741 // This test verifies the text input flags are correctly exposed to script. 2741 // This test verifies the text input flags are correctly exposed to script.
2742 TEST_F(WebViewTest, TextInputFlags) 2742 TEST_F(WebViewTest, TextInputFlags)
2743 { 2743 {
2744 NonUserInputTextUpdateWebViewClient client;
2745 std::string url = m_baseURL + "text_input_flags.html"; 2744 std::string url = m_baseURL + "text_input_flags.html";
2746 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html"); 2745 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html");
2747 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, & client); 2746 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true);
2748 webViewImpl->setInitialFocus(false); 2747 webViewImpl->setInitialFocus(false);
2749 2748
2750 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); 2749 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl();
2751 Document* document = frame->frame()->document(); 2750 Document* document = frame->frame()->document();
2752 2751
2753 // (A) <input> 2752 // (A) <input>
2754 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and 2753 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and
2755 // autocapitalize is set to none. 2754 // autocapitalize is set to none.
2756 HTMLInputElement* inputElement = toHTMLInputElement(document->getElementById ("input")); 2755 HTMLInputElement* inputElement = toHTMLInputElement(document->getElementById ("input"));
2757 document->setFocusedElement(inputElement, FocusParams(SelectionBehaviorOnFoc us::None, WebFocusTypeNone, nullptr)); 2756 document->setFocusedElement(inputElement, FocusParams(SelectionBehaviorOnFoc us::None, WebFocusTypeNone, nullptr));
(...skipping 26 matching lines...) Expand all
2784 EXPECT_FALSE(info2.equals(info3)); 2783 EXPECT_FALSE(info2.equals(info3));
2785 2784
2786 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. 2785 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient.
2787 m_webViewHelper.reset(); 2786 m_webViewHelper.reset();
2788 } 2787 }
2789 2788
2790 // This test verifies that WebWidgetClient::didUpdateTextOfFocusedElementByNonUs erInput is 2789 // This test verifies that WebWidgetClient::didUpdateTextOfFocusedElementByNonUs erInput is
2791 // called iff value of a focused element is modified via script. 2790 // called iff value of a focused element is modified via script.
2792 TEST_F(WebViewTest, NonUserInputTextUpdate) 2791 TEST_F(WebViewTest, NonUserInputTextUpdate)
2793 { 2792 {
2794 NonUserInputTextUpdateWebViewClient client; 2793 NonUserInputTextUpdateWebWidgetClient client;
2795 std::string url = m_baseURL + "non_user_input_text_update.html"; 2794 std::string url = m_baseURL + "non_user_input_text_update.html";
2796 URLTestHelpers::registerMockedURLLoad(toKURL(url), "non_user_input_text_upda te.html"); 2795 URLTestHelpers::registerMockedURLLoad(toKURL(url), "non_user_input_text_upda te.html");
2797 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, & client); 2796 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, null ptr, nullptr, &client);
2798 webViewImpl->setInitialFocus(false); 2797 webViewImpl->setInitialFocus(false);
2799 2798
2800 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); 2799 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl();
2801 Document* document = frame->frame()->document(); 2800 Document* document = frame->frame()->document();
2802 2801
2803 // (A) <input> 2802 // (A) <input>
2804 // (A.1) Focused and value is changed by script. 2803 // (A.1) Focused and value is changed by script.
2805 client.reset(); 2804 client.reset();
2806 EXPECT_FALSE(client.textIsUpdated()); 2805 EXPECT_FALSE(client.textIsUpdated());
2807 2806
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 EXPECT_TRUE(webView->page()->defersLoading()); 3364 EXPECT_TRUE(webView->page()->defersLoading());
3366 } 3365 }
3367 3366
3368 EXPECT_TRUE(webView->page()->defersLoading()); 3367 EXPECT_TRUE(webView->page()->defersLoading());
3369 } 3368 }
3370 3369
3371 EXPECT_FALSE(webView->page()->defersLoading()); 3370 EXPECT_FALSE(webView->page()->defersLoading());
3372 } 3371 }
3373 3372
3374 } // namespace blink 3373 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | third_party/WebKit/public/web/WebViewClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698