Message ID | 20190701201504.28487-11-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Kieran, Thanks for your patch. On 2019-07-01 23:15:01 +0300, Laurent Pinchart wrote: > From: Kieran Bingham <kieran.bingham@ideasonboard.com> > > 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> > --- > 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 <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) > 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') > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
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 <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) 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')