test: delayed_controls: Fixup tests after recent DelayedControls changes
The recent fixes applied to DelayedControls change the behavior of the library. As such, the tests ended up failing as they relied on the old behavior of the helper. Update the tests to account for the new behavior and get the tests passing again. Specifically, the following changes have been made for each test: singleControlNoDelay(): - Add a call to reset() to initialise internal DelayedControls state only after setting the control on the device. - Trigger a first frame start by calling applyControls() as a pipeline handler would. - Test frames from 1 onwards, as we will never have a queue item at frame 0, since the reset() handles that. singleControlWithDelay(): - Trigger a first frame start by calling applyControls() as a pipeline handler would. - Test frames from 1 onwards, as we will never have a queue item at frame 0, since the reset() handles that. dualControlsWithDelay() and dualControlsMultiQueue(): - Trigger a first frame start by calling applyControls() as a pipeline handler would. - Test frames from (startOffset + 1) onwards, as we will never have a queue item at frame startOffset. - Use the max delay (2 in this case) to determine the expected result value. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
a940866440
commit
bc8b6f266b
1 changed files with 26 additions and 9 deletions
|
@ -82,9 +82,13 @@ protected:
|
||||||
/* Reset control to value not used in test. */
|
/* Reset control to value not used in test. */
|
||||||
ctrls.set(V4L2_CID_BRIGHTNESS, 1);
|
ctrls.set(V4L2_CID_BRIGHTNESS, 1);
|
||||||
dev_->setControls(&ctrls);
|
dev_->setControls(&ctrls);
|
||||||
|
delayed->reset();
|
||||||
|
|
||||||
|
/* Trigger the first frame start event */
|
||||||
|
delayed->applyControls(0);
|
||||||
|
|
||||||
/* Test control without delay are set at once. */
|
/* Test control without delay are set at once. */
|
||||||
for (unsigned int i = 0; i < 100; i++) {
|
for (unsigned int i = 1; i < 100; i++) {
|
||||||
int32_t value = 100 + i;
|
int32_t value = 100 + i;
|
||||||
|
|
||||||
ctrls.set(V4L2_CID_BRIGHTNESS, value);
|
ctrls.set(V4L2_CID_BRIGHTNESS, value);
|
||||||
|
@ -122,8 +126,11 @@ protected:
|
||||||
dev_->setControls(&ctrls);
|
dev_->setControls(&ctrls);
|
||||||
delayed->reset();
|
delayed->reset();
|
||||||
|
|
||||||
|
/* Trigger the first frame start event */
|
||||||
|
delayed->applyControls(0);
|
||||||
|
|
||||||
/* Test single control with delay. */
|
/* Test single control with delay. */
|
||||||
for (unsigned int i = 0; i < 100; i++) {
|
for (unsigned int i = 1; i < 100; i++) {
|
||||||
int32_t value = 10 + i;
|
int32_t value = 10 + i;
|
||||||
|
|
||||||
ctrls.set(V4L2_CID_BRIGHTNESS, value);
|
ctrls.set(V4L2_CID_BRIGHTNESS, value);
|
||||||
|
@ -150,9 +157,11 @@ protected:
|
||||||
|
|
||||||
int dualControlsWithDelay(uint32_t startOffset)
|
int dualControlsWithDelay(uint32_t startOffset)
|
||||||
{
|
{
|
||||||
|
static const unsigned int maxDelay = 2;
|
||||||
|
|
||||||
std::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {
|
std::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {
|
||||||
{ V4L2_CID_BRIGHTNESS, { 1, false } },
|
{ V4L2_CID_BRIGHTNESS, { 1, false } },
|
||||||
{ V4L2_CID_CONTRAST, { 2, false } },
|
{ V4L2_CID_CONTRAST, { maxDelay, false } },
|
||||||
};
|
};
|
||||||
std::unique_ptr<DelayedControls> delayed =
|
std::unique_ptr<DelayedControls> delayed =
|
||||||
std::make_unique<DelayedControls>(dev_.get(), delays);
|
std::make_unique<DelayedControls>(dev_.get(), delays);
|
||||||
|
@ -165,8 +174,11 @@ protected:
|
||||||
dev_->setControls(&ctrls);
|
dev_->setControls(&ctrls);
|
||||||
delayed->reset();
|
delayed->reset();
|
||||||
|
|
||||||
|
/* Trigger the first frame start event */
|
||||||
|
delayed->applyControls(startOffset);
|
||||||
|
|
||||||
/* Test dual control with delay. */
|
/* Test dual control with delay. */
|
||||||
for (unsigned int i = 0; i < 100; i++) {
|
for (unsigned int i = 1; i < 100; i++) {
|
||||||
uint32_t frame = startOffset + i;
|
uint32_t frame = startOffset + i;
|
||||||
int32_t value = 10 + i;
|
int32_t value = 10 + i;
|
||||||
|
|
||||||
|
@ -189,7 +201,7 @@ protected:
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
expected = i < 1 ? expected : value - 1;
|
expected = i < maxDelay ? expected : value - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TestPass;
|
return TestPass;
|
||||||
|
@ -197,9 +209,11 @@ protected:
|
||||||
|
|
||||||
int dualControlsMultiQueue()
|
int dualControlsMultiQueue()
|
||||||
{
|
{
|
||||||
|
static const unsigned int maxDelay = 2;
|
||||||
|
|
||||||
std::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {
|
std::unordered_map<uint32_t, DelayedControls::ControlParams> delays = {
|
||||||
{ V4L2_CID_BRIGHTNESS, { 1, false } },
|
{ V4L2_CID_BRIGHTNESS, { 1, false } },
|
||||||
{ V4L2_CID_CONTRAST, { 2, false } }
|
{ V4L2_CID_CONTRAST, { maxDelay, false } }
|
||||||
};
|
};
|
||||||
std::unique_ptr<DelayedControls> delayed =
|
std::unique_ptr<DelayedControls> delayed =
|
||||||
std::make_unique<DelayedControls>(dev_.get(), delays);
|
std::make_unique<DelayedControls>(dev_.get(), delays);
|
||||||
|
@ -212,6 +226,9 @@ protected:
|
||||||
dev_->setControls(&ctrls);
|
dev_->setControls(&ctrls);
|
||||||
delayed->reset();
|
delayed->reset();
|
||||||
|
|
||||||
|
/* Trigger the first frame start event */
|
||||||
|
delayed->applyControls(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Queue all controls before any fake frame start. Note we
|
* Queue all controls before any fake frame start. Note we
|
||||||
* can't queue up more then the delayed controls history size
|
* can't queue up more then the delayed controls history size
|
||||||
|
@ -226,8 +243,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process all queued controls. */
|
/* Process all queued controls. */
|
||||||
for (unsigned int i = 0; i < 16; i++) {
|
for (unsigned int i = 1; i < 16; i++) {
|
||||||
int32_t value = 10 + i;
|
int32_t value = 10 + i - 1;
|
||||||
|
|
||||||
delayed->applyControls(i);
|
delayed->applyControls(i);
|
||||||
|
|
||||||
|
@ -245,7 +262,7 @@ protected:
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
expected = i < 1 ? expected : value - 1;
|
expected = i < maxDelay ? expected : value - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TestPass;
|
return TestPass;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue