From patchwork Fri Jun 21 16:13:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1500 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 57DD3615FF for ; Fri, 21 Jun 2019 18:14:08 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 03DD633C; Fri, 21 Jun 2019 18:14:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1561133648; bh=FxHWjaUOq2Qab1TBN0eiVHm2pTJE3gPMBx0l/7AYuuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX6r0TGCUZwylRLnTmiINxZU9rI5tO528ep6/Lpl+LjsMoUEuELk4CCz+lkux98Yp gGf2J3/SsK81cI69x12UMGKv7j03wC/eonn4wI4NYCzwS3kFMXcBiMSH5u1c5d4Tei xnwc0AHwzCGBmxJHJLJlPYyJoZmSk2/WlJO3U51E= From: Kieran Bingham To: LibCamera Devel Date: Fri, 21 Jun 2019 17:13:59 +0100 Message-Id: <20190621161401.28337-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190621161401.28337-1-kieran.bingham@ideasonboard.com> References: <20190621161401.28337-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 7/9] libcamera: test: Add ControlList tests X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jun 2019 16:14:08 -0000 Extend the Controls tests with specific testing of the ControlList infrastructure and public APIs. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- test/controls.cpp | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/test/controls.cpp b/test/controls.cpp index 94e89f270108..c4145b7a0543 100644 --- a/test/controls.cpp +++ b/test/controls.cpp @@ -25,6 +25,101 @@ protected: return TestPass; } + int testControlList() + { + ControlList list; + + if (list.contains(ManualGain)) { + cout << "Unexpected item in the bagging area" << endl; + return TestFail; + } + + if (list.size() != 0) { + cout << "List should contain zero elements" << endl; + return TestFail; + } + + if (!list.empty()) { + cout << "List expected to be empty" << endl; + return TestFail; + } + + /* Set a control */ + list[ManualBrightness] = 255; + + /* Contains should still not find a non set control */ + if (list.contains(ManualGain)) { + cout << "Unexpected item in the bagging area" << endl; + return TestFail; + } + + if (list.size() != 1) { + cout << "List should contain one element" << endl; + return TestFail; + } + + if (list.empty()) { + cout << "List not expected to be empty" << endl; + return TestFail; + } + + /* Finally lets find that Gain */ + list[ManualGain] = 128; + if (!list.contains(ManualGain)) { + cout << "Couldn't identify an in-list control" << endl; + return TestFail; + } + + /* Validate value retrieval */ + if (list[ManualGain].getInt() != 128 || + list[ManualBrightness].getInt() != 255) { + cout << "Failed to retrieve control value" << endl; + return TestFail; + } + + /* Update using ControlInfo */ + ControlInfo gainInfo(ManualGain); + list.update(gainInfo, 200); + if (list[ManualGain].getInt() != 200) { + cout << "Failed to update control value" << endl; + return TestFail; + } + + /* Create a new list from an existing one */ + ControlList newList; + + newList.update(list); + + /* + * Clear down the original list and assert items are still in + * the new list + */ + list.reset(); + + if (list.size() != 0) { + cout << "Old List should contain zero elements" << endl; + return TestFail; + } + + if (!list.empty()) { + cout << "Old List expected to be empty" << endl; + return TestFail; + } + + if (newList.size() != 2) { + cout << "New list with incorrect size" << endl; + return TestFail; + } + + if (!(newList.contains(ManualGain) && + newList.contains(ManualBrightness))) { + cout << "New list with incorrect items" << endl; + return TestFail; + } + + return TestPass; + } + int run() { int ret; @@ -33,6 +128,10 @@ protected: if (ret) return ret; + ret = testControlList(); + if (ret) + return ret; + return TestPass; } };