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

Side by Side Diff: Source/modules/imagebitmap/ImageBitmapModuleTest.cpp

Issue 1124153003: [Oilpan] [Reland] Migrate classes under core/fetch to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Work for comment Created 5 years, 5 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/frame/ImageBitmap.h" 6 #include "core/frame/ImageBitmap.h"
7 7
8 #include "bindings/core/v8/UnionTypesCore.h" 8 #include "bindings/core/v8/UnionTypesCore.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/fetch/MemoryCache.h" 10 #include "core/fetch/MemoryCache.h"
(...skipping 15 matching lines...) Expand all
26 virtual void TearDown() 26 virtual void TearDown()
27 { 27 {
28 // Garbage collection is required prior to switching out the 28 // Garbage collection is required prior to switching out the
29 // test's memory cache; image resources are released, evicting 29 // test's memory cache; image resources are released, evicting
30 // them from the cache. 30 // them from the cache.
31 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC WithSweep, Heap::ForcedGC); 31 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC WithSweep, Heap::ForcedGC);
32 32
33 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); 33 replaceMemoryCacheForTesting(m_globalMemoryCache.release());
34 } 34 }
35 35
36 OwnPtrWillBePersistent<MemoryCache> m_globalMemoryCache; 36 Persistent<MemoryCache> m_globalMemoryCache;
37 }; 37 };
38 38
39 // Verifies that ImageBitmaps constructed from ImageBitmaps hold onto their own Image. 39 // Verifies that ImageBitmaps constructed from ImageBitmaps hold onto their own Image.
40 TEST_F(ImageBitmapModuleTest, ImageResourceLifetime) 40 TEST_F(ImageBitmapModuleTest, ImageResourceLifetime)
41 { 41 {
42 RefPtrWillBeRawPtr<HTMLCanvasElement> canvasElement = HTMLCanvasElement::cre ate(*Document::create().get()); 42 RefPtrWillBeRawPtr<HTMLCanvasElement> canvasElement = HTMLCanvasElement::cre ate(*Document::create().get());
43 canvasElement->setHeight(40); 43 canvasElement->setHeight(40);
44 canvasElement->setWidth(40); 44 canvasElement->setWidth(40);
45 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapDerived = nullptr; 45 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapDerived = nullptr;
46 { 46 {
47 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapFromCanvas = ImageBitmap::cre ate(canvasElement.get(), IntRect(0, 0, canvasElement->width(), canvasElement->he ight())); 47 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapFromCanvas = ImageBitmap::cre ate(canvasElement.get(), IntRect(0, 0, canvasElement->width(), canvasElement->he ight()));
48 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas.get(), In tRect(0, 0, 20, 20)); 48 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas.get(), In tRect(0, 0, 20, 20));
49 } 49 }
50 CanvasContextCreationAttributes attributes; 50 CanvasContextCreationAttributes attributes;
51 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c anvasElement->getCanvasRenderingContext("2d", attributes)); 51 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c anvasElement->getCanvasRenderingContext("2d", attributes));
52 TrackExceptionState exceptionState; 52 TrackExceptionState exceptionState;
53 CanvasImageSourceUnion imageSource; 53 CanvasImageSourceUnion imageSource;
54 imageSource.setImageBitmap(imageBitmapDerived); 54 imageSource.setImageBitmap(imageBitmapDerived);
55 context->drawImage(imageSource, 0, 0, exceptionState); 55 context->drawImage(imageSource, 0, 0, exceptionState);
56 } 56 }
57 57
58 } // namespace 58 } // namespace
OLDNEW
« Source/core/fetch/Resource.h ('K') | « Source/core/loader/FrameFetchContextTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698