summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasha Levitskiy <sanek@google.com>2013-12-12 14:08:55 -0800
committerSasha Levitskiy <sanek@google.com>2013-12-12 14:08:55 -0800
commit024c15346b00c2ac7d6b53e78422570bbc4245c7 (patch)
treebd6ebeaebea118bdfc838b54e9f94e281b92a3cb
parent4a7b2171f00ba37e301105e8ea1f61dddaa4db3d (diff)
downloadhardware_libhardware-024c15346b00c2ac7d6b53e78422570bbc4245c7.zip
hardware_libhardware-024c15346b00c2ac7d6b53e78422570bbc4245c7.tar.gz
hardware_libhardware-024c15346b00c2ac7d6b53e78422570bbc4245c7.tar.bz2
Camera: HAL3: device test fixture and a test.
Change-Id: Ifaec4be35e8f4fb80c8e71e24499fbcd40fddb6e Signed-off-by: Sasha Levitskiy <sanek@google.com>
-rw-r--r--tests/camera3/camera3test_fixtures.h31
-rw-r--r--tests/camera3/camera3tests.cpp17
2 files changed, 43 insertions, 5 deletions
diff --git a/tests/camera3/camera3test_fixtures.h b/tests/camera3/camera3test_fixtures.h
index e25880d..81d1997 100644
--- a/tests/camera3/camera3test_fixtures.h
+++ b/tests/camera3/camera3test_fixtures.h
@@ -26,12 +26,12 @@ namespace tests {
static const int kMmaxCams = 2;
static const uint16_t kVersion3_0 = HARDWARE_MODULE_API_VERSION(3, 0);
-class Camera3Test : public testing::Test {
+class Camera3Module : public testing::Test {
public:
- Camera3Test() :
+ Camera3Module() :
num_cams_(0),
cam_module_(NULL) {}
- ~Camera3Test() {}
+ ~Camera3Module() {}
protected:
virtual void SetUp() {
const hw_module_t *hw_module = NULL;
@@ -52,6 +52,31 @@ class Camera3Test : public testing::Test {
const camera_module_t *cam_module_;
};
+class Camera3Device : public Camera3Module {
+ public:
+ Camera3Device() :
+ cam_device_(NULL) {}
+ ~Camera3Device() {}
+ protected:
+ virtual void SetUp() {
+ Camera3Module::SetUp();
+ hw_device_t *device = NULL;
+ ASSERT_TRUE(NULL != cam_module()->common.methods->open)
+ << "Camera open() is unimplemented";
+ ASSERT_EQ(0, cam_module()->common.methods->open(
+ (const hw_module_t*)cam_module(), "0", &device))
+ << "Can't open camera device";
+ ASSERT_TRUE(NULL != device)
+ << "Camera open() returned a NULL device";
+ ASSERT_EQ(kVersion3_0, device->version)
+ << "The device does not support HAL3";
+ cam_device_ = reinterpret_cast<camera3_device_t*>(device);
+ }
+ camera3_device_t* cam_device() { return cam_device_; }
+ private:
+ camera3_device *cam_device_;
+};
+
} // namespace tests
#endif // __ANDROID_HAL_CAMERA3_TEST_COMMON__
diff --git a/tests/camera3/camera3tests.cpp b/tests/camera3/camera3tests.cpp
index 9585483..5dbe588 100644
--- a/tests/camera3/camera3tests.cpp
+++ b/tests/camera3/camera3tests.cpp
@@ -19,12 +19,12 @@
namespace tests {
-TEST_F(Camera3Test, NumberOfCameras) {
+TEST_F(Camera3Module, NumberOfCameras) {
ASSERT_LT(0, num_cams()) << "No cameras found";
ASSERT_GE(kMmaxCams, num_cams()) << "Too many cameras found";
}
-TEST_F(Camera3Test, IsActiveArraySizeSubsetPixelArraySize) {
+TEST_F(Camera3Module, IsActiveArraySizeSubsetPixelArraySize) {
for (int i = 0; i < num_cams(); ++i) {
ASSERT_TRUE(NULL != cam_module()->get_camera_info)
<< "get_camera_info is not implemented";
@@ -55,4 +55,17 @@ TEST_F(Camera3Test, IsActiveArraySizeSubsetPixelArraySize) {
}
}
+TEST_F(Camera3Device, DefaultSettingsStillCaptureHasAndroidControlMode) {
+ ASSERT_TRUE(NULL != cam_device()->ops) << "Camera device ops are NULL";
+ const camera_metadata_t *default_settings =
+ cam_device()->ops->construct_default_request_settings(cam_device(),
+ CAMERA3_TEMPLATE_STILL_CAPTURE);
+ ASSERT_TRUE(NULL != default_settings) << "Camera default settings are NULL";
+ camera_metadata_entry entry;
+ ASSERT_EQ(0, find_camera_metadata_entry(
+ const_cast<camera_metadata_t*>(default_settings),
+ ANDROID_CONTROL_MODE, &entry))
+ << "Can't find ANDROID_CONTROL_MODE in default settings.";
+}
+
} // namespace tests