| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 TEST(DragImageTest, NonNullHandling) | 111 TEST(DragImageTest, NonNullHandling) |
| 112 { | 112 { |
| 113 RefPtr<TestImage> testImage(TestImage::create(IntSize(2, 2))); | 113 RefPtr<TestImage> testImage(TestImage::create(IntSize(2, 2))); |
| 114 OwnPtr<DragImage> dragImage = DragImage::create(testImage.get()); | 114 OwnPtr<DragImage> dragImage = DragImage::create(testImage.get()); |
| 115 ASSERT_TRUE(dragImage); | 115 ASSERT_TRUE(dragImage); |
| 116 | 116 |
| 117 dragImage->scale(0.5, 0.5); | 117 dragImage->scale(0.5, 0.5); |
| 118 IntSize size = dragImage->size(); | 118 IntSize size = dragImage->size(); |
| 119 EXPECT_EQ(1, size.width()); | 119 EXPECT_EQ(1, size.width()); |
| 120 EXPECT_EQ(1, size.height()); | 120 EXPECT_EQ(1, size.height()); |
| 121 | |
| 122 dragImage->dissolveToFraction(0.5); | |
| 123 } | 121 } |
| 124 | 122 |
| 125 TEST(DragImageTest, CreateDragImage) | 123 TEST(DragImageTest, CreateDragImage) |
| 126 { | 124 { |
| 127 { | 125 { |
| 128 // Tests that the DrageImage implementation doesn't choke on null values | 126 // Tests that the DrageImage implementation doesn't choke on null values |
| 129 // of bitmapForCurrentFrame(). | 127 // of imageForCurrentFrame(). |
| 130 RefPtr<TestImage> testImage(TestImage::create(IntSize())); | 128 RefPtr<TestImage> testImage(TestImage::create(IntSize())); |
| 131 EXPECT_FALSE(DragImage::create(testImage.get())); | 129 EXPECT_FALSE(DragImage::create(testImage.get())); |
| 132 } | 130 } |
| 133 | |
| 134 { | |
| 135 // Tests that the drag image is a deep copy. | |
| 136 RefPtr<TestImage> testImage(TestImage::create(IntSize(1, 1))); | |
| 137 OwnPtr<DragImage> dragImage = DragImage::create(testImage.get()); | |
| 138 ASSERT_TRUE(dragImage); | |
| 139 SkBitmap bitmap; | |
| 140 EXPECT_TRUE(testImage->deprecatedBitmapForCurrentFrame(&bitmap)); | |
| 141 SkAutoLockPixels lock1(dragImage->bitmap()), lock2(bitmap); | |
| 142 EXPECT_NE(dragImage->bitmap().getPixels(), bitmap.getPixels()); | |
| 143 } | |
| 144 } | 131 } |
| 145 | 132 |
| 146 TEST(DragImageTest, TrimWhitespace) | 133 TEST(DragImageTest, TrimWhitespace) |
| 147 { | 134 { |
| 148 KURL url(ParsedURLString, "http://www.example.com/"); | 135 KURL url(ParsedURLString, "http://www.example.com/"); |
| 149 String testLabel = " Example Example Example \n "; | 136 String testLabel = " Example Example Example \n "; |
| 150 String expectedLabel = "Example Example Example"; | 137 String expectedLabel = "Example Example Example"; |
| 151 float deviceScaleFactor = 1.0f; | 138 float deviceScaleFactor = 1.0f; |
| 152 | 139 |
| 153 FontDescription fontDescription; | 140 FontDescription fontDescription; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 { | 217 { |
| 231 SkAutoLockPixels lock1(dragBitmap); | 218 SkAutoLockPixels lock1(dragBitmap); |
| 232 SkAutoLockPixels lock2(expectedBitmap); | 219 SkAutoLockPixels lock2(expectedBitmap); |
| 233 for (int x = 0; x < dragBitmap.width(); ++x) | 220 for (int x = 0; x < dragBitmap.width(); ++x) |
| 234 for (int y = 0; y < dragBitmap.height(); ++y) | 221 for (int y = 0; y < dragBitmap.height(); ++y) |
| 235 EXPECT_EQ(expectedBitmap.getColor(x, y), dragBitmap.getColor(x,
y)); | 222 EXPECT_EQ(expectedBitmap.getColor(x, y), dragBitmap.getColor(x,
y)); |
| 236 } | 223 } |
| 237 } | 224 } |
| 238 | 225 |
| 239 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |