From patchwork Tue Sep 10 13:31:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21214 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 83DB9C324C for ; Tue, 10 Sep 2024 13:31:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A9C0634F7; Tue, 10 Sep 2024 15:31:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Zvk7MxqW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9183A618FB for ; Tue, 10 Sep 2024 15:31:54 +0200 (CEST) Received: from pyrite.hamster-moth.ts.net (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9768F63F; Tue, 10 Sep 2024 15:30:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1725975037; bh=6pAFk0dRkk07bWADoBkdyGp11rSOmrOD+Covbky7K0o=; h=From:To:Cc:Subject:Date:From; b=Zvk7MxqWMBGWK8rDTCpVGvSZi2XVIHi8YJ+hCmojMrfOeyW+wtVohU0k40Xh8MtZE gmLRVhYTtYsy1/uO3Z09KzmtBPzrSvDpBIElCKtVfSwBLQAJoNigjdiFBWwy2Y5MQr GqajkBny84RX09kh1oO0lZgoWFvSnzKusQOY9H1o= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [PATCH] test: controls: control_info: Add test for enum controls Date: Tue, 10 Sep 2024 15:31:30 +0200 Message-Id: <20240910133130.1374459-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a test for enum controls to test that the ranges and values are set properly. Signed-off-by: Paul Elder --- test/controls/control_info.cpp | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp index e1bb43f0e..460aaa345 100644 --- a/test/controls/control_info.cpp +++ b/test/controls/control_info.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include @@ -79,6 +80,44 @@ protected: return TestFail; } + /* + * Test information retrieval from an enum control. + */ + ControlInfo awbMode(static_cast(controls::AwbTungsten), + static_cast(controls::AwbDaylight)); + if (awbMode.min().get() != controls::AwbTungsten || + awbMode.max().get() != controls::AwbDaylight) { + cout << "Invalid control range for AwbMode" << endl; + return TestFail; + } + + std::vector modes = { + static_cast(controls::AwbTungsten), + static_cast(controls::AwbFluorescent), + static_cast(controls::AwbDaylight), + }; + ControlInfo awbModes(Span{ modes }); + + if (awbModes.min() != modes.front() || + awbModes.def() != modes.front() || + awbModes.max() != modes.back()) { + cout << "Invalid control range for AwbModes" << endl; + return TestFail; + } + + if (awbModes.values().size() != modes.size()) { + cout << "Invalid size for AwbModes" << endl; + return TestFail; + } + + unsigned int i = 0; + for (const auto &value : awbModes.values()) { + if (value != modes.at(i++)) { + cout << "Invalid control values for AwbModes" << endl; + return TestFail; + } + } + return TestPass; } };