blob: 722e71ed595b719d432a9b6f6abeba453541d2b3 [file] [log] [blame]
Igor Murashkine302ee32012-11-05 11:14:49 -08001/*
2 * Copyright (C) 2012 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#define LOG_NDEBUG 0
18#define LOG_TAG "CameraMetadataTestFunctional"
19#include "cutils/log.h"
20#include "cutils/properties.h"
21#include "utils/Errors.h"
22
23#include "gtest/gtest.h"
24#include "system/camera_metadata.h"
25#include "hardware/hardware.h"
26#include "hardware/camera2.h"
27
28#include "Camera2Device.h"
29#include "utils/StrongPointer.h"
30
31#include <gui/CpuConsumer.h>
Mathias Agopiancc501112013-02-14 17:34:35 -080032#include <gui/Surface.h>
Igor Murashkine302ee32012-11-05 11:14:49 -080033
34#include <string>
Igor Murashkineab33fc2012-11-06 17:02:54 -080035
Igor Murashkine302ee32012-11-05 11:14:49 -080036#include "CameraStreamFixture.h"
Igor Murashkineab33fc2012-11-06 17:02:54 -080037#include "TestExtensions.h"
Igor Murashkine302ee32012-11-05 11:14:49 -080038
39namespace android {
40namespace camera2 {
41namespace tests {
42
43//FIXME: dont hardcode
44static CameraStreamParams METADATA_STREAM_PARAMETERS = {
Igor Murashkine302ee32012-11-05 11:14:49 -080045 /*mFormat*/ HAL_PIXEL_FORMAT_YCrCb_420_SP,
46 /*mHeapCount*/ 2
47};
48
Igor Murashkineab33fc2012-11-06 17:02:54 -080049class CameraMetadataTest
Igor Murashkine302ee32012-11-05 11:14:49 -080050 : public ::testing::Test,
51 public CameraStreamFixture {
52
53public:
Igor Murashkineab33fc2012-11-06 17:02:54 -080054 CameraMetadataTest()
Igor Murashkine302ee32012-11-05 11:14:49 -080055 : CameraStreamFixture(METADATA_STREAM_PARAMETERS) {
Igor Murashkineab33fc2012-11-06 17:02:54 -080056 TEST_EXTENSION_FORKING_CONSTRUCTOR;
Igor Murashkine302ee32012-11-05 11:14:49 -080057 }
58
Igor Murashkineab33fc2012-11-06 17:02:54 -080059 ~CameraMetadataTest() {
60 TEST_EXTENSION_FORKING_DESTRUCTOR;
Igor Murashkine302ee32012-11-05 11:14:49 -080061 }
62
63 int GetTypeFromTag(uint32_t tag) const {
64 return get_camera_metadata_tag_type(tag);
65 }
66
67 int GetTypeFromStaticTag(uint32_t tag) const {
68 const CameraMetadata& staticInfo = mDevice->info();
69 camera_metadata_ro_entry entry = staticInfo.find(tag);
70 return entry.type;
71 }
72
Igor Murashkine302ee32012-11-05 11:14:49 -080073protected:
74
75};
76
Igor Murashkineab33fc2012-11-06 17:02:54 -080077TEST_F(CameraMetadataTest, types) {
Igor Murashkine302ee32012-11-05 11:14:49 -080078
Igor Murashkineab33fc2012-11-06 17:02:54 -080079 TEST_EXTENSION_FORKING_INIT;
Igor Murashkine302ee32012-11-05 11:14:49 -080080
81 //FIXME: set this up in an external file of some sort (xml?)
82 {
83 char value[PROPERTY_VALUE_MAX];
84 property_get("ro.build.id", value, "");
85 std::string str_value(value);
86
87 if (str_value == "manta")
88 {
89 EXPECT_EQ(TYPE_BYTE,
90 GetTypeFromStaticTag(ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO));
91 EXPECT_EQ(TYPE_BYTE,
92 GetTypeFromStaticTag(ANDROID_QUIRKS_USE_ZSL_FORMAT));
93 EXPECT_EQ(TYPE_BYTE,
94 GetTypeFromStaticTag(ANDROID_QUIRKS_METERING_CROP_REGION));
95 }
96 }
97
98 /*
99 TODO:
100 go through all static metadata and make sure all fields we expect
101 that are there, ARE there.
102
103 dont worry about the type as its enforced by the metadata api
104 we can probably check the range validity though
105 */
106
107 if (0) {
108 camera_metadata_ro_entry entry;
109 EXPECT_EQ(TYPE_BYTE, entry.type);
110 EXPECT_EQ(TYPE_INT32, entry.type);
111 EXPECT_EQ(TYPE_FLOAT, entry.type);
112 EXPECT_EQ(TYPE_INT64, entry.type);
113 EXPECT_EQ(TYPE_DOUBLE, entry.type);
114 EXPECT_EQ(TYPE_RATIONAL, entry.type);
115 }
116}
117
118}
119}
120}