OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 7465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7476 FrameTestHelpers::LoadHTMLString(frame, kBluePNG, test_url); | 7476 FrameTestHelpers::LoadHTMLString(frame, kBluePNG, test_url); |
7477 | 7477 |
7478 WebNode node = frame->GetDocument().Body().FirstChild(); | 7478 WebNode node = frame->GetDocument().Body().FirstChild(); |
7479 EXPECT_TRUE(node.IsElementNode()); | 7479 EXPECT_TRUE(node.IsElementNode()); |
7480 WebElement element = node.To<WebElement>(); | 7480 WebElement element = node.To<WebElement>(); |
7481 WebImage image = element.ImageContents(); | 7481 WebImage image = element.ImageContents(); |
7482 ASSERT_FALSE(image.IsNull()); | 7482 ASSERT_FALSE(image.IsNull()); |
7483 EXPECT_EQ(image.Size().width, 10); | 7483 EXPECT_EQ(image.Size().width, 10); |
7484 EXPECT_EQ(image.Size().height, 10); | 7484 EXPECT_EQ(image.Size().height, 10); |
7485 SkBitmap bitmap = image.GetSkBitmap(); | 7485 SkBitmap bitmap = image.GetSkBitmap(); |
7486 SkAutoLockPixels locker(bitmap); | |
7487 EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); | 7486 EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE); |
7488 } | 7487 } |
7489 | 7488 |
7490 class TestStartStopCallbackWebFrameClient | 7489 class TestStartStopCallbackWebFrameClient |
7491 : public FrameTestHelpers::TestWebFrameClient { | 7490 : public FrameTestHelpers::TestWebFrameClient { |
7492 public: | 7491 public: |
7493 TestStartStopCallbackWebFrameClient() | 7492 TestStartStopCallbackWebFrameClient() |
7494 : start_loading_count_(0), | 7493 : start_loading_count_(0), |
7495 stop_loading_count_(0), | 7494 stop_loading_count_(0), |
7496 different_document_start_count_(0) {} | 7495 different_document_start_count_(0) {} |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8577 // Prepare the reference bitmap. | 8576 // Prepare the reference bitmap. |
8578 SkBitmap bitmap; | 8577 SkBitmap bitmap; |
8579 bitmap.allocN32Pixels(reference_bitmap_size.Width(), | 8578 bitmap.allocN32Pixels(reference_bitmap_size.Width(), |
8580 reference_bitmap_size.Height()); | 8579 reference_bitmap_size.Height()); |
8581 SkCanvas canvas(bitmap); | 8580 SkCanvas canvas(bitmap); |
8582 canvas.drawColor(SK_ColorGREEN); | 8581 canvas.drawColor(SK_ColorGREEN); |
8583 | 8582 |
8584 EXPECT_EQ(reference_bitmap_size.Width(), drag_image->Size().Width()); | 8583 EXPECT_EQ(reference_bitmap_size.Width(), drag_image->Size().Width()); |
8585 EXPECT_EQ(reference_bitmap_size.Height(), drag_image->Size().Height()); | 8584 EXPECT_EQ(reference_bitmap_size.Height(), drag_image->Size().Height()); |
8586 const SkBitmap& drag_bitmap = drag_image->Bitmap(); | 8585 const SkBitmap& drag_bitmap = drag_image->Bitmap(); |
8587 SkAutoLockPixels lock_pixel(drag_bitmap); | |
8588 EXPECT_EQ( | 8586 EXPECT_EQ( |
8589 0, memcmp(bitmap.getPixels(), drag_bitmap.getPixels(), bitmap.getSize())); | 8587 0, memcmp(bitmap.getPixels(), drag_bitmap.getPixels(), bitmap.getSize())); |
8590 } | 8588 } |
8591 | 8589 |
8592 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant) { | 8590 TEST_P(ParameterizedWebFrameTest, NodeImageTestCSSTransformDescendant) { |
8593 FrameTestHelpers::WebViewHelper web_view_helper; | 8591 FrameTestHelpers::WebViewHelper web_view_helper; |
8594 std::unique_ptr<DragImage> drag_image = NodeImageTestSetup( | 8592 std::unique_ptr<DragImage> drag_image = NodeImageTestSetup( |
8595 &web_view_helper, std::string("case-css-3dtransform-descendant")); | 8593 &web_view_helper, std::string("case-css-3dtransform-descendant")); |
8596 EXPECT_TRUE(drag_image); | 8594 EXPECT_TRUE(drag_image); |
8597 | 8595 |
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10619 WebLocalFrame* local_frame = web_view->MainFrameImpl(); | 10617 WebLocalFrame* local_frame = web_view->MainFrameImpl(); |
10620 local_frame->CopyImageAt(WebPoint(50, 50)); | 10618 local_frame->CopyImageAt(WebPoint(50, 50)); |
10621 | 10619 |
10622 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( | 10620 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( |
10623 WebClipboard::kBufferStandard)); | 10621 WebClipboard::kBufferStandard)); |
10624 | 10622 |
10625 WebImage image = | 10623 WebImage image = |
10626 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) | 10624 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) |
10627 ->ReadRawImage(WebClipboard::Buffer()); | 10625 ->ReadRawImage(WebClipboard::Buffer()); |
10628 | 10626 |
10629 SkAutoLockPixels auto_lock(image.GetSkBitmap()); | |
10630 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); | 10627 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); |
10631 }; | 10628 }; |
10632 | 10629 |
10633 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { | 10630 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { |
10634 std::string url = base_url_ + "canvas-copy-image.html"; | 10631 std::string url = base_url_ + "canvas-copy-image.html"; |
10635 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html"); | 10632 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html"); |
10636 | 10633 |
10637 FrameTestHelpers::WebViewHelper helper; | 10634 FrameTestHelpers::WebViewHelper helper; |
10638 WebViewImpl* web_view = helper.InitializeAndLoad(url, true, 0); | 10635 WebViewImpl* web_view = helper.InitializeAndLoad(url, true, 0); |
10639 web_view->Resize(WebSize(400, 400)); | 10636 web_view->Resize(WebSize(400, 400)); |
10640 web_view->UpdateAllLifecyclePhases(); | 10637 web_view->UpdateAllLifecyclePhases(); |
10641 web_view->SetPageScaleFactor(2); | 10638 web_view->SetPageScaleFactor(2); |
10642 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200)); | 10639 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200)); |
10643 | 10640 |
10644 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber( | 10641 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber( |
10645 WebClipboard::kBufferStandard); | 10642 WebClipboard::kBufferStandard); |
10646 | 10643 |
10647 WebLocalFrame* local_frame = web_view->MainFrameImpl(); | 10644 WebLocalFrame* local_frame = web_view->MainFrameImpl(); |
10648 local_frame->CopyImageAt(WebPoint(0, 0)); | 10645 local_frame->CopyImageAt(WebPoint(0, 0)); |
10649 | 10646 |
10650 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( | 10647 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( |
10651 WebClipboard::kBufferStandard)); | 10648 WebClipboard::kBufferStandard)); |
10652 | 10649 |
10653 WebImage image = | 10650 WebImage image = |
10654 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) | 10651 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) |
10655 ->ReadRawImage(WebClipboard::Buffer()); | 10652 ->ReadRawImage(WebClipboard::Buffer()); |
10656 | 10653 |
10657 SkAutoLockPixels auto_lock(image.GetSkBitmap()); | |
10658 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); | 10654 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); |
10659 }; | 10655 }; |
10660 | 10656 |
10661 TEST_F(WebFrameTest, CopyImageWithImageMap) { | 10657 TEST_F(WebFrameTest, CopyImageWithImageMap) { |
10662 SaveImageFromDataURLWebFrameClient client; | 10658 SaveImageFromDataURLWebFrameClient client; |
10663 | 10659 |
10664 std::string url = base_url_ + "image-map.html"; | 10660 std::string url = base_url_ + "image-map.html"; |
10665 RegisterMockedURLLoadFromBase(base_url_, "image-map.html"); | 10661 RegisterMockedURLLoadFromBase(base_url_, "image-map.html"); |
10666 | 10662 |
10667 FrameTestHelpers::WebViewHelper helper; | 10663 FrameTestHelpers::WebViewHelper helper; |
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12001 | 11997 |
12002 // Failing the original child frame navigation and trying to render fallback | 11998 // Failing the original child frame navigation and trying to render fallback |
12003 // content shouldn't crash. It should return NoLoadInProgress. This is so the | 11999 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
12004 // caller won't attempt to replace the correctly empty frame with an error | 12000 // caller won't attempt to replace the correctly empty frame with an error |
12005 // page. | 12001 // page. |
12006 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, | 12002 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
12007 child->MaybeRenderFallbackContent(WebURLError())); | 12003 child->MaybeRenderFallbackContent(WebURLError())); |
12008 } | 12004 } |
12009 | 12005 |
12010 } // namespace blink | 12006 } // namespace blink |
OLD | NEW |