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

Side by Side Diff: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp

Issue 1184673003: Fix unit test style in Source/platform/, part 2. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32
33 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h" 32 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h"
34 33
35 #include "platform/SharedBuffer.h" 34 #include "platform/SharedBuffer.h"
36 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
37 #include "public/platform/WebData.h" 36 #include "public/platform/WebData.h"
38 #include "public/platform/WebSize.h" 37 #include "public/platform/WebSize.h"
39 #include "public/platform/WebUnitTestSupport.h" 38 #include "public/platform/WebUnitTestSupport.h"
40 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
41 #include "wtf/PassOwnPtr.h" 40 #include "wtf/PassOwnPtr.h"
42 #include "wtf/StringHasher.h" 41 #include "wtf/StringHasher.h"
43
44 #include <gtest/gtest.h> 42 #include <gtest/gtest.h>
45 43
46 using namespace blink; 44 namespace blink {
47 45
48 static const size_t LargeEnoughSize = 1000 * 1000; 46 static const size_t LargeEnoughSize = 1000 * 1000;
49 47
50 namespace { 48 namespace {
51 49
52 PassRefPtr<SharedBuffer> readFile(const char* fileName) 50 PassRefPtr<SharedBuffer> readFile(const char* fileName)
53 { 51 {
54 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); 52 String filePath = Platform::current()->unitTestSupport()->webKitRootDir();
55 filePath.append(fileName); 53 filePath.append(fileName);
56 54
57 return Platform::current()->unitTestSupport()->readFromFile(filePath); 55 return Platform::current()->unitTestSupport()->readFromFile(filePath);
58 } 56 }
59 57
60 PassOwnPtr<JPEGImageDecoder> createDecoder(size_t maxDecodedBytes) 58 PassOwnPtr<JPEGImageDecoder> createDecoder(size_t maxDecodedBytes)
61 { 59 {
62 return adoptPtr(new JPEGImageDecoder(ImageSource::AlphaNotPremultiplied, Ima geSource::GammaAndColorProfileApplied, maxDecodedBytes)); 60 return adoptPtr(new JPEGImageDecoder(ImageSource::AlphaNotPremultiplied, Ima geSource::GammaAndColorProfileApplied, maxDecodedBytes));
63 } 61 }
64 62
65 } // namespace 63 } // anonymous namespace
66 64
67 void downsample(size_t maxDecodedBytes, unsigned* outputWidth, unsigned* outputH eight, const char* imageFilePath) 65 void downsample(size_t maxDecodedBytes, unsigned* outputWidth, unsigned* outputH eight, const char* imageFilePath)
68 { 66 {
69 RefPtr<SharedBuffer> data = readFile(imageFilePath); 67 RefPtr<SharedBuffer> data = readFile(imageFilePath);
70 ASSERT_TRUE(data.get()); 68 ASSERT_TRUE(data.get());
71 69
72 OwnPtr<JPEGImageDecoder> decoder = createDecoder(maxDecodedBytes); 70 OwnPtr<JPEGImageDecoder> decoder = createDecoder(maxDecodedBytes);
73 decoder->setData(data.get(), true); 71 decoder->setData(data.get(), true);
74 72
75 ImageFrame* frame = decoder->frameBufferAtIndex(0); 73 ImageFrame* frame = decoder->frameBufferAtIndex(0);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ASSERT_TRUE(data.get()); 227 ASSERT_TRUE(data.get());
230 228
231 OwnPtr<JPEGImageDecoder> decoder = createDecoder(230 * 230 * 4); 229 OwnPtr<JPEGImageDecoder> decoder = createDecoder(230 * 230 * 4);
232 decoder->setData(data.get(), true); 230 decoder->setData(data.get(), true);
233 231
234 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes()); 232 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes());
235 decoder->setImagePlanes(imagePlanes.release()); 233 decoder->setImagePlanes(imagePlanes.release());
236 ASSERT_TRUE(decoder->isSizeAvailable()); 234 ASSERT_TRUE(decoder->isSizeAvailable());
237 ASSERT_FALSE(decoder->canDecodeToYUV()); 235 ASSERT_FALSE(decoder->canDecodeToYUV());
238 } 236 }
237
238 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698