diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2021-04-21 17:23:45 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2021-05-06 15:08:34 +0200 |
commit | b3a603a489d5f22d3efc3bd2f3b66dd2447df6fc (patch) | |
tree | 9d6eb8800fed39f2898ba8a1bb097a078fff2d00 /test | |
parent | f3481886255675a6ba1342865bf8fd0033a30eba (diff) |
test: control_list: Test ControlList::merge()
Test the ControlList::merge() method by creating a new list and
merging it with the existing one.
Test that the merged list contains all the controls, the existing values
do not get overwritten and the ones copied are not changed.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/controls/control_list.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp index 2b321ddd..70cf61b8 100644 --- a/test/controls/control_list.cpp +++ b/test/controls/control_list.cpp @@ -150,6 +150,52 @@ protected: return TestFail; } + /* + * Create a new list with a new control and merge it with the + * existing one, verifying that the existing controls + * values don't get overwritten. + */ + ControlList mergeList(controls::controls, &validator); + mergeList.set(controls::Brightness, 0.7f); + mergeList.set(controls::Saturation, 0.4f); + + mergeList.merge(list); + if (mergeList.size() != 3) { + cout << "Merged list should contain three elements" << endl; + return TestFail; + } + + if (list.size() != 2) { + cout << "The list to merge should contain two elements" + << endl; + return TestFail; + } + + if (!mergeList.contains(controls::Brightness) || + !mergeList.contains(controls::Contrast) || + !mergeList.contains(controls::Saturation)) { + cout << "Merged list does not contain all controls" << endl; + return TestFail; + } + + if (mergeList.get(controls::Brightness) != 0.7f) { + cout << "Brightness control value changed after merging lists" + << endl; + return TestFail; + } + + if (mergeList.get(controls::Contrast) != 1.1f) { + cout << "Contrast control value changed after merging lists" + << endl; + return TestFail; + } + + if (mergeList.get(controls::Saturation) != 0.4f) { + cout << "Saturation control value changed after merging lists" + << endl; + return TestFail; + } + return TestPass; } }; |