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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 negativeResult.reset(); | 420 negativeResult.reset(); |
421 | 421 |
422 // Scale page up 2x so image should occupy the whole viewport. | 422 // Scale page up 2x so image should occupy the whole viewport. |
423 webView->setPageScaleFactor(2.0f); | 423 webView->setPageScaleFactor(2.0f); |
424 WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); | 424 WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); |
425 ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); | 425 ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); |
426 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img")); | 426 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img")); |
427 positiveResult.reset(); | 427 positiveResult.reset(); |
428 } | 428 } |
429 | 429 |
| 430 TEST_F(WebViewTest, HitTestResultForTapWithTapArea) |
| 431 { |
| 432 std::string url = m_baseURL + "hit_test.html"; |
| 433 URLTestHelpers::registerMockedURLLoad(toKURL(url), "hit_test.html"); |
| 434 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0); |
| 435 webView->resize(WebSize(100, 100)); |
| 436 WebPoint hitPoint(55, 55); |
| 437 |
| 438 // Image is at top left quandrant, so should not hit it. |
| 439 WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); |
| 440 ASSERT_EQ(WebNode::ElementNode, negativeResult.node().nodeType()); |
| 441 EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img")); |
| 442 negativeResult.reset(); |
| 443 |
| 444 // The tap area is 20 by 20 square, centered at 55, 55. |
| 445 WebSize tapArea(20, 20); |
| 446 WebHitTestResult positiveResult = webView->hitTestResultForTap(hitPoint, tap
Area); |
| 447 ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); |
| 448 EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img")); |
| 449 positiveResult.reset(); |
| 450 |
| 451 // Scale down page by half so the image is outside the tapped area now. |
| 452 webView->setPageScaleFactor(0.5f); |
| 453 WebHitTestResult negativeResult2 = webView->hitTestResultForTap(hitPoint, ta
pArea); |
| 454 ASSERT_EQ(WebNode::ElementNode, negativeResult2.node().nodeType()); |
| 455 EXPECT_FALSE(negativeResult2.node().to<WebElement>().hasHTMLTagName("img")); |
| 456 negativeResult2.reset(); |
| 457 } |
| 458 |
430 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
xAutoResize, | 459 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
xAutoResize, |
431 const std::string& pageWidth, const std::string
& pageHeight, | 460 const std::string& pageWidth, const std::string
& pageHeight, |
432 int expectedWidth, int expectedHeight, | 461 int expectedWidth, int expectedHeight, |
433 HorizontalScrollbarState expectedHorizontalStat
e, VerticalScrollbarState expectedVerticalState) | 462 HorizontalScrollbarState expectedHorizontalStat
e, VerticalScrollbarState expectedVerticalState) |
434 { | 463 { |
435 AutoResizeWebViewClient client; | 464 AutoResizeWebViewClient client; |
436 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageH
eight; | 465 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageH
eight; |
437 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); | 466 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); |
438 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); | 467 WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); |
439 client.testData().setWebView(webView); | 468 client.testData().setWebView(webView); |
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 loadFrame(webView->mainFrame(), url); | 2245 loadFrame(webView->mainFrame(), url); |
2217 | 2246 |
2218 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); | 2247 FrameView* frameView = m_webViewHelper.webViewImpl()->mainFrameImpl()->frame
View(); |
2219 | 2248 |
2220 // Auto-resizing used to ASSERT(needsLayout()) in RenderBlockFlow::layout. T
his EXPECT is | 2249 // Auto-resizing used to ASSERT(needsLayout()) in RenderBlockFlow::layout. T
his EXPECT is |
2221 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. | 2250 // merely a dummy. The real test is that we don't trigger asserts in debug b
uilds. |
2222 EXPECT_FALSE(frameView->needsLayout()); | 2251 EXPECT_FALSE(frameView->needsLayout()); |
2223 }; | 2252 }; |
2224 | 2253 |
2225 } // namespace | 2254 } // namespace |
OLD | NEW |