Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91c699a3 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7771957 from 6996259b to sc-v2-release

Change-Id: I7d777c1772be4eeb2c234ab132f50ee6e651cdbb
parents e4fa13d0 6996259b
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "ExifUtilsTest"

#include <camera/CameraMetadata.h>
#include "../utils/ExifUtils.h"
#include <gtest/gtest.h>

using android::camera3::ExifUtils;
using android::camera3::ExifOrientation;
using android::CameraMetadata;

uint32_t kImageWidth = 1920;
uint32_t kImageHeight = 1440;
ExifOrientation kExifOrientation = ExifOrientation::ORIENTATION_0_DEGREES;

// Test that setFromMetadata works correctly, without errors.
TEST(ExifUtilsTest, SetFromMetadataTest) {
    std::unique_ptr<ExifUtils> utils(ExifUtils::create());
    uint8_t invalidSensorPixelMode = 2;
    uint8_t validSensorPixelMode = ANDROID_SENSOR_PIXEL_MODE_DEFAULT;
    CameraMetadata metadata;
    // Empty staticInfo
    CameraMetadata staticInfo;
    ASSERT_TRUE(utils->initializeEmpty());
    ASSERT_TRUE(
            metadata.update(ANDROID_SENSOR_PIXEL_MODE, &invalidSensorPixelMode, 1) == android::OK);
    ASSERT_FALSE(utils->setFromMetadata(metadata, staticInfo, kImageWidth, kImageHeight));
    ASSERT_TRUE(
            metadata.update(ANDROID_SENSOR_PIXEL_MODE, &validSensorPixelMode, 1) == android::OK);
    ASSERT_TRUE(utils->setFromMetadata(metadata, staticInfo, kImageWidth, kImageHeight));
    ASSERT_TRUE(utils->setImageWidth(kImageWidth));
    ASSERT_TRUE(utils->setImageHeight(kImageHeight));
    ASSERT_TRUE(utils->setOrientationValue(kExifOrientation));
    ASSERT_TRUE(utils->generateApp1());
    const uint8_t* exifBuffer = utils->getApp1Buffer();
    ASSERT_NE(exifBuffer, nullptr);
    size_t exifBufferSize = utils->getApp1Length();
    ASSERT_TRUE(exifBufferSize != 0);
}
+1 −1
Original line number Diff line number Diff line
@@ -920,7 +920,7 @@ bool ExifUtilsImpl::setFromMetadata(const CameraMetadata& metadata,
    camera_metadata_ro_entry sensorPixelModeEntry = metadata.find(ANDROID_SENSOR_PIXEL_MODE);
    if (sensorPixelModeEntry.count != 0) {
        sensorPixelMode = sensorPixelModeEntry.data.u8[0];
        if (sensorPixelMode != ANDROID_SENSOR_PIXEL_MODE_DEFAULT ||
        if (sensorPixelMode != ANDROID_SENSOR_PIXEL_MODE_DEFAULT &&
            sensorPixelMode != ANDROID_SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION) {
            ALOGE("%s: Request sensor pixel mode is not one of the valid values %d",
                      __FUNCTION__, sensorPixelMode);