diff options
Diffstat (limited to 'test/controls')
-rw-r--r-- | test/controls/control_info.cpp | 12 | ||||
-rw-r--r-- | test/controls/control_info_map.cpp | 9 | ||||
-rw-r--r-- | test/controls/control_list.cpp | 70 | ||||
-rw-r--r-- | test/controls/control_value.cpp | 2 | ||||
-rw-r--r-- | test/controls/meson.build | 14 |
5 files changed, 83 insertions, 24 deletions
diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp index 2827473b..e1bb43f0 100644 --- a/test/controls/control_info.cpp +++ b/test/controls/control_info.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * control_info.cpp - ControlInfo tests + * ControlInfo tests */ #include <iostream> @@ -26,20 +26,22 @@ protected: */ ControlInfo brightness; - if (brightness.min().get<int32_t>() != 0 || - brightness.max().get<int32_t>() != 0) { + if (brightness.min().type() != ControlType::ControlTypeNone || + brightness.max().type() != ControlType::ControlTypeNone || + brightness.def().type() != ControlType::ControlTypeNone) { cout << "Invalid control range for Brightness" << endl; return TestFail; } /* * Test information retrieval from a control with a minimum and - * a maximum value. + * a maximum value, and an implicit default value. */ ControlInfo contrast(10, 200); if (contrast.min().get<int32_t>() != 10 || - contrast.max().get<int32_t>() != 200) { + contrast.max().get<int32_t>() != 200 || + !contrast.def().isNone()) { cout << "Invalid control range for Contrast" << endl; return TestFail; } diff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp index db95945a..b0be14b5 100644 --- a/test/controls/control_info_map.cpp +++ b/test/controls/control_info_map.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * control_info.cpp - ControlInfoMap tests + * ControlInfoMap tests */ #include <iostream> @@ -75,6 +75,13 @@ protected: return TestFail; } + /* Test looking up a control on a default-constructed infoMap */ + const ControlInfoMap emptyInfoMap; + if (emptyInfoMap.find(12345) != emptyInfoMap.end()) { + cerr << "find() on empty ControlInfoMap failed" << endl; + return TestFail; + } + return TestPass; } }; diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp index 70cf61b8..e27325c3 100644 --- a/test/controls/control_list.cpp +++ b/test/controls/control_list.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * control_list.cpp - ControlList tests + * ControlList tests */ #include <iostream> @@ -50,7 +50,7 @@ protected: return TestFail; } - if (list.contains(controls::Brightness)) { + if (list.get(controls::Brightness)) { cout << "List should not contain Brightness control" << endl; return TestFail; } @@ -80,7 +80,7 @@ protected: return TestFail; } - if (!list.contains(controls::Brightness)) { + if (!list.get(controls::Brightness)) { cout << "List should contain Brightness control" << endl; return TestFail; } @@ -99,7 +99,7 @@ protected: return TestFail; } - if (list.contains(controls::Contrast)) { + if (list.get(controls::Contrast)) { cout << "List should not contain Contract control" << endl; return TestFail; } @@ -108,8 +108,8 @@ protected: list.set(controls::Brightness, 0.0f); list.set(controls::Contrast, 1.5f); - if (!list.contains(controls::Brightness) || - !list.contains(controls::Contrast)) { + if (!list.get(controls::Brightness) || + !list.get(controls::Contrast)) { cout << "List should contain Brightness and Contrast controls" << endl; return TestFail; @@ -145,7 +145,7 @@ protected: */ list.set(controls::AwbEnable, true); - if (list.contains(controls::AwbEnable)) { + if (list.get(controls::AwbEnable)) { cout << "List shouldn't contain AwbEnable control" << endl; return TestFail; } @@ -171,9 +171,9 @@ protected: return TestFail; } - if (!mergeList.contains(controls::Brightness) || - !mergeList.contains(controls::Contrast) || - !mergeList.contains(controls::Saturation)) { + if (!mergeList.get(controls::Brightness) || + !mergeList.get(controls::Contrast) || + !mergeList.get(controls::Saturation)) { cout << "Merged list does not contain all controls" << endl; return TestFail; } @@ -196,6 +196,56 @@ protected: return TestFail; } + /* + * Create two lists with overlapping controls. Merge them with + * overwriteExisting = true, verifying that the existing control + * values *get* overwritten. + */ + mergeList.clear(); + mergeList.set(controls::Brightness, 0.7f); + mergeList.set(controls::Saturation, 0.4f); + + list.clear(); + list.set(controls::Brightness, 0.5f); + list.set(controls::Contrast, 1.1f); + + mergeList.merge(list, ControlList::MergePolicy::OverwriteExisting); + 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.get(controls::Brightness) || + !mergeList.get(controls::Contrast) || + !mergeList.get(controls::Saturation)) { + cout << "Merged list does not contain all controls" << endl; + return TestFail; + } + + if (mergeList.get(controls::Brightness) != 0.5f) { + cout << "Brightness control value did not change 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; } }; diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp index ad8e05d0..344107fa 100644 --- a/test/controls/control_value.cpp +++ b/test/controls/control_value.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * control_value.cpp - ControlValue tests + * ControlValue tests */ #include <algorithm> diff --git a/test/controls/meson.build b/test/controls/meson.build index 0103543e..763f8905 100644 --- a/test/controls/meson.build +++ b/test/controls/meson.build @@ -1,16 +1,16 @@ # SPDX-License-Identifier: CC0-1.0 control_tests = [ - ['control_info', 'control_info.cpp'], - ['control_info_map', 'control_info_map.cpp'], - ['control_list', 'control_list.cpp'], - ['control_value', 'control_value.cpp'], + {'name': 'control_info', 'sources': ['control_info.cpp']}, + {'name': 'control_info_map', 'sources': ['control_info_map.cpp']}, + {'name': 'control_list', 'sources': ['control_list.cpp']}, + {'name': 'control_value', 'sources': ['control_value.cpp']}, ] -foreach t : control_tests - exe = executable(t[0], t[1], +foreach test : control_tests + exe = executable(test['name'], test['sources'], dependencies : libcamera_public, link_with : test_libraries, include_directories : test_includes_internal) - test(t[0], exe, suite : 'controls', is_parallel : false) + test(test['name'], exe, suite : 'controls', is_parallel : false) endforeach |