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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTestWoPlatform.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/DeferredImageDecoder.h" 5 #include "platform/graphics/DeferredImageDecoder.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "platform/SharedBuffer.h" 8 #include "platform/SharedBuffer.h"
9 #include "platform/image-decoders/ImageDecoderTestHelpers.h" 9 #include "platform/image-decoders/ImageDecoderTestHelpers.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 RefPtr<SharedBuffer> fileBuffer = readFile(testFiles[i]); 97 RefPtr<SharedBuffer> fileBuffer = readFile(testFiles[i]);
98 ASSERT_NE(fileBuffer, nullptr); 98 ASSERT_NE(fileBuffer, nullptr);
99 // We need contiguous data, which SharedBuffer doesn't guarantee. 99 // We need contiguous data, which SharedBuffer doesn't guarantee.
100 sk_sp<SkData> skData = fileBuffer->getAsSkData(); 100 sk_sp<SkData> skData = fileBuffer->getAsSkData();
101 EXPECT_EQ(skData->size(), fileBuffer->size()); 101 EXPECT_EQ(skData->size(), fileBuffer->size());
102 const char* data = reinterpret_cast<const char*>(skData->bytes()); 102 const char* data = reinterpret_cast<const char*>(skData->bytes());
103 103
104 // Truncated signature (only 1 byte). Decoder instantiation should fail. 104 // Truncated signature (only 1 byte). Decoder instantiation should fail.
105 RefPtr<SharedBuffer> buffer = SharedBuffer::create<size_t>(data, 1u); 105 RefPtr<SharedBuffer> buffer = SharedBuffer::create<size_t>(data, 1u);
106 EXPECT_FALSE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer)); 106 EXPECT_FALSE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer));
107 EXPECT_EQ(nullptr, DeferredImageDecoder::create( 107 EXPECT_EQ(nullptr,
108 buffer, false, ImageDecoder::AlphaPremultiplied, 108 DeferredImageDecoder::create(buffer, false,
109 ColorBehavior::ignore())); 109 ImageDecoder::AlphaPremultiplied,
110 ColorBehavior::ignore()));
110 111
111 // Append the rest of the data. We should be able to sniff the signature 112 // Append the rest of the data. We should be able to sniff the signature
112 // now, even if segmented. 113 // now, even if segmented.
113 buffer->append<size_t>(data + 1, skData->size() - 1); 114 buffer->append<size_t>(data + 1, skData->size() - 1);
114 EXPECT_TRUE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer)); 115 EXPECT_TRUE(ImageDecoder::hasSufficientDataToSniffImageType(*buffer));
115 std::unique_ptr<DeferredImageDecoder> decoder = 116 std::unique_ptr<DeferredImageDecoder> decoder =
116 DeferredImageDecoder::create(buffer, false, 117 DeferredImageDecoder::create(buffer, false,
117 ImageDecoder::AlphaPremultiplied, 118 ImageDecoder::AlphaPremultiplied,
118 ColorBehavior::ignore()); 119 ColorBehavior::ignore());
119 ASSERT_NE(decoder, nullptr); 120 ASSERT_NE(decoder, nullptr);
120 EXPECT_TRUE(String(testFiles[i]).endsWith(decoder->filenameExtension())); 121 EXPECT_TRUE(String(testFiles[i]).endsWith(decoder->filenameExtension()));
121 } 122 }
122 } 123 }
123 124
124 } // namespace blink 125 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698