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