| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 std::string m_baseURL; | 126 std::string m_baseURL; |
| 127 FrameTestHelpers::WebViewHelper m_webViewHelper; | 127 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 void TouchActionTest::runTouchActionTest(std::string file) | 130 void TouchActionTest::runTouchActionTest(std::string file) |
| 131 { | 131 { |
| 132 TouchActionTrackingWebViewClient client; | 132 TouchActionTrackingWebViewClient client; |
| 133 | 133 |
| 134 WebView* webView = setupTest(file, client); | 134 WebView* webView = setupTest(file, client); |
| 135 | 135 |
| 136 RefPtr<WebCore::Document> document = static_cast<PassRefPtr<WebCore::Documen
t> >(webView->mainFrame()->document()); | 136 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); |
| 137 runTestOnTree(document.get(), webView, client); | 137 runTestOnTree(document.get(), webView, client); |
| 138 | 138 |
| 139 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 139 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
| 140 } | 140 } |
| 141 | 141 |
| 142 void TouchActionTest::runShadowDOMTest(std::string file) | 142 void TouchActionTest::runShadowDOMTest(std::string file) |
| 143 { | 143 { |
| 144 TouchActionTrackingWebViewClient client; | 144 TouchActionTrackingWebViewClient client; |
| 145 | 145 |
| 146 WebView* webView = setupTest(file, client); | 146 WebView* webView = setupTest(file, client); |
| 147 | 147 |
| 148 WebCore::TrackExceptionState es; | 148 WebCore::TrackExceptionState es; |
| 149 RefPtr<WebCore::Document> document = static_cast<PassRefPtr<WebCore::Documen
t> >(webView->mainFrame()->document()); | 149 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); |
| 150 RefPtr<WebCore::NodeList> hostNodes = document->querySelectorAll("[shadow-ho
st]", es); | 150 RefPtr<WebCore::NodeList> hostNodes = document->querySelectorAll("[shadow-ho
st]", es); |
| 151 ASSERT_FALSE(es.hadException()); | 151 ASSERT_FALSE(es.hadException()); |
| 152 ASSERT_GE(hostNodes->length(), 1u); | 152 ASSERT_GE(hostNodes->length(), 1u); |
| 153 | 153 |
| 154 for (unsigned index = 0; index < hostNodes->length(); index++) { | 154 for (unsigned index = 0; index < hostNodes->length(); index++) { |
| 155 WebCore::ShadowRoot* shadowRoot = WebCore::toElement(hostNodes->item(ind
ex))->shadowRoot(); | 155 WebCore::ShadowRoot* shadowRoot = WebCore::toElement(hostNodes->item(ind
ex))->shadowRoot(); |
| 156 runTestOnTree(shadowRoot, webView, client); | 156 runTestOnTree(shadowRoot, webView, client); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Projections show up in the main document. | 159 // Projections show up in the main document. |
| 160 runTestOnTree(document.get(), webView, client); | 160 runTestOnTree(document.get(), webView, client); |
| 161 | 161 |
| 162 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 162 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
| 163 } | 163 } |
| 164 | 164 |
| 165 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView
Client& client) | 165 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView
Client& client) |
| 166 { | 166 { |
| 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file)); | 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file)); |
| 168 // Note that JavaScript must be enabled for shadow DOM tests. | 168 // Note that JavaScript must be enabled for shadow DOM tests. |
| 169 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true,
0, &client); | 169 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true,
0, &client); |
| 170 | 170 |
| 171 // Set size to enable hit testing, and avoid line wrapping for consistency w
ith browser. | 171 // Set size to enable hit testing, and avoid line wrapping for consistency w
ith browser. |
| 172 webView->resize(WebSize(800, 1200)); | 172 webView->resize(WebSize(800, 1200)); |
| 173 | 173 |
| 174 // Scroll to verify the code properly transforms windows to client co-ords. | 174 // Scroll to verify the code properly transforms windows to client co-ords. |
| 175 const int kScrollOffset = 100; | 175 const int kScrollOffset = 100; |
| 176 RefPtr<WebCore::Document> document = static_cast<PassRefPtr<WebCore::Documen
t> >(webView->mainFrame()->document()); | 176 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); |
| 177 document->frame()->view()->setScrollOffset(WebCore::IntPoint(0, kScrollOffse
t)); | 177 document->frame()->view()->setScrollOffset(WebCore::IntPoint(0, kScrollOffse
t)); |
| 178 | 178 |
| 179 return webView; | 179 return webView; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TouchActionTest::runTestOnTree(WebCore::ContainerNode* root, WebView* webVi
ew, TouchActionTrackingWebViewClient& client) | 182 void TouchActionTest::runTestOnTree(WebCore::ContainerNode* root, WebView* webVi
ew, TouchActionTrackingWebViewClient& client) |
| 183 { | 183 { |
| 184 // Find all elements to test the touch-action of in the document. | 184 // Find all elements to test the touch-action of in the document. |
| 185 WebCore::TrackExceptionState es; | 185 WebCore::TrackExceptionState es; |
| 186 RefPtr<WebCore::NodeList> nodes = root->querySelectorAll("[expected-action]"
, es); | 186 RefPtr<WebCore::NodeList> nodes = root->querySelectorAll("[expected-action]"
, es); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 { | 326 { |
| 327 runShadowDOMTest("touch-action-shadow-dom.html"); | 327 runShadowDOMTest("touch-action-shadow-dom.html"); |
| 328 } | 328 } |
| 329 | 329 |
| 330 TEST_F(TouchActionTest, Pan) | 330 TEST_F(TouchActionTest, Pan) |
| 331 { | 331 { |
| 332 runTouchActionTest("touch-action-pan.html"); | 332 runTouchActionTest("touch-action-pan.html"); |
| 333 } | 333 } |
| 334 | 334 |
| 335 } | 335 } |
| OLD | NEW |