chromium/ui/display/util/edid_parser_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/display/util/edid_parser.h"

#include <stdint.h>

#include <memory>

#include "base/containers/flat_set.h"
#include "base/hash/md5.h"
#include "base/numerics/ranges.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "ui/display/types/display_constants.h"
#include "ui/gfx/geometry/size.h"

AssertionFailure;
AssertionSuccess;
TestWithParam;
ValuesIn;

namespace display {

namespace {

// EDID with non-ascii char in display name.
constexpr unsigned char kBadDisplayName[] =;
constexpr size_t kBadDisplayNameLength =;

// Sample EDID data extracted from real devices.
constexpr unsigned char kNormalDisplay[] =;
constexpr size_t kNormalDisplayLength =;

// Max image display is an optional field and is omitted in this display by
// setting bytes 21-22 to 0x00.
constexpr unsigned char kNoMaxImageSizeDisplay[] =;
constexpr size_t kNoMaxImageSizeDisplayLength =;

// Serial number is in bytes 12-15 of Block 0. Serial number descriptor
// (tag: 0xff) is omitted and replaced by a dummy descriptor (tag: 0x10).
constexpr unsigned char kBlockZeroSerialNumberOnlyDisplay[] =;
constexpr size_t kBlockZeroSerialNumberOnlyDisplayLength =;

// Serial number is unavailable. Omitted from bytes 12-15 of block zero and SN
// descriptor (tag: 0xff).
constexpr unsigned char kNoSerialNumberDisplay[] =;
constexpr size_t kNoSerialNumberDisplayLength =;

// Week of manufacture is optional and is omitted in this display
// (0x00 at byte 16).
constexpr unsigned char kNoWeekOfManufactureDisplay[] =;
constexpr size_t kNoWeekOfManufactureDisplayLength =;

// Week of manufacture can be used to signal that year of manufacture is the
// model year by setting byte 16 to 0xff.
constexpr unsigned char kModelYearDisplay[] =;
constexpr size_t kModelYearDisplayLength =;

constexpr unsigned char kInternalDisplay[] =;
constexpr size_t kInternalDisplayLength =;

constexpr unsigned char kOverscanDisplay[] =;
constexpr size_t kOverscanDisplayLength =;

// The EDID info misdetecting overscan once. see crbug.com/226318
constexpr unsigned char kMisdetectedDisplay[] =;
constexpr size_t kMisdetectedDisplayLength =;

constexpr unsigned char kLP2565A[] =;
constexpr size_t kLP2565ALength =;

constexpr unsigned char kLP2565B[] =;
constexpr size_t kLP2565BLength =;

// HP z32x monitor.
constexpr unsigned char kHPz32x[] =;
constexpr size_t kHPz32xLength =;

// Chromebook Samus internal display.
constexpr unsigned char kSamus[] =;
constexpr size_t kSamusLength =;

// Chromebook Eve internal display.
constexpr unsigned char kEve[] =;
constexpr size_t kEveLength =;

// A Samsung monitor that supports HDR metadata.
constexpr unsigned char kHDRMetadata[] =;
constexpr size_t kHDRMetadataLength =;

// EDID for Dell UP3218K, a 2x1 8K tiled display.
constexpr unsigned char kTiledDisplay[] =;
constexpr size_t kTiledDisplayLength =;

const std::string kNoSerialNumber =;
const gfx::Size kNoMaxImageSize =;
constexpr uint8_t kNoWeekOfManufactureTag =;
constexpr uint8_t kModelYearTag =;
// 16843009 == 0x01010101
const std::string kGenericBlockZeroHashedSerialNumber =;
const std::string kNormalDisplayHashedDescriptorBlockSerialNumber =;

// Primaries coordinates ({RX, RY, GX, GY, BX, BY, WX, WY}) calculated by hand
// and rounded to 4 decimal places.
constexpr SkColorSpacePrimaries kNormalDisplayPrimaries =;
constexpr SkColorSpacePrimaries kInternalDisplayPrimaries =;
constexpr SkColorSpacePrimaries kOverscanDisplayPrimaries =;
constexpr SkColorSpacePrimaries kMisdetectedDisplayPrimaries =;
constexpr SkColorSpacePrimaries kLP2565APrimaries =;
constexpr SkColorSpacePrimaries kLP2565BPrimaries =;
constexpr SkColorSpacePrimaries kHPz32xPrimaries =;
constexpr SkColorSpacePrimaries kSamusPrimaries =;
constexpr SkColorSpacePrimaries kEvePrimaries =;
constexpr SkColorSpacePrimaries kHDRPrimaries =;
constexpr SkColorSpacePrimaries kDellTiledPrimaries =;

// Chromaticity primaries in EDID are specified with 10 bits precision.
constexpr static float kPrimariesPrecision =;

::testing::AssertionResult SkColorSpacePrimariesEquals(
    const char* lhs_expr,
    const char* rhs_expr,
    const SkColorSpacePrimaries& lhs,
    const SkColorSpacePrimaries& rhs) {}

}  // namespace

struct TestParams {} kTestCases[] =;

class EDIDParserTest : public TestWithParam<TestParams> {};

TEST_P(EDIDParserTest, ParseEdids) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace display