From patchwork Wed Mar 6 02:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 707 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE21D611A2 for ; Wed, 6 Mar 2019 03:48:21 +0100 (CET) X-Halon-ID: 4cdb3461-3fba-11e9-985a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 4cdb3461-3fba-11e9-985a-005056917f90; Wed, 06 Mar 2019 03:48:20 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Mar 2019 03:47:53 +0100 Message-Id: <20190306024755.28726-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190306024755.28726-1-niklas.soderlund@ragnatech.se> References: <20190306024755.28726-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] test: camera: Add setting of format 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: Wed, 06 Mar 2019 02:48:22 -0000 Try to set the default format, a modified valid format and an invalid format. Signed-off-by: Niklas Söderlund --- test/camera/format_set.cpp | 88 ++++++++++++++++++++++++++++++++++++++ test/camera/meson.build | 1 + 2 files changed, 89 insertions(+) create mode 100644 test/camera/format_set.cpp diff --git a/test/camera/format_set.cpp b/test/camera/format_set.cpp new file mode 100644 index 0000000000000000..948428ca6b00d2d0 --- /dev/null +++ b/test/camera/format_set.cpp @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * libcamera Camera API tests + */ + +#include + +#include "camera_test.h" + +using namespace std; + +namespace { + +class FormatSet : public CameraTest +{ +protected: + int run() + { + if (camera_->acquire()) { + cout << "Acquiring the camera failed" << endl; + return TestFail; + } + + std::set streams = { *camera_->streams().begin() }; + std::map conf = + camera_->streamConfiguration(streams); + StreamConfiguration *sconf = &conf.begin()->second; + if (conf.size() != 1) { + cout << "Reading default format failed" << endl; + return TestFail; + } + + /* + * Test setting the default format works. + */ + if (camera_->configureStreams(conf)) { + cout << "Setting valid format test failed" << endl; + return TestFail; + } + + /* + * Test setting the default format fails the camera is not + * acquired. + */ + if (camera_->release()) { + cout << "Releasing the camera failed" << endl; + return TestFail; + } + + if (!camera_->configureStreams(conf)) { + cout << "Setting valid format on a camera not acquired failed" << endl; + return TestFail; + } + + if (camera_->acquire()) { + cout << "Acquiring the camera failed" << endl; + return TestFail; + } + + /* + * Test doubling the resolution works. + */ + sconf->width *= 2; + sconf->height *= 2; + if (camera_->configureStreams(conf)) { + cout << "Setting modified valid format test failed" << endl; + return TestFail; + } + + /* + * Test Setting an invalid format fails. + */ + sconf->width = 0; + sconf->height = 0; + if (!camera_->configureStreams(conf)) { + cout << "Setting invalid format test failed" << endl; + return TestFail; + } + + return TestPass; + } +}; + +} /* namespace */ + +TEST_REGISTER(FormatSet); diff --git a/test/camera/meson.build b/test/camera/meson.build index 4f2ed244a9240512..f5f27c4229ac307f 100644 --- a/test/camera/meson.build +++ b/test/camera/meson.build @@ -2,6 +2,7 @@ # They are not alphabetically sorted. camera_tests = [ [ 'format_default', 'format_default.cpp' ], + [ 'format_set', 'format_set.cpp' ], ] foreach t : camera_tests