From 2129117df920699ad83bd231ebe83ca9f0a619da Mon Sep 17 00:00:00 2001 From: Kaaira Gupta Date: Mon, 22 Jun 2020 16:33:51 +0530 Subject: libcamera: pixel_format: Replace hex with format names Print format names defined in formats namespace instead of the hex values in toString() as they are easier to comprehend. For this add a property of 'name' in PixelFormatInfo' so as to map the formats with their names. Print fourcc for formats which are not used in libcamera. Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- test/pixel-format.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/pixel-format.cpp (limited to 'test/pixel-format.cpp') diff --git a/test/pixel-format.cpp b/test/pixel-format.cpp new file mode 100644 index 00000000..c4a08f46 --- /dev/null +++ b/test/pixel-format.cpp @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2020, Kaaira Gupta + * libcamera pixel format handling test + */ + +#include +#include + +#include +#include + +#include "libcamera/internal/utils.h" + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class PixelFormatTest : public Test +{ +protected: + int run() + { + std::vector> formatsMap{ + { formats::R8, "R8" }, + { formats::SRGGB10_CSI2P, "SRGGB10_CSI2P" }, + { PixelFormat(0, 0), "" }, + { PixelFormat(0x20203843), "" } + }; + + for (const auto &format : formatsMap) { + if ((format.first).toString() != format.second) { + cerr << "Failed to convert PixelFormat " + << utils::hex(format.first.fourcc()) << " to string" + << endl; + return TestFail; + } + } + + if (PixelFormat().toString() != "") { + cerr << "Failed to convert default PixelFormat to string" + << endl; + return TestFail; + } + + return TestPass; + } +}; + +TEST_REGISTER(PixelFormatTest) -- cgit v1.2.1