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