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

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

Issue 540033002: use tryAllocPixels to check the result, allocPixels to require success (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « Source/platform/image-decoders/ImageFrame.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 // doesn't cause compositing 2187 // doesn't cause compositing
2188 webViewHelper.webView()->settings()->setViewportEnabled(true); 2188 webViewHelper.webView()->settings()->setViewportEnabled(true);
2189 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); 2189 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
2190 webViewHelper.webView()->layout(); 2190 webViewHelper.webView()->layout();
2191 2191
2192 // Set <1 page scale so that the clip rect should be larger than 2192 // Set <1 page scale so that the clip rect should be larger than
2193 // the viewport size as passed into resize(). 2193 // the viewport size as passed into resize().
2194 webViewHelper.webView()->setPageScaleFactor(0.5); 2194 webViewHelper.webView()->setPageScaleFactor(0.5);
2195 2195
2196 SkBitmap bitmap; 2196 SkBitmap bitmap;
2197 ASSERT_TRUE(bitmap.allocN32Pixels(200, 200)); 2197 bitmap.allocN32Pixels(200, 200);
2198 bitmap.eraseColor(0); 2198 bitmap.eraseColor(0);
2199 SkCanvas canvas(bitmap); 2199 SkCanvas canvas(bitmap);
2200 2200
2201 blink::GraphicsContext context(&canvas); 2201 blink::GraphicsContext context(&canvas);
2202 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); 2202 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
2203 2203
2204 EXPECT_EQ_RECT(blink::IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); 2204 EXPECT_EQ_RECT(blink::IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
2205 2205
2206 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame View(); 2206 blink::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frame View();
2207 blink::IntRect paintRect(0, 0, 200, 200); 2207 blink::IntRect paintRect(0, 0, 200, 200);
(...skipping 3609 matching lines...) Expand 10 before | Expand all | Expand 10 after
5817 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); 5817 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true);
5818 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5818 WebFrame* frame = webViewHelper.webView()->mainFrame();
5819 FrameTestHelpers::reloadFrameIgnoringCache(frame); 5819 FrameTestHelpers::reloadFrameIgnoringCache(frame);
5820 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request( ).cachePolicy()); 5820 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request( ).cachePolicy());
5821 } 5821 }
5822 5822
5823 static void nodeImageTestValidation(const blink::IntSize& referenceBitmapSize, b link::DragImage* dragImage) 5823 static void nodeImageTestValidation(const blink::IntSize& referenceBitmapSize, b link::DragImage* dragImage)
5824 { 5824 {
5825 // Prepare the reference bitmap. 5825 // Prepare the reference bitmap.
5826 SkBitmap bitmap; 5826 SkBitmap bitmap;
5827 ASSERT_TRUE(bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitm apSize.height())); 5827 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh t());
5828 SkCanvas canvas(bitmap); 5828 SkCanvas canvas(bitmap);
5829 canvas.drawColor(SK_ColorGREEN); 5829 canvas.drawColor(SK_ColorGREEN);
5830 5830
5831 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width()); 5831 EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width());
5832 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height()); 5832 EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height());
5833 const SkBitmap& dragBitmap = dragImage->bitmap(); 5833 const SkBitmap& dragBitmap = dragImage->bitmap();
5834 SkAutoLockPixels lockPixel(dragBitmap); 5834 SkAutoLockPixels lockPixel(dragBitmap);
5835 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze())); 5835 EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSi ze()));
5836 } 5836 }
5837 5837
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6180 6180
6181 // Neither should a page reload. 6181 // Neither should a page reload.
6182 localFrame->reload(); 6182 localFrame->reload();
6183 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6183 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6184 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6184 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6185 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6185 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6186 } 6186 }
6187 6187
6188 } // namespace 6188 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/ImageFrame.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698