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/PtrUtil.h" | 33 #include "wtf/PassOwnPtr.h" |
34 #include <memory> | |
35 | 34 |
36 namespace blink { | 35 namespace blink { |
37 | 36 |
38 namespace { | 37 namespace { |
39 | 38 |
40 class TestImage : public Image { | 39 class TestImage : public Image { |
41 public: | 40 public: |
42 static PassRefPtr<TestImage> create(const IntSize& size, bool opaque) | 41 static PassRefPtr<TestImage> create(const IntSize& size, bool opaque) |
43 { | 42 { |
44 return adoptRef(new TestImage(size, opaque)); | 43 return adoptRef(new TestImage(size, opaque)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 88 |
90 IntSize m_size; | 89 IntSize m_size; |
91 RefPtr<SkImage> m_image; | 90 RefPtr<SkImage> m_image; |
92 }; | 91 }; |
93 | 92 |
94 } // anonymous namespace | 93 } // anonymous namespace |
95 | 94 |
96 TEST(ImageLayerChromiumTest, imageLayerContentReset) | 95 TEST(ImageLayerChromiumTest, imageLayerContentReset) |
97 { | 96 { |
98 FakeGraphicsLayerClient client; | 97 FakeGraphicsLayerClient client; |
99 std::unique_ptr<FakeGraphicsLayer> graphicsLayer = wrapUnique(new FakeGraphi
csLayer(&client)); | 98 OwnPtr<FakeGraphicsLayer> graphicsLayer = adoptPtr(new FakeGraphicsLayer(&cl
ient)); |
100 ASSERT_TRUE(graphicsLayer.get()); | 99 ASSERT_TRUE(graphicsLayer.get()); |
101 | 100 |
102 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); | 101 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); |
103 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 102 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
104 | 103 |
105 bool opaque = false; | 104 bool opaque = false; |
106 RefPtr<Image> image = TestImage::create(IntSize(100, 100), opaque); | 105 RefPtr<Image> image = TestImage::create(IntSize(100, 100), opaque); |
107 ASSERT_TRUE(image.get()); | 106 ASSERT_TRUE(image.get()); |
108 | 107 |
109 graphicsLayer->setContentsToImage(image.get()); | 108 graphicsLayer->setContentsToImage(image.get()); |
110 ASSERT_TRUE(graphicsLayer->hasContentsLayer()); | 109 ASSERT_TRUE(graphicsLayer->hasContentsLayer()); |
111 ASSERT_TRUE(graphicsLayer->contentsLayer()); | 110 ASSERT_TRUE(graphicsLayer->contentsLayer()); |
112 | 111 |
113 graphicsLayer->setContentsToImage(0); | 112 graphicsLayer->setContentsToImage(0); |
114 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); | 113 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); |
115 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 114 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
116 } | 115 } |
117 | 116 |
118 TEST(ImageLayerChromiumTest, opaqueImages) | 117 TEST(ImageLayerChromiumTest, opaqueImages) |
119 { | 118 { |
120 FakeGraphicsLayerClient client; | 119 FakeGraphicsLayerClient client; |
121 std::unique_ptr<FakeGraphicsLayer> graphicsLayer = wrapUnique(new FakeGraphi
csLayer(&client)); | 120 OwnPtr<FakeGraphicsLayer> graphicsLayer = adoptPtr(new FakeGraphicsLayer(&cl
ient)); |
122 ASSERT_TRUE(graphicsLayer.get()); | 121 ASSERT_TRUE(graphicsLayer.get()); |
123 | 122 |
124 bool opaque = true; | 123 bool opaque = true; |
125 RefPtr<Image> opaqueImage = TestImage::create(IntSize(100, 100), opaque); | 124 RefPtr<Image> opaqueImage = TestImage::create(IntSize(100, 100), opaque); |
126 ASSERT_TRUE(opaqueImage.get()); | 125 ASSERT_TRUE(opaqueImage.get()); |
127 RefPtr<Image> nonOpaqueImage = TestImage::create(IntSize(100, 100), !opaque)
; | 126 RefPtr<Image> nonOpaqueImage = TestImage::create(IntSize(100, 100), !opaque)
; |
128 ASSERT_TRUE(nonOpaqueImage.get()); | 127 ASSERT_TRUE(nonOpaqueImage.get()); |
129 | 128 |
130 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 129 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
131 | 130 |
132 graphicsLayer->setContentsToImage(opaqueImage.get()); | 131 graphicsLayer->setContentsToImage(opaqueImage.get()); |
133 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); | 132 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); |
134 | 133 |
135 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); | 134 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); |
136 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); | 135 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); |
137 } | 136 } |
138 | 137 |
139 } // namespace blink | 138 } // namespace blink |
OLD | NEW |