chromium/ui/gfx/image/image_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <utility>
#include <vector>

#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_png_rep.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_unittest_util.h"

#if BUILDFLAG(IS_IOS)
#include "base/apple/foundation_util.h"
#include "skia/ext/skia_utils_ios.h"
#elif BUILDFLAG(IS_MAC)
#include <CoreGraphics/CoreGraphics.h>

#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#include "base/mac/mac_util.h"
#include "skia/ext/skia_utils_mac.h"
#endif

namespace {

#if BUILDFLAG(IS_APPLE)
constexpr bool kUsesSkiaNatively = false;
#else
constexpr bool kUsesSkiaNatively =;
#endif

#if BUILDFLAG(IS_MAC)
bool IsSystemColorSpaceSRGB() {
  base::apple::ScopedCFTypeRef<CGColorSpaceRef> color_space(
      CGDisplayCopyColorSpace(CGMainDisplayID()));
  base::apple::ScopedCFTypeRef<CFStringRef> name(
      CGColorSpaceCopyName(color_space.get()));
  return name &&
         CFStringCompare(name.get(), kCGColorSpaceSRGB, 0) == kCFCompareEqualTo;
}
#endif  // BUILDFLAG(IS_MAC)

class ImageTest : public testing::Test {};

gt;

TEST_F(ImageTest, EmptyImage) {}

// Test constructing a gfx::Image from an empty PlatformImage.
TEST_F(ImageTest, EmptyImageFromEmptyPlatformImage) {}

// The resulting Image should be empty when it is created using obviously
// invalid data.
TEST_F(ImageTest, EmptyImageFromObviouslyInvalidPNGImage) {}

// Test the Width, Height and Size of an empty and non-empty image.
TEST_F(ImageTest, ImageSize) {}

TEST_F(ImageTest, SkiaToSkia) {}

TEST_F(ImageTest, EmptyImageToPNG) {}

// Check that getting the 1x PNG bytes from images which do not have a 1x
// representation returns null.
TEST_F(ImageTest, ImageNo1xToPNG) {}

// Check that for an image initialized with multi resolution PNG data,
// As1xPNGBytes() returns the 1x bytes.
TEST_F(ImageTest, CreateExtractPNGBytes) {}

TEST_F(ImageTest, MultiResolutionImageSkiaToPNG) {}

TEST_F(ImageTest, MultiResolutionPNGToImageSkia) {}

#if !BUILDFLAG(IS_IOS)
// IOS does not support arbitrary scale factors.
TEST_F(ImageTest, PreferDownscaleToUpscale) {}
#endif

TEST_F(ImageTest, MultiResolutionPNGToPlatform) {}


TEST_F(ImageTest, PlatformToPNGEncodeAndDecode) {}

// The platform types use the platform provided encoding/decoding of PNGs. Make
// sure these work with the Skia Encode/Decode.
TEST_F(ImageTest, PNGEncodeFromSkiaDecodeToPlatform) {}

TEST_F(ImageTest, PNGEncodeFromPlatformDecodeToSkia) {}

TEST_F(ImageTest, PNGDecodeToSkiaFailure) {}

TEST_F(ImageTest, PNGDecodeToPlatformFailure) {}

TEST_F(ImageTest, SkiaToPlatform) {}

TEST_F(ImageTest, PlatformToSkia) {}

TEST_F(ImageTest, PlatformToPlatform) {}

TEST_F(ImageTest, CheckSkiaColor) {}

TEST_F(ImageTest, SkBitmapConversionPreservesOrientation) {}

TEST_F(ImageTest, SkBitmapConversionPreservesTransparency) {}

TEST_F(ImageTest, Copy) {}

TEST_F(ImageTest, Assign) {}

TEST_F(ImageTest, Move) {}

TEST_F(ImageTest, MoveAssign) {}

TEST_F(ImageTest, Copy_PreservesRepresentation) {}

TEST_F(ImageTest, Copy_PreventsDuplication) {}

TEST_F(ImageTest, Copy_PreservesBackingStore) {}

TEST_F(ImageTest, MultiResolutionImageSkia) {}

TEST_F(ImageTest, RemoveFromMultiResolutionImageSkia) {}

// Tests that gfx::Image does indeed take ownership of the SkBitmap it is
// passed.
TEST_F(ImageTest, OwnershipTest) {}

// Integration tests with UI toolkit frameworks require linking against the
// Views library and cannot be here (ui_base_unittests doesn't include it). They
// instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc.

}  // namespace