diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2019-05-30 14:30:35 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-07-02 16:59:46 +0300 |
commit | 4cbf83da408c45c64b1b293480ebea26cec88222 (patch) | |
tree | 892af6cc9fac46d47c6880e355f4999c65142617 /test/controls/control_value.cpp | |
parent | 9ea9dc5830e0d3675bec473806a70e22d8b7e514 (diff) |
libcamera: test: Add ControlValue test
Add initial basic testing for the new ControlValue class.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'test/controls/control_value.cpp')
-rw-r--r-- | test/controls/control_value.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp new file mode 100644 index 00000000..778efe5c --- /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 <iostream> + +#include <libcamera/controls.h> + +#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) |