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 | #include <gtest/gtest.h> |
| 18 | |
| 19 | #define LOG_TAG "DISABLED_CameraModuleTest" |
| 20 | #define LOG_NDEBUG 0 |
| 21 | #include <utils/Log.h> |
| 22 | |
| 23 | #include "hardware/hardware.h" |
| 24 | #include "hardware/camera2.h" |
| 25 | |
| 26 | #include "Camera2Device.h" |
| 27 | #include "utils/StrongPointer.h" |
| 28 | #include "CameraModuleFixture.h" |
| 29 | |
| 30 | namespace android { |
| 31 | namespace camera2 { |
| 32 | namespace tests { |
| 33 | |
| 34 | class DISABLED_CameraModuleTest : public ::testing::Test, |
| 35 | public CameraModuleFixture<> { |
| 36 | |
| 37 | virtual void SetUp() { |
| 38 | //CameraModuleFixture::SetUp(); |
| 39 | } |
| 40 | |
| 41 | virtual void TearDown() { |
| 42 | //CameraModuleFixture::TearDown(); |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | TEST_F(DISABLED_CameraModuleTest, LoadModule) { |
| 47 | |
| 48 | if (HasFatalFailure()) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | for (int i = 0; i < mNumberOfCameras; ++i) { |
| 53 | mDevice = new Camera2Device(i); |
| 54 | ASSERT_EQ(OK, mDevice->initialize(mModule)) |
| 55 | << "Failed to initialize device " << i; |
| 56 | mDevice.clear(); |
| 57 | } |
| 58 | |
| 59 | } |
| 60 | |
| 61 | TEST_F(DISABLED_CameraModuleTest, LoadModuleBadIndices) { |
| 62 | |
| 63 | if (HasFatalFailure()) { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | int idx[] = { -1, mNumberOfCameras, mNumberOfCameras + 1 }; |
| 68 | |
| 69 | for (unsigned i = 0; i < sizeof(idx)/sizeof(idx[0]); ++i) { |
| 70 | mDevice = new Camera2Device(idx[i]); |
| 71 | status_t deviceInitializeCode = mDevice->initialize(mModule); |
| 72 | EXPECT_NE(OK, deviceInitializeCode); |
| 73 | EXPECT_EQ(-ENODEV, deviceInitializeCode) |
| 74 | << "Incorrect error code when trying to initialize invalid index " |
| 75 | << idx[i]; |
| 76 | mDevice.clear(); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | TEST_F(DISABLED_CameraModuleTest, GetCameraInfo) { |
| 81 | |
| 82 | if (HasFatalFailure()) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | for (int i = 0; i < mNumberOfCameras; ++i) { |
| 87 | struct camera_info info; |
| 88 | ASSERT_EQ(OK, mModule->get_camera_info(i, &info)); |
| 89 | } |
| 90 | |
| 91 | } |
| 92 | |
| 93 | TEST_F(DISABLED_CameraModuleTest, GetCameraInfoBadIndices) { |
| 94 | |
| 95 | if (HasFatalFailure()) { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | int idx[] = { -1, mNumberOfCameras, mNumberOfCameras + 1 }; |
| 100 | for (unsigned i = 0; i < sizeof(idx)/sizeof(idx[0]); ++i) { |
| 101 | struct camera_info info; |
| 102 | EXPECT_NE(OK, mModule->get_camera_info(idx[i], &info)); |
| 103 | EXPECT_EQ(-ENODEV, mModule->get_camera_info(idx[i], &info)) |
| 104 | << "Incorrect error code for get_camera_info idx= " |
| 105 | << idx[i]; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * TODO: Additional test to add: open two cameras at once. |
| 111 | * (is allowed to fail, at least for now, but should not blow up) |
| 112 | */ |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |