Chromium Code Reviews| Index: ui/gfx/codec/tiff_codec_unittest_mac.mm |
| diff --git a/ui/gfx/codec/tiff_codec_unittest_mac.mm b/ui/gfx/codec/tiff_codec_unittest_mac.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..221f9f0545d06023a7dcc9875ab4a034e083b7dd |
| --- /dev/null |
| +++ b/ui/gfx/codec/tiff_codec_unittest_mac.mm |
| @@ -0,0 +1,46 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import <Cocoa/Cocoa.h> |
| + |
| +#include "base/file_path.h" |
| +#include "base/file_util.h" |
| +#include "base/memory/scoped_nsobject.h" |
| +#include "base/path_service.h" |
| +#include "base/sys_string_conversions.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/gfx/codec/tiff_codec.h" |
| + |
| +namespace gfx { |
| + |
| +#if defined(OS_MACOSX) |
| +TEST(TIFFCodecMac, DecodeMultiImage) { |
| + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; |
|
Robert Sesek
2011/04/14 18:42:44
base::ScopedNSAutoreleasePool
|
| + |
| + FilePath data_path; |
| + ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_path)); |
| + data_path = data_path.Append(FILE_PATH_LITERAL( |
| + "../ui/gfx/test/data/tiff_codec_unittest/two_images.tiff")); |
| + |
| + NSString* path = base::SysUTF8ToNSString(data_path.value()); |
| + scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile:path]); |
| + ASSERT_TRUE(image.get()); |
| + EXPECT_EQ(2u, [[image representations] count]); |
| + |
| + scoped_nsobject<NSData> data([[NSData alloc] initWithContentsOfFile:path]); |
| + EXPECT_TRUE(data.get()); |
| + |
| + std::vector<SkBitmap> bitmaps; |
| + EXPECT_TRUE(TIFFCodec::Decode(static_cast<const unsigned char*>([data bytes]), |
| + [data length], bitmaps)); |
| + EXPECT_EQ(2u, bitmaps.size()); |
| + EXPECT_FALSE(bitmaps[0].isNull()); |
| + EXPECT_FALSE(bitmaps[1].isNull()); |
| + |
| + [pool drain]; |
| +} |
| +#endif |
| + |
| +} // namespace gfx |