Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 const WebSize& maxAutoResize, | 232 const WebSize& maxAutoResize, |
| 233 const std::string& pageWidth, | 233 const std::string& pageWidth, |
| 234 const std::string& pageHeight, | 234 const std::string& pageHeight, |
| 235 int expectedWidth, | 235 int expectedWidth, |
| 236 int expectedHeight, | 236 int expectedHeight, |
| 237 HorizontalScrollbarState expectedHorizontalState, | 237 HorizontalScrollbarState expectedHorizontalState, |
| 238 VerticalScrollbarState expectedVerticalState); | 238 VerticalScrollbarState expectedVerticalState); |
| 239 | 239 |
| 240 void testTextInputType(WebTextInputType expectedType, | 240 void testTextInputType(WebTextInputType expectedType, |
| 241 const std::string& htmlFile); | 241 const std::string& htmlFile); |
| 242 void testInputMode(const WebString& expectedInputMode, | 242 void testInputMode(WebTextInputMode expectedInputMode, |
| 243 const std::string& htmlFile); | 243 const std::string& htmlFile); |
| 244 bool tapElement(WebInputEvent::Type, Element*); | 244 bool tapElement(WebInputEvent::Type, Element*); |
| 245 bool tapElementById(WebInputEvent::Type, const WebString& id); | 245 bool tapElementById(WebInputEvent::Type, const WebString& id); |
| 246 | 246 |
| 247 std::string m_baseURL; | 247 std::string m_baseURL; |
| 248 FrameTestHelpers::WebViewHelper m_webViewHelper; | 248 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 static bool hitTestIsContentEditable(WebView* view, int x, int y) { | 251 static bool hitTestIsContentEditable(WebView* view, int x, int y) { |
| 252 WebPoint hitPoint(x, y); | 252 WebPoint hitPoint(x, y); |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 // Add id="foo" to <path>, thus triggering the condition described above. | 787 // Add id="foo" to <path>, thus triggering the condition described above. |
| 788 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 788 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 789 document->body() | 789 document->body() |
| 790 ->querySelector("path", ASSERT_NO_EXCEPTION) | 790 ->querySelector("path", ASSERT_NO_EXCEPTION) |
| 791 ->setIdAttribute("foo"); | 791 ->setIdAttribute("foo"); |
| 792 | 792 |
| 793 // This should not DCHECK. | 793 // This should not DCHECK. |
| 794 EXPECT_EQ(WebTextInputTypeText, webViewImpl->textInputInfo().type); | 794 EXPECT_EQ(WebTextInputTypeText, webViewImpl->textInputInfo().type); |
| 795 } | 795 } |
| 796 | 796 |
| 797 void WebViewTest::testInputMode(const WebString& expectedInputMode, | 797 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode, |
| 798 const std::string& htmlFile) { | 798 const std::string& htmlFile) { |
| 799 URLTestHelpers::registerMockedURLFromBaseURL( | 799 URLTestHelpers::registerMockedURLFromBaseURL( |
| 800 WebString::fromUTF8(m_baseURL.c_str()), | 800 WebString::fromUTF8(m_baseURL.c_str()), |
| 801 WebString::fromUTF8(htmlFile.c_str())); | 801 WebString::fromUTF8(htmlFile.c_str())); |
| 802 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); | 802 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); |
| 803 webView->setInitialFocus(false); | 803 webView->setInitialFocus(false); |
| 804 EXPECT_EQ(expectedInputMode, webView->textInputInfo().inputMode); | 804 EXPECT_EQ(expectedInputMode, webView->textInputInfo().inputMode); |
| 805 } | 805 } |
| 806 | 806 |
| 807 TEST_F(WebViewTest, InputMode) { | 807 TEST_F(WebViewTest, InputMode) { |
| 808 testInputMode(WebString(), "input_mode_default.html"); | 808 testInputMode(WebTextInputMode::kWebTextInputModeDefault, |
| 809 testInputMode(WebString("unknown"), "input_mode_default_unknown.html"); | 809 "input_mode_default.html"); |
| 810 testInputMode(WebString("verbatim"), "input_mode_default_verbatim.html"); | 810 testInputMode(WebTextInputMode::kWebTextInputModeDefault, |
| 811 testInputMode(WebString("verbatim"), "input_mode_type_text_verbatim.html"); | 811 "input_mode_default_unknown.html"); |
| 812 testInputMode(WebString("verbatim"), "input_mode_type_search_verbatim.html"); | 812 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, |
|
esprehn
2016/10/24 21:12:26
All of this seems like it should be unit tests ins
| |
| 813 testInputMode(WebString(), "input_mode_type_url_verbatim.html"); | 813 "input_mode_default_verbatim.html"); |
| 814 testInputMode(WebString("verbatim"), "input_mode_textarea_verbatim.html"); | 814 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, |
| 815 "input_mode_type_text_verbatim.html"); | |
| 816 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, | |
| 817 "input_mode_type_search_verbatim.html"); | |
| 818 testInputMode(WebTextInputMode::kWebTextInputModeDefault, | |
| 819 "input_mode_type_url_verbatim.html"); | |
| 820 testInputMode(WebTextInputMode::kWebTextInputModeLatin, | |
| 821 "input_mode_type_latin.html"); | |
| 822 testInputMode(WebTextInputMode::kWebTextInputModeLatinName, | |
| 823 "input_mode_type_latin_name.html"); | |
| 824 testInputMode(WebTextInputMode::kWebTextInputModeLatinProse, | |
| 825 "input_mode_type_latin_prose.html"); | |
| 826 testInputMode(WebTextInputMode::kWebTextInputModeFullWidthLatin, | |
| 827 "input_mode_type_full_width_latin.html"); | |
| 828 testInputMode(WebTextInputMode::kWebTextInputModeKana, | |
| 829 "input_mode_type_kana.html"); | |
| 830 testInputMode(WebTextInputMode::kWebTextInputModeKanaName, | |
| 831 "input_mode_type_kana_name.html"); | |
| 832 testInputMode(WebTextInputMode::kWebTextInputModeKataKana, | |
| 833 "input_mode_type_kata_kana.html"); | |
| 834 testInputMode(WebTextInputMode::kWebTextInputModeNumeric, | |
| 835 "input_mode_type_numeric.html"); | |
| 836 testInputMode(WebTextInputMode::kWebTextInputModeTel, | |
| 837 "input_mode_type_tel.html"); | |
| 838 testInputMode(WebTextInputMode::kWebTextInputModeEmail, | |
| 839 "input_mode_type_email.html"); | |
| 840 testInputMode(WebTextInputMode::kWebTextInputModeUrl, | |
| 841 "input_mode_type_url.html"); | |
| 815 } | 842 } |
| 816 | 843 |
| 817 TEST_F(WebViewTest, TextInputInfoWithReplacedElements) { | 844 TEST_F(WebViewTest, TextInputInfoWithReplacedElements) { |
| 818 std::string url = m_baseURL + "div_with_image.html"; | 845 std::string url = m_baseURL + "div_with_image.html"; |
| 819 URLTestHelpers::registerMockedURLLoad(toKURL(url), "div_with_image.html"); | 846 URLTestHelpers::registerMockedURLLoad(toKURL(url), "div_with_image.html"); |
| 820 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com/foo.png"), | 847 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com/foo.png"), |
| 821 "white-1x1.png"); | 848 "white-1x1.png"); |
| 822 WebView* webView = m_webViewHelper.initializeAndLoad(url); | 849 WebView* webView = m_webViewHelper.initializeAndLoad(url); |
| 823 webView->setInitialFocus(false); | 850 webView->setInitialFocus(false); |
| 824 WebTextInputInfo info = webView->textInputInfo(); | 851 WebTextInputInfo info = webView->textInputInfo(); |
| (...skipping 3305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4130 .translate(50, 55) | 4157 .translate(50, 55) |
| 4131 .scale(1. / 2.f); | 4158 .scale(1. / 2.f); |
| 4132 EXPECT_EQ(expectedMatrix, | 4159 EXPECT_EQ(expectedMatrix, |
| 4133 webViewImpl->getDeviceEmulationTransformForTesting()); | 4160 webViewImpl->getDeviceEmulationTransformForTesting()); |
| 4134 // visibleContentRect doesn't change. | 4161 // visibleContentRect doesn't change. |
| 4135 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4162 EXPECT_EQ(IntRect(50, 55, 50, 75), |
| 4136 *devToolsEmulator->visibleContentRectForPainting()); | 4163 *devToolsEmulator->visibleContentRectForPainting()); |
| 4137 } | 4164 } |
| 4138 | 4165 |
| 4139 } // namespace blink | 4166 } // namespace blink |
| OLD | NEW |