OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 { | 67 { |
68 // Garbage collection is required prior to switching out the | 68 // Garbage collection is required prior to switching out the |
69 // test's memory cache; image resources are released, evicting | 69 // test's memory cache; image resources are released, evicting |
70 // them from the cache. | 70 // them from the cache. |
71 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); | 71 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); |
72 | 72 |
73 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 73 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
74 } | 74 } |
75 | 75 |
76 SkBitmap m_bitmap, m_bitmap2; | 76 SkBitmap m_bitmap, m_bitmap2; |
77 OwnPtrWillBePersistent<MemoryCache> m_globalMemoryCache; | 77 Persistent<MemoryCache> m_globalMemoryCache; |
78 }; | 78 }; |
79 | 79 |
80 // Verifies that the image resource held by an ImageBitmap is the same as the | 80 // Verifies that the image resource held by an ImageBitmap is the same as the |
81 // one held by the HTMLImageElement. | 81 // one held by the HTMLImageElement. |
82 TEST_F(ImageBitmapTest, ImageResourceConsistency) | 82 TEST_F(ImageBitmapTest, ImageResourceConsistency) |
83 { | 83 { |
84 RefPtrWillBeRawPtr<HTMLImageElement> imageElement = HTMLImageElement::create
(*Document::create().get()); | 84 RefPtrWillBeRawPtr<HTMLImageElement> imageElement = HTMLImageElement::create
(*Document::create().get()); |
85 imageElement->setImageResource(new ImageResource(BitmapImage::create(m_bitma
p).get())); | 85 imageElement->setImageResource(new ImageResource(BitmapImage::create(m_bitma
p).get())); |
86 | 86 |
87 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create(imag
eElement.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height())); | 87 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create(imag
eElement.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height())); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ASSERT_TRUE(originalImageResource->image()->bitmapForCurrentFrame(&bitmap2))
; | 191 ASSERT_TRUE(originalImageResource->image()->bitmapForCurrentFrame(&bitmap2))
; |
192 ASSERT_EQ(bitmap1.pixelRef()->pixels(), bitmap2.pixelRef()->pixels()); | 192 ASSERT_EQ(bitmap1.pixelRef()->pixels(), bitmap2.pixelRef()->pixels()); |
193 | 193 |
194 ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image()); | 194 ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image()); |
195 ASSERT_TRUE(imageBitmap->bitmapImage()->bitmapForCurrentFrame(&bitmap1)); | 195 ASSERT_TRUE(imageBitmap->bitmapImage()->bitmapForCurrentFrame(&bitmap1)); |
196 ASSERT_TRUE(newImageResource->image()->bitmapForCurrentFrame(&bitmap2)); | 196 ASSERT_TRUE(newImageResource->image()->bitmapForCurrentFrame(&bitmap2)); |
197 ASSERT_NE(bitmap1.pixelRef()->pixels(), bitmap2.pixelRef()->pixels()); | 197 ASSERT_NE(bitmap1.pixelRef()->pixels(), bitmap2.pixelRef()->pixels()); |
198 } | 198 } |
199 | 199 |
200 } // namespace | 200 } // namespace |
OLD | NEW |