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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 EXPECT_EQ("image", HitTestElementId(web_view, 75, 25)); | 355 EXPECT_EQ("image", HitTestElementId(web_view, 75, 25)); |
356 EXPECT_TRUE(HitTestUrlElement(web_view, 75, 25).IsNull()); | 356 EXPECT_TRUE(HitTestUrlElement(web_view, 75, 25).IsNull()); |
357 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 75, 25)); | 357 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 75, 25)); |
358 } | 358 } |
359 | 359 |
360 TEST_P(WebViewTest, BrokenImage) { | 360 TEST_P(WebViewTest, BrokenImage) { |
361 URLTestHelpers::RegisterMockedErrorURLLoad( | 361 URLTestHelpers::RegisterMockedErrorURLLoad( |
362 KURL(ToKURL(base_url_), "non_existent.png")); | 362 KURL(ToKURL(base_url_), "non_existent.png")); |
363 std::string url = RegisterMockedHttpURLLoad("image-broken.html"); | 363 std::string url = RegisterMockedHttpURLLoad("image-broken.html"); |
364 | 364 |
365 WebView* web_view = web_view_helper_.Initialize(); | 365 WebViewBase* web_view = web_view_helper_.Initialize(); |
366 web_view->GetSettings()->SetLoadsImagesAutomatically(true); | 366 web_view->GetSettings()->SetLoadsImagesAutomatically(true); |
367 LoadFrame(web_view->MainFrame(), url); | 367 LoadFrame(web_view->MainFrameImpl(), url); |
368 web_view->Resize(WebSize(400, 400)); | 368 web_view->Resize(WebSize(400, 400)); |
369 | 369 |
370 std::string image_url = "http://www.test.com/non_existent.png"; | 370 std::string image_url = "http://www.test.com/non_existent.png"; |
371 | 371 |
372 EXPECT_EQ("image", HitTestElementId(web_view, 25, 25)); | 372 EXPECT_EQ("image", HitTestElementId(web_view, 25, 25)); |
373 EXPECT_TRUE(HitTestUrlElement(web_view, 25, 25).IsNull()); | 373 EXPECT_TRUE(HitTestUrlElement(web_view, 25, 25).IsNull()); |
374 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 25, 25)); | 374 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 25, 25)); |
375 } | 375 } |
376 | 376 |
377 TEST_P(WebViewTest, BrokenInputImage) { | 377 TEST_P(WebViewTest, BrokenInputImage) { |
378 URLTestHelpers::RegisterMockedErrorURLLoad( | 378 URLTestHelpers::RegisterMockedErrorURLLoad( |
379 KURL(ToKURL(base_url_), "non_existent.png")); | 379 KURL(ToKURL(base_url_), "non_existent.png")); |
380 std::string url = RegisterMockedHttpURLLoad("input-image-broken.html"); | 380 std::string url = RegisterMockedHttpURLLoad("input-image-broken.html"); |
381 | 381 |
382 WebView* web_view = web_view_helper_.Initialize(); | 382 WebViewBase* web_view = web_view_helper_.Initialize(); |
383 web_view->GetSettings()->SetLoadsImagesAutomatically(true); | 383 web_view->GetSettings()->SetLoadsImagesAutomatically(true); |
384 LoadFrame(web_view->MainFrame(), url); | 384 LoadFrame(web_view->MainFrameImpl(), url); |
385 web_view->Resize(WebSize(400, 400)); | 385 web_view->Resize(WebSize(400, 400)); |
386 | 386 |
387 std::string image_url = "http://www.test.com/non_existent.png"; | 387 std::string image_url = "http://www.test.com/non_existent.png"; |
388 | 388 |
389 EXPECT_EQ("image", HitTestElementId(web_view, 25, 25)); | 389 EXPECT_EQ("image", HitTestElementId(web_view, 25, 25)); |
390 EXPECT_TRUE(HitTestUrlElement(web_view, 25, 25).IsNull()); | 390 EXPECT_TRUE(HitTestUrlElement(web_view, 25, 25).IsNull()); |
391 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 25, 25)); | 391 EXPECT_EQ(image_url, HitTestAbsoluteUrl(web_view, 25, 25)); |
392 } | 392 } |
393 | 393 |
394 TEST_P(WebViewTest, SetBaseBackgroundColor) { | 394 TEST_P(WebViewTest, SetBaseBackgroundColor) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 web_view->SetPageScaleFactor(2.0f); | 571 web_view->SetPageScaleFactor(2.0f); |
572 WebHitTestResult positive_result = web_view->HitTestResultAt(hit_point); | 572 WebHitTestResult positive_result = web_view->HitTestResultAt(hit_point); |
573 EXPECT_TRUE(positive_result.GetNode().To<WebElement>().HasHTMLTagName("img")); | 573 EXPECT_TRUE(positive_result.GetNode().To<WebElement>().HasHTMLTagName("img")); |
574 positive_result.Reset(); | 574 positive_result.Reset(); |
575 } | 575 } |
576 | 576 |
577 TEST_P(WebViewTest, HitTestResultAtWithPageScaleAndPan) { | 577 TEST_P(WebViewTest, HitTestResultAtWithPageScaleAndPan) { |
578 std::string url = base_url_ + "specify_size.html?" + "50px" + ":" + "50px"; | 578 std::string url = base_url_ + "specify_size.html?" + "50px" + ":" + "50px"; |
579 URLTestHelpers::RegisterMockedURLLoad( | 579 URLTestHelpers::RegisterMockedURLLoad( |
580 ToKURL(url), testing::WebTestDataPath("specify_size.html")); | 580 ToKURL(url), testing::WebTestDataPath("specify_size.html")); |
581 WebView* web_view = web_view_helper_.Initialize(); | 581 WebViewBase* web_view = web_view_helper_.Initialize(); |
582 LoadFrame(web_view->MainFrame(), url); | 582 LoadFrame(web_view->MainFrameImpl(), url); |
583 web_view->Resize(WebSize(100, 100)); | 583 web_view->Resize(WebSize(100, 100)); |
584 WebPoint hit_point(75, 75); | 584 WebPoint hit_point(75, 75); |
585 | 585 |
586 // Image is at top left quandrant, so should not hit it. | 586 // Image is at top left quandrant, so should not hit it. |
587 WebHitTestResult negative_result = web_view->HitTestResultAt(hit_point); | 587 WebHitTestResult negative_result = web_view->HitTestResultAt(hit_point); |
588 EXPECT_FALSE( | 588 EXPECT_FALSE( |
589 negative_result.GetNode().To<WebElement>().HasHTMLTagName("img")); | 589 negative_result.GetNode().To<WebElement>().HasHTMLTagName("img")); |
590 negative_result.Reset(); | 590 negative_result.Reset(); |
591 | 591 |
592 // Scale page up 2x so image should occupy the whole viewport. | 592 // Scale page up 2x so image should occupy the whole viewport. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 hit_point = WebPoint(61, 61); | 626 hit_point = WebPoint(61, 61); |
627 WebHitTestResult negative_result2 = | 627 WebHitTestResult negative_result2 = |
628 web_view->HitTestResultForTap(hit_point, tap_area); | 628 web_view->HitTestResultForTap(hit_point, tap_area); |
629 EXPECT_FALSE( | 629 EXPECT_FALSE( |
630 negative_result2.GetNode().To<WebElement>().HasHTMLTagName("img")); | 630 negative_result2.GetNode().To<WebElement>().HasHTMLTagName("img")); |
631 negative_result2.Reset(); | 631 negative_result2.Reset(); |
632 } | 632 } |
633 | 633 |
634 TEST_P(WebViewTest, HitTestResultForTapWithTapAreaPageScaleAndPan) { | 634 TEST_P(WebViewTest, HitTestResultForTapWithTapAreaPageScaleAndPan) { |
635 std::string url = RegisterMockedHttpURLLoad("hit_test.html"); | 635 std::string url = RegisterMockedHttpURLLoad("hit_test.html"); |
636 WebView* web_view = web_view_helper_.Initialize(); | 636 WebViewBase* web_view = web_view_helper_.Initialize(); |
637 LoadFrame(web_view->MainFrame(), url); | 637 LoadFrame(web_view->MainFrameImpl(), url); |
638 web_view->Resize(WebSize(100, 100)); | 638 web_view->Resize(WebSize(100, 100)); |
639 WebPoint hit_point(55, 55); | 639 WebPoint hit_point(55, 55); |
640 | 640 |
641 // Image is at top left quandrant, so should not hit it. | 641 // Image is at top left quandrant, so should not hit it. |
642 WebHitTestResult negative_result = web_view->HitTestResultAt(hit_point); | 642 WebHitTestResult negative_result = web_view->HitTestResultAt(hit_point); |
643 EXPECT_FALSE( | 643 EXPECT_FALSE( |
644 negative_result.GetNode().To<WebElement>().HasHTMLTagName("img")); | 644 negative_result.GetNode().To<WebElement>().HasHTMLTagName("img")); |
645 negative_result.Reset(); | 645 negative_result.Reset(); |
646 | 646 |
647 // The tap area is 20 by 20 square, centered at 55, 55. | 647 // The tap area is 20 by 20 square, centered at 55, 55. |
(...skipping 2546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3194 web_view_helper_.WebView()->MainFrameImpl()->DispatchUnloadEvent(); | 3194 web_view_helper_.WebView()->MainFrameImpl()->DispatchUnloadEvent(); |
3195 EXPECT_EQ(0, frame_client.Count()); | 3195 EXPECT_EQ(0, frame_client.Count()); |
3196 web_view_helper_.Reset(); | 3196 web_view_helper_.Reset(); |
3197 } | 3197 } |
3198 | 3198 |
3199 TEST_P(WebViewTest, AddFrameInNavigateUnload) { | 3199 TEST_P(WebViewTest, AddFrameInNavigateUnload) { |
3200 CreateChildCounterFrameClient frame_client; | 3200 CreateChildCounterFrameClient frame_client; |
3201 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); | 3201 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); |
3202 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", | 3202 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", |
3203 &frame_client); | 3203 &frame_client); |
3204 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrame(), | 3204 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrameImpl(), |
3205 "about:blank"); | 3205 "about:blank"); |
3206 EXPECT_EQ(0, frame_client.Count()); | 3206 EXPECT_EQ(0, frame_client.Count()); |
3207 web_view_helper_.Reset(); | 3207 web_view_helper_.Reset(); |
3208 } | 3208 } |
3209 | 3209 |
3210 TEST_P(WebViewTest, AddFrameInChildInNavigateUnload) { | 3210 TEST_P(WebViewTest, AddFrameInChildInNavigateUnload) { |
3211 CreateChildCounterFrameClient frame_client; | 3211 CreateChildCounterFrameClient frame_client; |
3212 RegisterMockedHttpURLLoad("add_frame_in_unload_wrapper.html"); | 3212 RegisterMockedHttpURLLoad("add_frame_in_unload_wrapper.html"); |
3213 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); | 3213 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); |
3214 web_view_helper_.InitializeAndLoad( | 3214 web_view_helper_.InitializeAndLoad( |
3215 base_url_ + "add_frame_in_unload_wrapper.html", &frame_client); | 3215 base_url_ + "add_frame_in_unload_wrapper.html", &frame_client); |
3216 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrame(), | 3216 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrameImpl(), |
3217 "about:blank"); | 3217 "about:blank"); |
3218 EXPECT_EQ(1, frame_client.Count()); | 3218 EXPECT_EQ(1, frame_client.Count()); |
3219 web_view_helper_.Reset(); | 3219 web_view_helper_.Reset(); |
3220 } | 3220 } |
3221 | 3221 |
3222 class TouchEventHandlerWebWidgetClient | 3222 class TouchEventHandlerWebWidgetClient |
3223 : public FrameTestHelpers::TestWebWidgetClient { | 3223 : public FrameTestHelpers::TestWebWidgetClient { |
3224 public: | 3224 public: |
3225 // WebWidgetClient methods | 3225 // WebWidgetClient methods |
3226 void HasTouchEventHandlers(bool state) override { | 3226 void HasTouchEventHandlers(bool state) override { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3542 | 3542 |
3543 const int kMaxOutputCharacters = 1024; | 3543 const int kMaxOutputCharacters = 1024; |
3544 std::string expected = | 3544 std::string expected = |
3545 WebFrameContentDumper::DumpWebViewAsText(web_view, kMaxOutputCharacters) | 3545 WebFrameContentDumper::DumpWebViewAsText(web_view, kMaxOutputCharacters) |
3546 .Utf8(); | 3546 .Utf8(); |
3547 EXPECT_EQ(expected, actual); | 3547 EXPECT_EQ(expected, actual); |
3548 } | 3548 } |
3549 | 3549 |
3550 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { | 3550 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { |
3551 std::string url = RegisterMockedHttpURLLoad("subtree-layout.html"); | 3551 std::string url = RegisterMockedHttpURLLoad("subtree-layout.html"); |
3552 WebView* web_view = web_view_helper_.Initialize(); | 3552 WebViewBase* web_view = web_view_helper_.Initialize(); |
3553 | 3553 |
3554 web_view->EnableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); | 3554 web_view->EnableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); |
3555 LoadFrame(web_view->MainFrame(), url); | 3555 LoadFrame(web_view->MainFrameImpl(), url); |
3556 | 3556 |
3557 LocalFrameView* frame_view = | 3557 LocalFrameView* frame_view = |
3558 web_view_helper_.WebView()->MainFrameImpl()->GetFrameView(); | 3558 web_view_helper_.WebView()->MainFrameImpl()->GetFrameView(); |
3559 | 3559 |
3560 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. | 3560 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. |
3561 // This EXPECT is merely a dummy. The real test is that we don't trigger | 3561 // This EXPECT is merely a dummy. The real test is that we don't trigger |
3562 // asserts in debug builds. | 3562 // asserts in debug builds. |
3563 EXPECT_FALSE(frame_view->NeedsLayout()); | 3563 EXPECT_FALSE(frame_view->NeedsLayout()); |
3564 }; | 3564 }; |
3565 | 3565 |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4337 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4337 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |
4338 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 4338 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { |
4339 EXPECT_NE(nullptr, | 4339 EXPECT_NE(nullptr, |
4340 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4340 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |
4341 } else { | 4341 } else { |
4342 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4342 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |
4343 } | 4343 } |
4344 } | 4344 } |
4345 | 4345 |
4346 } // namespace blink | 4346 } // namespace blink |
OLD | NEW |