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(true); | 581 WebViewBase* web_view = web_view_helper_.Initialize(true); |
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(true); | 636 WebViewBase* web_view = web_view_helper_.Initialize(true); |
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 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3203 web_view_helper_.WebView()->MainFrameImpl()->DispatchUnloadEvent(); | 3203 web_view_helper_.WebView()->MainFrameImpl()->DispatchUnloadEvent(); |
3204 EXPECT_EQ(0, frame_client.Count()); | 3204 EXPECT_EQ(0, frame_client.Count()); |
3205 web_view_helper_.Reset(); | 3205 web_view_helper_.Reset(); |
3206 } | 3206 } |
3207 | 3207 |
3208 TEST_P(WebViewTest, AddFrameInNavigateUnload) { | 3208 TEST_P(WebViewTest, AddFrameInNavigateUnload) { |
3209 CreateChildCounterFrameClient frame_client; | 3209 CreateChildCounterFrameClient frame_client; |
3210 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); | 3210 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); |
3211 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", | 3211 web_view_helper_.InitializeAndLoad(base_url_ + "add_frame_in_unload.html", |
3212 true, &frame_client); | 3212 true, &frame_client); |
3213 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrame(), | 3213 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrameImpl(), |
3214 "about:blank"); | 3214 "about:blank"); |
3215 EXPECT_EQ(0, frame_client.Count()); | 3215 EXPECT_EQ(0, frame_client.Count()); |
3216 web_view_helper_.Reset(); | 3216 web_view_helper_.Reset(); |
3217 } | 3217 } |
3218 | 3218 |
3219 TEST_P(WebViewTest, AddFrameInChildInNavigateUnload) { | 3219 TEST_P(WebViewTest, AddFrameInChildInNavigateUnload) { |
3220 CreateChildCounterFrameClient frame_client; | 3220 CreateChildCounterFrameClient frame_client; |
3221 RegisterMockedHttpURLLoad("add_frame_in_unload_wrapper.html"); | 3221 RegisterMockedHttpURLLoad("add_frame_in_unload_wrapper.html"); |
3222 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); | 3222 RegisterMockedHttpURLLoad("add_frame_in_unload.html"); |
3223 web_view_helper_.InitializeAndLoad( | 3223 web_view_helper_.InitializeAndLoad( |
3224 base_url_ + "add_frame_in_unload_wrapper.html", true, &frame_client); | 3224 base_url_ + "add_frame_in_unload_wrapper.html", true, &frame_client); |
3225 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrame(), | 3225 FrameTestHelpers::LoadFrame(web_view_helper_.WebView()->MainFrameImpl(), |
3226 "about:blank"); | 3226 "about:blank"); |
3227 EXPECT_EQ(1, frame_client.Count()); | 3227 EXPECT_EQ(1, frame_client.Count()); |
3228 web_view_helper_.Reset(); | 3228 web_view_helper_.Reset(); |
3229 } | 3229 } |
3230 | 3230 |
3231 class TouchEventHandlerWebWidgetClient | 3231 class TouchEventHandlerWebWidgetClient |
3232 : public FrameTestHelpers::TestWebWidgetClient { | 3232 : public FrameTestHelpers::TestWebWidgetClient { |
3233 public: | 3233 public: |
3234 // WebWidgetClient methods | 3234 // WebWidgetClient methods |
3235 void HasTouchEventHandlers(bool state) override { | 3235 void HasTouchEventHandlers(bool state) override { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 | 3551 |
3552 const int kMaxOutputCharacters = 1024; | 3552 const int kMaxOutputCharacters = 1024; |
3553 std::string expected = | 3553 std::string expected = |
3554 WebFrameContentDumper::DumpWebViewAsText(web_view, kMaxOutputCharacters) | 3554 WebFrameContentDumper::DumpWebViewAsText(web_view, kMaxOutputCharacters) |
3555 .Utf8(); | 3555 .Utf8(); |
3556 EXPECT_EQ(expected, actual); | 3556 EXPECT_EQ(expected, actual); |
3557 } | 3557 } |
3558 | 3558 |
3559 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { | 3559 TEST_P(WebViewTest, AutoResizeSubtreeLayout) { |
3560 std::string url = RegisterMockedHttpURLLoad("subtree-layout.html"); | 3560 std::string url = RegisterMockedHttpURLLoad("subtree-layout.html"); |
3561 WebView* web_view = web_view_helper_.Initialize(true); | 3561 WebViewBase* web_view = web_view_helper_.Initialize(true); |
3562 | 3562 |
3563 web_view->EnableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); | 3563 web_view->EnableAutoResizeMode(WebSize(200, 200), WebSize(200, 200)); |
3564 LoadFrame(web_view->MainFrame(), url); | 3564 LoadFrame(web_view->MainFrameImpl(), url); |
3565 | 3565 |
3566 LocalFrameView* frame_view = | 3566 LocalFrameView* frame_view = |
3567 web_view_helper_.WebView()->MainFrameImpl()->GetFrameView(); | 3567 web_view_helper_.WebView()->MainFrameImpl()->GetFrameView(); |
3568 | 3568 |
3569 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. | 3569 // Auto-resizing used to DCHECK(needsLayout()) in LayoutBlockFlow::layout. |
3570 // This EXPECT is merely a dummy. The real test is that we don't trigger | 3570 // This EXPECT is merely a dummy. The real test is that we don't trigger |
3571 // asserts in debug builds. | 3571 // asserts in debug builds. |
3572 EXPECT_FALSE(frame_view->NeedsLayout()); | 3572 EXPECT_FALSE(frame_view->NeedsLayout()); |
3573 }; | 3573 }; |
3574 | 3574 |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4346 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4346 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |
4347 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 4347 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { |
4348 EXPECT_NE(nullptr, | 4348 EXPECT_NE(nullptr, |
4349 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4349 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |
4350 } else { | 4350 } else { |
4351 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4351 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |
4352 } | 4352 } |
4353 } | 4353 } |
4354 | 4354 |
4355 } // namespace blink | 4355 } // namespace blink |
OLD | NEW |