OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/gl/gl_surface_format.h" |
| 7 |
| 8 namespace gl { |
| 9 |
| 10 TEST(GLSurfaceFormatTest, BasicTest) { |
| 11 { |
| 12 // Check default format properties. |
| 13 GLSurfaceFormat format = GLSurfaceFormat(); |
| 14 EXPECT_TRUE(format.IsDefault()); |
| 15 EXPECT_EQ(32, format.GetBufferSize()); |
| 16 EXPECT_FALSE(format.IsSurfaceless()); |
| 17 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_DONT_CARE, |
| 18 format.GetPixelLayout()); |
| 19 } |
| 20 |
| 21 { |
| 22 // Check rgb565 format as used for low-end Android devices. |
| 23 GLSurfaceFormat format = GLSurfaceFormat(); |
| 24 format.SetRGB565(); |
| 25 EXPECT_FALSE(format.IsDefault()); |
| 26 EXPECT_EQ(16, format.GetBufferSize()); |
| 27 } |
| 28 |
| 29 { |
| 30 // Check surfaceless format. |
| 31 GLSurfaceFormat format = GLSurfaceFormat(); |
| 32 format.SetIsSurfaceless(); |
| 33 EXPECT_FALSE(format.IsDefault()); |
| 34 EXPECT_TRUE(format.IsSurfaceless()); |
| 35 } |
| 36 |
| 37 { |
| 38 // Check custom pixel layout. |
| 39 GLSurfaceFormat format = GLSurfaceFormat( |
| 40 GLSurfaceFormat::PIXEL_LAYOUT_RGBA); |
| 41 EXPECT_FALSE(format.IsDefault()); |
| 42 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA, |
| 43 format.GetPixelLayout()); |
| 44 |
| 45 // The custom pixel layout should remain after other modifications. |
| 46 format.SetDepthBits(24); |
| 47 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA, |
| 48 format.GetPixelLayout()); |
| 49 EXPECT_EQ(24, format.GetDepthBits()); |
| 50 } |
| 51 |
| 52 { |
| 53 // Check IsCompatible |
| 54 GLSurfaceFormat format = GLSurfaceFormat(); |
| 55 EXPECT_TRUE(format.IsCompatible(GLSurfaceFormat())); |
| 56 |
| 57 GLSurfaceFormat other = GLSurfaceFormat(); |
| 58 other.SetRGB565(); |
| 59 EXPECT_FALSE(format.IsCompatible(other)); |
| 60 EXPECT_TRUE(other.IsCompatible(other)); |
| 61 } |
| 62 } |
| 63 |
| 64 } |
OLD | NEW |