From patchwork Mon Jul 1 20:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1569 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74F3E61F5D 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 202081217 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=GHlMySBi5xqeUwYJNAOLGl2fTK8C15O+d7MdvuQ3lss=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Llp3hE+ZNi0mN/ilGOzqoHjVuWf8kJ+Z8XJkXFtOKNzMbAUhMhohYMtshBgMJR2Xg mHzJ1JyacA8xWnOeZK7YXUuNSoINCp3zyL8wH8nljySMeCqoPPBtAJLkgzz9cCrjXK XIHC7PbSZjn5xAYSIRnUN5PYMmGsXnvhkY5a4iZU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Jul 2019 23:15:01 +0300 Message-Id: <20190701201504.28487-11-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 10/13] libcamera: test: Add ControlValue 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 Add initial basic testing for the new ControlValue class. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- test/controls/control_value.cpp | 69 +++++++++++++++++++++++++++++++++ test/controls/meson.build | 11 ++++++ test/meson.build | 1 + 3 files changed, 81 insertions(+) create mode 100644 test/controls/control_value.cpp create mode 100644 test/controls/meson.build diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp new file mode 100644 index 000000000000..778efe5c115f --- /dev/null +++ b/test/controls/control_value.cpp @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_value.cpp - ControlValue tests + */ + +#include + +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class ControlValueTest : public Test +{ +protected: + int run() + { + ControlValue integer(1234); + ControlValue boolean(true); + + /* Just a string conversion output test... no validation */ + cout << "Int: " << integer.toString() + << " Bool: " << boolean.toString() + << endl; + + if (integer.getInt() != 1234) { + cerr << "Failed to get Integer" << endl; + return TestFail; + } + + if (boolean.getBool() != true) { + cerr << "Failed to get Boolean" << endl; + return TestFail; + } + + /* Test an uninitialised value, and updating it. */ + + ControlValue value; + if (!value.isNone()) { + cerr << "Empty value is non-null" << endl; + return TestFail; + } + + value.set(true); + if (value.isNone()) { + cerr << "Failed to set an empty object" << endl; + return TestFail; + } + + if (value.getBool() != true) { + cerr << "Failed to get Booleans" << endl; + return TestFail; + } + + value.set(10); + if (value.getInt() != 10) { + cerr << "Failed to get Integer" << endl; + return TestFail; + } + + return TestPass; + } +}; + +TEST_REGISTER(ControlValueTest) diff --git a/test/controls/meson.build b/test/controls/meson.build new file mode 100644 index 000000000000..1161864d9949 --- /dev/null +++ b/test/controls/meson.build @@ -0,0 +1,11 @@ +control_tests = [ + [ 'control_value', 'control_value.cpp' ], +] + +foreach t : control_tests + exe = executable(t[0], t[1], + dependencies : libcamera_dep, + link_with : test_libraries, + include_directories : test_includes_internal) + test(t[0], exe, suite : 'controls', is_parallel : false) +endforeach diff --git a/test/meson.build b/test/meson.build index c36ac2479636..fea2485cbb34 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,6 +1,7 @@ subdir('libtest') subdir('camera') +subdir('controls') subdir('ipa') subdir('media_device') subdir('pipeline')