From patchwork Mon Jul 1 20:15:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1570 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B360661F4A for ; Mon, 1 Jul 2019 22:15:31 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6A838524 for ; Mon, 1 Jul 2019 22:15:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562012131; bh=PXVWkAZU9N/gTgufqV4/MXpcO3dQqPOekospj4fc+yU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=syM6/ainhsn8lT3eFDbb0qLmq+DvjQjG6TK5ldk+4l+pxd1wtNdH5+Tv7N1MGh7// 3BS3i3vWW9ll0xQcS7jkKXknnGOooS9OxvMPL4axXaiCSYRt6Ev1U0WyfTfnomgO7I aLSmzpBa4r+3g5hEtBAEkVfG7acL1bXMltXcGX8w= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Jul 2019 23:15:02 +0300 Message-Id: <20190701201504.28487-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190701201504.28487-1-laurent.pinchart@ideasonboard.com> References: <20190701201504.28487-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 11/13] libcamera: test: Add ControlInfo test X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2019 20:15:32 -0000 From: Kieran Bingham Provide an initial test coverage for the ControlInfo class. Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- Changes since v2: - Renamed to control_info.cpp --- test/controls/control_info.cpp | 62 ++++++++++++++++++++++++++++++++++ test/controls/meson.build | 1 + 2 files changed, 63 insertions(+) create mode 100644 test/controls/control_info.cpp diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp new file mode 100644 index 000000000000..aa3a65b1e5ef --- /dev/null +++ b/test/controls/control_info.cpp @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_info.cpp - ControlInfo tests + */ + +#include + +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class ControlInfoTest : public Test +{ +protected: + int run() + { + /* + * Test information retrieval from a control with no minimum + * and maximum. + */ + ControlInfo info(Brightness); + + if (info.id() != Brightness || + info.type() != ControlValueInteger || + info.name() != std::string("Brightness")) { + cout << "Invalid control identification for Brightness" << endl; + return TestFail; + } + + if (info.min().getInt() != 0 || info.max().getInt() != 0) { + cout << "Invalid control range for Brightness" << endl; + return TestFail; + } + + /* + * Test information retrieval from a control with a minimum and + * a maximum value. + */ + info = ControlInfo(Contrast, 10, 200); + + if (info.id() != Contrast || + info.type() != ControlValueInteger || + info.name() != std::string("Contrast")) { + cout << "Invalid control identification for Contrast" << endl; + return TestFail; + } + + if (info.min().getInt() != 10 || info.max().getInt() != 200) { + cout << "Invalid control range for Contrast" << endl; + return TestFail; + } + + return TestPass; + } +}; + +TEST_REGISTER(ControlInfoTest) diff --git a/test/controls/meson.build b/test/controls/meson.build index 1161864d9949..f8cda2877e73 100644 --- a/test/controls/meson.build +++ b/test/controls/meson.build @@ -1,4 +1,5 @@ control_tests = [ + [ 'control_info', 'control_info.cpp' ], [ 'control_value', 'control_value.cpp' ], ]