From patchwork Fri Nov 8 20:53:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2298 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 35BAC6150A for ; Fri, 8 Nov 2019 21:54:23 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C8C792D1 for ; Fri, 8 Nov 2019 21:54:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1573246462; bh=aVv4tmUKK5hzM121JHAcTAX/nWTzokiWDabNINf7hpY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZlWXPOsc4VsgUaxcKt5EfRghz3fsuqdSKq84Z6QgdnvzL8xdZXCAD7ae9kMWbaY22 ro80uooDXH67rTHUhSB55KLv/VDTCUjcwVoaZG5szyCZNPzJlC3XTUsLZuNtN04+c2 FFK9Xfb7YpnOdLwH7GQxXmfpSLIeTRx3nMAqaqm4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 8 Nov 2019 22:53:47 +0200 Message-Id: <20191108205409.18845-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108205409.18845-1-laurent.pinchart@ideasonboard.com> References: <20191108205409.18845-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/24] test: controls: Add ControlInfoMap test 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: , X-List-Received-Date: Fri, 08 Nov 2019 20:54:23 -0000 Add a test to exercise the ControlInfoMap API. This currently tests at(), count(), find() and end(). Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- test/controls/control_info.cpp | 77 ++++++++++++++++++++++++++++++++++ test/controls/meson.build | 1 + 2 files changed, 78 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..c2678ea3e593 --- /dev/null +++ b/test/controls/control_info.cpp @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_info.cpp - ControlInfoMap tests + */ + +#include + +#include +#include +#include +#include + +#include "camera_controls.h" + +#include "camera_test.h" +#include "test.h" + +using namespace std; +using namespace libcamera; + +class ControlInfoMapTest : public CameraTest, public Test +{ +public: + ControlInfoMapTest() + : CameraTest("VIMC Sensor B") + { + } + +protected: + int run() + { + const ControlInfoMap &info = camera_->controls(); + + /* Test looking up a valid control by ControlId. */ + if (info.count(&controls::Brightness) != 1) { + cout << "count() on valid control failed" << endl; + return TestFail; + } + + if (info.find(&controls::Brightness) == info.end()) { + cout << "find() on valid control failed" << endl; + return TestFail; + } + + info.at(&controls::Brightness); + + /* Test looking up a valid control by numerical ID. */ + if (info.count(controls::Brightness.id()) != 1) { + cout << "count() on valid ID failed" << endl; + return TestFail; + } + + if (info.find(controls::Brightness.id()) == info.end()) { + cout << "find() on valid ID failed" << endl; + return TestFail; + } + + info.at(controls::Brightness.id()); + + /* Test looking up an invalid control by numerical ID. */ + if (info.count(12345) != 0) { + cout << "count() on invalid ID failed" << endl; + return TestFail; + } + + if (info.find(12345) != info.end()) { + cout << "find() on invalid ID failed" << endl; + return TestFail; + } + + return TestPass; + } +}; + +TEST_REGISTER(ControlInfoMapTest) diff --git a/test/controls/meson.build b/test/controls/meson.build index 9f0f005a2759..f0850df28c8a 100644 --- a/test/controls/meson.build +++ b/test/controls/meson.build @@ -1,4 +1,5 @@ control_tests = [ + [ 'control_info', 'control_info.cpp' ], [ 'control_list', 'control_list.cpp' ], [ 'control_range', 'control_range.cpp' ], [ 'control_value', 'control_value.cpp' ],