| Index: ui/gl/gl_surface_format_unittest.cc
|
| diff --git a/ui/gl/gl_surface_format_unittest.cc b/ui/gl/gl_surface_format_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6e145c6267c37223f0c52d2edec61afb7198a397
|
| --- /dev/null
|
| +++ b/ui/gl/gl_surface_format_unittest.cc
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/gl/gl_surface_format.h"
|
| +
|
| +namespace gl {
|
| +
|
| +TEST(GLSurfaceFormatTest, BasicTest) {
|
| + {
|
| + // Check default format properties.
|
| + GLSurfaceFormat format = GLSurfaceFormat();
|
| + EXPECT_TRUE(format.IsDefault());
|
| + EXPECT_EQ(32, format.GetBufferSize());
|
| + EXPECT_FALSE(format.IsSurfaceless());
|
| + EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_DONT_CARE,
|
| + format.GetPixelLayout());
|
| + }
|
| +
|
| + {
|
| + // Check rgb565 format as used for low-end Android devices.
|
| + GLSurfaceFormat format = GLSurfaceFormat();
|
| + format.SetRGB565();
|
| + EXPECT_FALSE(format.IsDefault());
|
| + EXPECT_EQ(16, format.GetBufferSize());
|
| + }
|
| +
|
| + {
|
| + // Check surfaceless format.
|
| + GLSurfaceFormat format = GLSurfaceFormat();
|
| + format.SetIsSurfaceless();
|
| + EXPECT_FALSE(format.IsDefault());
|
| + EXPECT_TRUE(format.IsSurfaceless());
|
| + }
|
| +
|
| + {
|
| + // Check custom pixel layout.
|
| + GLSurfaceFormat format = GLSurfaceFormat(
|
| + GLSurfaceFormat::PIXEL_LAYOUT_RGBA);
|
| + EXPECT_FALSE(format.IsDefault());
|
| + EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA,
|
| + format.GetPixelLayout());
|
| +
|
| + // The custom pixel layout should remain after other modifications.
|
| + format.SetDepthBits(24);
|
| + EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA,
|
| + format.GetPixelLayout());
|
| + EXPECT_EQ(24, format.GetDepthBits());
|
| + }
|
| +
|
| + {
|
| + // Check IsCompatible
|
| + GLSurfaceFormat format = GLSurfaceFormat();
|
| + EXPECT_TRUE(format.IsCompatible(GLSurfaceFormat()));
|
| +
|
| + GLSurfaceFormat other = GLSurfaceFormat();
|
| + other.SetRGB565();
|
| + EXPECT_FALSE(format.IsCompatible(other));
|
| + EXPECT_TRUE(other.IsCompatible(other));
|
| + }
|
| +}
|
| +
|
| +}
|
|
|