OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #include "platform/graphics/Image.h" | 25 #include "platform/graphics/Image.h" |
26 | 26 |
27 #include "platform/graphics/GraphicsLayer.h" | 27 #include "platform/graphics/GraphicsLayer.h" |
28 #include "platform/testing/FakeGraphicsLayer.h" | 28 #include "platform/testing/FakeGraphicsLayer.h" |
29 #include "platform/testing/FakeGraphicsLayerClient.h" | 29 #include "platform/testing/FakeGraphicsLayerClient.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "third_party/skia/include/core/SkImage.h" | 31 #include "third_party/skia/include/core/SkImage.h" |
32 #include "third_party/skia/include/core/SkSurface.h" | 32 #include "third_party/skia/include/core/SkSurface.h" |
33 #include "wtf/PassOwnPtr.h" | 33 #include "wtf/PtrUtil.h" |
| 34 #include <memory> |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 class TestImage : public Image { | 40 class TestImage : public Image { |
40 public: | 41 public: |
41 static PassRefPtr<TestImage> create(const IntSize& size, bool opaque) | 42 static PassRefPtr<TestImage> create(const IntSize& size, bool opaque) |
42 { | 43 { |
43 return adoptRef(new TestImage(size, opaque)); | 44 return adoptRef(new TestImage(size, opaque)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 89 |
89 IntSize m_size; | 90 IntSize m_size; |
90 RefPtr<SkImage> m_image; | 91 RefPtr<SkImage> m_image; |
91 }; | 92 }; |
92 | 93 |
93 } // anonymous namespace | 94 } // anonymous namespace |
94 | 95 |
95 TEST(ImageLayerChromiumTest, imageLayerContentReset) | 96 TEST(ImageLayerChromiumTest, imageLayerContentReset) |
96 { | 97 { |
97 FakeGraphicsLayerClient client; | 98 FakeGraphicsLayerClient client; |
98 OwnPtr<FakeGraphicsLayer> graphicsLayer = adoptPtr(new FakeGraphicsLayer(&cl
ient)); | 99 std::unique_ptr<FakeGraphicsLayer> graphicsLayer = wrapUnique(new FakeGraphi
csLayer(&client)); |
99 ASSERT_TRUE(graphicsLayer.get()); | 100 ASSERT_TRUE(graphicsLayer.get()); |
100 | 101 |
101 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); | 102 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); |
102 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 103 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
103 | 104 |
104 bool opaque = false; | 105 bool opaque = false; |
105 RefPtr<Image> image = TestImage::create(IntSize(100, 100), opaque); | 106 RefPtr<Image> image = TestImage::create(IntSize(100, 100), opaque); |
106 ASSERT_TRUE(image.get()); | 107 ASSERT_TRUE(image.get()); |
107 | 108 |
108 graphicsLayer->setContentsToImage(image.get()); | 109 graphicsLayer->setContentsToImage(image.get()); |
109 ASSERT_TRUE(graphicsLayer->hasContentsLayer()); | 110 ASSERT_TRUE(graphicsLayer->hasContentsLayer()); |
110 ASSERT_TRUE(graphicsLayer->contentsLayer()); | 111 ASSERT_TRUE(graphicsLayer->contentsLayer()); |
111 | 112 |
112 graphicsLayer->setContentsToImage(0); | 113 graphicsLayer->setContentsToImage(0); |
113 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); | 114 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); |
114 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 115 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
115 } | 116 } |
116 | 117 |
117 TEST(ImageLayerChromiumTest, opaqueImages) | 118 TEST(ImageLayerChromiumTest, opaqueImages) |
118 { | 119 { |
119 FakeGraphicsLayerClient client; | 120 FakeGraphicsLayerClient client; |
120 OwnPtr<FakeGraphicsLayer> graphicsLayer = adoptPtr(new FakeGraphicsLayer(&cl
ient)); | 121 std::unique_ptr<FakeGraphicsLayer> graphicsLayer = wrapUnique(new FakeGraphi
csLayer(&client)); |
121 ASSERT_TRUE(graphicsLayer.get()); | 122 ASSERT_TRUE(graphicsLayer.get()); |
122 | 123 |
123 bool opaque = true; | 124 bool opaque = true; |
124 RefPtr<Image> opaqueImage = TestImage::create(IntSize(100, 100), opaque); | 125 RefPtr<Image> opaqueImage = TestImage::create(IntSize(100, 100), opaque); |
125 ASSERT_TRUE(opaqueImage.get()); | 126 ASSERT_TRUE(opaqueImage.get()); |
126 RefPtr<Image> nonOpaqueImage = TestImage::create(IntSize(100, 100), !opaque)
; | 127 RefPtr<Image> nonOpaqueImage = TestImage::create(IntSize(100, 100), !opaque)
; |
127 ASSERT_TRUE(nonOpaqueImage.get()); | 128 ASSERT_TRUE(nonOpaqueImage.get()); |
128 | 129 |
129 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 130 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
130 | 131 |
131 graphicsLayer->setContentsToImage(opaqueImage.get()); | 132 graphicsLayer->setContentsToImage(opaqueImage.get()); |
132 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); | 133 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); |
133 | 134 |
134 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); | 135 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); |
135 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); | 136 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); |
136 } | 137 } |
137 | 138 |
138 } // namespace blink | 139 } // namespace blink |
OLD | NEW |