blob: 739eba6d979c76c4348f66ee36fdcff54dea8a2d [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>
32#include <gui/SurfaceTextureClient.h>
33
34#include <string>
35#include "CameraStreamFixture.h"
36
37namespace android {
38namespace camera2 {
39namespace tests {
40
41//FIXME: dont hardcode
42static CameraStreamParams METADATA_STREAM_PARAMETERS = {
43 /*mCameraId*/ 0,
44 /*mFormat*/ HAL_PIXEL_FORMAT_YCrCb_420_SP,
45 /*mHeapCount*/ 2
46};
47
48class DISABLED_CameraMetadataTest
49 : public ::testing::Test,
50 public CameraStreamFixture {
51
52public:
53 DISABLED_CameraMetadataTest()
54 : CameraStreamFixture(METADATA_STREAM_PARAMETERS) {
55 }
56
57 ~DISABLED_CameraMetadataTest() {
58 }
59
60 int GetTypeFromTag(uint32_t tag) const {
61 return get_camera_metadata_tag_type(tag);
62 }
63
64 int GetTypeFromStaticTag(uint32_t tag) const {
65 const CameraMetadata& staticInfo = mDevice->info();
66 camera_metadata_ro_entry entry = staticInfo.find(tag);
67 return entry.type;
68 }
69
70 static void SetUpTestCase() {
71 }
72
73 static void TearDownTestCase()
74 {
75 }
76
77protected:
78
79};
80
81TEST_F(DISABLED_CameraMetadataTest, types) {
82
83 if (HasFatalFailure()) {
84 return;
85 }
86
87 //FIXME: set this up in an external file of some sort (xml?)
88 {
89 char value[PROPERTY_VALUE_MAX];
90 property_get("ro.build.id", value, "");
91 std::string str_value(value);
92
93 if (str_value == "manta")
94 {
95 EXPECT_EQ(TYPE_BYTE,
96 GetTypeFromStaticTag(ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO));
97 EXPECT_EQ(TYPE_BYTE,
98 GetTypeFromStaticTag(ANDROID_QUIRKS_USE_ZSL_FORMAT));
99 EXPECT_EQ(TYPE_BYTE,
100 GetTypeFromStaticTag(ANDROID_QUIRKS_METERING_CROP_REGION));
101 }
102 }
103
104 /*
105 TODO:
106 go through all static metadata and make sure all fields we expect
107 that are there, ARE there.
108
109 dont worry about the type as its enforced by the metadata api
110 we can probably check the range validity though
111 */
112
113 if (0) {
114 camera_metadata_ro_entry entry;
115 EXPECT_EQ(TYPE_BYTE, entry.type);
116 EXPECT_EQ(TYPE_INT32, entry.type);
117 EXPECT_EQ(TYPE_FLOAT, entry.type);
118 EXPECT_EQ(TYPE_INT64, entry.type);
119 EXPECT_EQ(TYPE_DOUBLE, entry.type);
120 EXPECT_EQ(TYPE_RATIONAL, entry.type);
121 }
122}
123
124}
125}
126}