1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <gtest/gtest.h>
18#include "camera3test_fixtures.h"
19
20namespace tests {
21
22TEST_F(Camera3Module, NumberOfCameras) {
23    ASSERT_LT(0, num_cams()) << "No cameras found";
24    ASSERT_GE(kMmaxCams, num_cams()) << "Too many cameras found";
25}
26
27TEST_F(Camera3Module, IsActiveArraySizeSubsetPixelArraySize) {
28    for (int i = 0; i < num_cams(); ++i) {
29        ASSERT_TRUE(NULL != cam_module()->get_camera_info)
30            << "get_camera_info is not implemented";
31
32        camera_info info;
33        ASSERT_EQ(0, cam_module()->get_camera_info(i, &info))
34                    << "Can't get camera info for" << i;
35
36        camera_metadata_entry entry;
37        ASSERT_EQ(0, find_camera_metadata_entry(
38                    const_cast<camera_metadata_t*>(
39                        info.static_camera_characteristics),
40                        ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, &entry))
41                            << "Can't find the sensor pixel array size.";
42        int pixel_array_w = entry.data.i32[0];
43        int pixel_array_h = entry.data.i32[1];
44
45        ASSERT_EQ(0, find_camera_metadata_entry(
46                    const_cast<camera_metadata_t*>(
47                        info.static_camera_characteristics),
48                        ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, &entry))
49                            << "Can't find the sensor active array size.";
50        int active_array_w = entry.data.i32[0];
51        int active_array_h = entry.data.i32[1];
52
53        EXPECT_LE(active_array_h, pixel_array_h);
54        EXPECT_LE(active_array_w, pixel_array_w);
55    }
56}
57
58TEST_F(Camera3Device, DefaultSettingsStillCaptureHasAndroidControlMode) {
59    ASSERT_TRUE(NULL != cam_device()->ops) << "Camera device ops are NULL";
60    const camera_metadata_t *default_settings =
61        cam_device()->ops->construct_default_request_settings(cam_device(),
62            CAMERA3_TEMPLATE_STILL_CAPTURE);
63    ASSERT_TRUE(NULL != default_settings) << "Camera default settings are NULL";
64    camera_metadata_entry entry;
65    ASSERT_EQ(0, find_camera_metadata_entry(
66                const_cast<camera_metadata_t*>(default_settings),
67                ANDROID_CONTROL_MODE, &entry))
68                    << "Can't find ANDROID_CONTROL_MODE in default settings.";
69}
70
71}  // namespace tests
72