| 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 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 1943 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); |
| 1944 webView->resize(WebSize(640, 480)); | 1944 webView->resize(WebSize(640, 480)); |
| 1945 webView->setPageScaleFactor(pageScaleFactor); | 1945 webView->setPageScaleFactor(pageScaleFactor); |
| 1946 webView->layout(); | 1946 webView->layout(); |
| 1947 runPendingTasks(); | 1947 runPendingTasks(); |
| 1948 | 1948 |
| 1949 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1949 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 1950 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 1950 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
| 1951 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); | 1951 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); |
| 1952 | 1952 |
| 1953 WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
Factor()); | |
| 1954 WebRect actualRootBounds; | |
| 1955 webView->getSelectionRootBounds(actualRootBounds); | |
| 1956 ASSERT_EQ(expectedRootBounds, actualRootBounds); | |
| 1957 | |
| 1958 WebRect anchor, focus; | 1953 WebRect anchor, focus; |
| 1959 webView->selectionBounds(anchor, focus); | 1954 webView->selectionBounds(anchor, focus); |
| 1960 IntRect expectedIntRect = expectedRootBounds; | 1955 IntRect expectedIntRect = ExpectedRootBounds(document, webView->pageScaleFac
tor()); |
| 1961 ASSERT_TRUE(expectedIntRect.contains(anchor)); | 1956 ASSERT_TRUE(expectedIntRect.contains(anchor)); |
| 1962 // The "overflow" tests have the focus boundary outside of the element box. | 1957 // The "overflow" tests have the focus boundary outside of the element box. |
| 1963 ASSERT_EQ(url.find("overflow") == std::string::npos, expectedIntRect.contain
s(focus)); | 1958 ASSERT_EQ(url.find("overflow") == std::string::npos, expectedIntRect.contain
s(focus)); |
| 1964 } | 1959 } |
| 1965 | 1960 |
| 1966 TEST_F(WebViewTest, GetSelectionRootBounds) | |
| 1967 { | |
| 1968 // Register all the pages we will be using. | |
| 1969 registerMockedHttpURLLoad("select_range_basic.html"); | |
| 1970 registerMockedHttpURLLoad("select_range_div_editable.html"); | |
| 1971 registerMockedHttpURLLoad("select_range_scroll.html"); | |
| 1972 registerMockedHttpURLLoad("select_range_span_editable.html"); | |
| 1973 registerMockedHttpURLLoad("select_range_input.html"); | |
| 1974 registerMockedHttpURLLoad("select_range_input_overflow.html"); | |
| 1975 registerMockedHttpURLLoad("select_range_textarea.html"); | |
| 1976 registerMockedHttpURLLoad("select_range_textarea_overflow.html"); | |
| 1977 registerMockedHttpURLLoad("select_range_iframe.html"); | |
| 1978 registerMockedHttpURLLoad("select_range_iframe_div_editable.html"); | |
| 1979 registerMockedHttpURLLoad("select_range_iframe_scroll.html"); | |
| 1980 registerMockedHttpURLLoad("select_range_iframe_span_editable.html"); | |
| 1981 registerMockedHttpURLLoad("select_range_iframe_input.html"); | |
| 1982 registerMockedHttpURLLoad("select_range_iframe_input_overflow.html"); | |
| 1983 registerMockedHttpURLLoad("select_range_iframe_textarea.html"); | |
| 1984 registerMockedHttpURLLoad("select_range_iframe_textarea_overflow.html"); | |
| 1985 | |
| 1986 // Test with simple pages. | |
| 1987 testSelectionRootBounds("select_range_basic.html", 1.0f); | |
| 1988 testSelectionRootBounds("select_range_div_editable.html", 1.0f); | |
| 1989 testSelectionRootBounds("select_range_scroll.html", 1.0f); | |
| 1990 testSelectionRootBounds("select_range_span_editable.html", 1.0f); | |
| 1991 testSelectionRootBounds("select_range_input.html", 1.0f); | |
| 1992 testSelectionRootBounds("select_range_input_overflow.html", 1.0f); | |
| 1993 testSelectionRootBounds("select_range_textarea.html", 1.0f); | |
| 1994 testSelectionRootBounds("select_range_textarea_overflow.html", 1.0f); | |
| 1995 | |
| 1996 // Test with the same pages as above in iframes. | |
| 1997 testSelectionRootBounds("select_range_iframe.html", 1.0f); | |
| 1998 testSelectionRootBounds("select_range_iframe_div_editable.html", 1.0f); | |
| 1999 testSelectionRootBounds("select_range_iframe_scroll.html", 1.0f); | |
| 2000 testSelectionRootBounds("select_range_iframe_span_editable.html", 1.0f); | |
| 2001 testSelectionRootBounds("select_range_iframe_input.html", 1.0f); | |
| 2002 testSelectionRootBounds("select_range_iframe_input_overflow.html", 1.0f); | |
| 2003 testSelectionRootBounds("select_range_iframe_textarea.html", 1.0f); | |
| 2004 testSelectionRootBounds("select_range_iframe_textarea_overflow.html", 1.0f); | |
| 2005 | |
| 2006 // Basic page with scale factor. | |
| 2007 testSelectionRootBounds("select_range_basic.html", 0.0f); | |
| 2008 testSelectionRootBounds("select_range_basic.html", 0.1f); | |
| 2009 testSelectionRootBounds("select_range_basic.html", 1.5f); | |
| 2010 testSelectionRootBounds("select_range_basic.html", 2.0f); | |
| 2011 } | |
| 2012 | |
| 2013 TEST_F(WebViewTest, GetSelectionRootBoundsBrokenHeight) | |
| 2014 { | |
| 2015 WebSize contentSize = WebSize(640, 480); | |
| 2016 | |
| 2017 registerMockedHttpURLLoad("select_range_basic_broken_height.html"); | |
| 2018 | |
| 2019 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "select_ran
ge_basic_broken_height.html", true); | |
| 2020 webView->resize(contentSize); | |
| 2021 webView->setPageScaleFactor(1.0f, WebPoint(0, 0)); | |
| 2022 webView->layout(); | |
| 2023 runPendingTasks(); | |
| 2024 | |
| 2025 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | |
| 2026 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | |
| 2027 | |
| 2028 WebRect expectedRootBounds = WebRect(0, 0, contentSize.width, contentSize.he
ight); | |
| 2029 WebRect actualRootBounds; | |
| 2030 webView->getSelectionRootBounds(actualRootBounds); | |
| 2031 ASSERT_EQ(expectedRootBounds, actualRootBounds); | |
| 2032 } | |
| 2033 | |
| 2034 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView
Client { | 1961 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView
Client { |
| 2035 public: | 1962 public: |
| 2036 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } | 1963 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } |
| 2037 | 1964 |
| 2038 // WebWidgetClient methods | 1965 // WebWidgetClient methods |
| 2039 virtual void didUpdateTextOfFocusedElementByNonUserInput() override | 1966 virtual void didUpdateTextOfFocusedElementByNonUserInput() override |
| 2040 { | 1967 { |
| 2041 m_textIsUpdated = true; | 1968 m_textIsUpdated = true; |
| 2042 } | 1969 } |
| 2043 | 1970 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 loadFrame(webView->mainFrame(), url); | 2156 loadFrame(webView->mainFrame(), url); |
| 2230 | 2157 |
| 2231 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2158 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
| 2232 | 2159 |
| 2233 // Auto-resizing used to ASSERT(needsLayout()) in RenderBlockFlow::layout. T
his EXPECT is | 2160 // Auto-resizing used to ASSERT(needsLayout()) in RenderBlockFlow::layout. T
his EXPECT is |
| 2234 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. | 2161 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. |
| 2235 EXPECT_FALSE(frameView->needsLayout()); | 2162 EXPECT_FALSE(frameView->needsLayout()); |
| 2236 }; | 2163 }; |
| 2237 | 2164 |
| 2238 } // namespace | 2165 } // namespace |
| OLD | NEW |