Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

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

Powered by Google App Engine
This is Rietveld 408576698