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 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 19 | #define LOG_TAG "CameraStreamTest" |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 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 | |
| 29 | #include <gui/CpuConsumer.h> |
| 30 | #include <gui/SurfaceTextureClient.h> |
| 31 | |
| 32 | #include "CameraStreamFixture.h" |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 33 | #include "TestExtensions.h" |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 34 | |
| 35 | using namespace android; |
| 36 | using namespace android::camera2; |
| 37 | |
| 38 | namespace android { |
| 39 | namespace camera2 { |
| 40 | namespace tests { |
| 41 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 42 | class CameraStreamTest |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 43 | : public ::testing::TestWithParam<CameraStreamParams>, |
| 44 | public CameraStreamFixture { |
| 45 | |
| 46 | public: |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 47 | CameraStreamTest() : CameraStreamFixture(GetParam()) { |
| 48 | TEST_EXTENSION_FORKING_CONSTRUCTOR; |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 49 | } |
| 50 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 51 | ~CameraStreamTest() { |
| 52 | TEST_EXTENSION_FORKING_DESTRUCTOR; |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | virtual void SetUp() { |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 56 | TEST_EXTENSION_FORKING_SET_UP; |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 57 | } |
| 58 | virtual void TearDown() { |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 59 | TEST_EXTENSION_FORKING_TEAR_DOWN; |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | protected: |
| 63 | |
| 64 | }; |
| 65 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 66 | TEST_P(CameraStreamTest, CreateStream) { |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 67 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 68 | TEST_EXTENSION_FORKING_INIT; |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 69 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 70 | ASSERT_NO_FATAL_FAILURE(CreateStream()); |
| 71 | ASSERT_NO_FATAL_FAILURE(DeleteStream()); |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | //TODO: use a combinatoric generator |
| 75 | static CameraStreamParams TestParameters[] = { |
| 76 | { |
| 77 | /*cameraId*/ 0, |
| 78 | /*mFormat*/ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, |
| 79 | /*mHeapCount*/ 1 |
| 80 | }, |
| 81 | { |
| 82 | /*cameraId*/ 0, |
| 83 | /*mFormat*/ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, |
| 84 | /*mHeapCount*/ 2 |
| 85 | }, |
| 86 | { |
| 87 | /*cameraId*/ 0, |
| 88 | /*mFormat*/ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, |
| 89 | /*mHeapCount*/ 3 |
| 90 | }, |
| 91 | { |
| 92 | /*cameraId*/ 0, |
| 93 | /*mFormat*/ HAL_PIXEL_FORMAT_YCrCb_420_SP, // NV21 |
| 94 | /*mHeapCount*/ 1 |
| 95 | }, |
| 96 | { |
| 97 | /*cameraId*/ 0, |
| 98 | /*mFormat*/ HAL_PIXEL_FORMAT_YCrCb_420_SP, |
| 99 | /*mHeapCount*/ 2 |
| 100 | }, |
| 101 | { |
| 102 | /*cameraId*/ 0, |
| 103 | /*mFormat*/ HAL_PIXEL_FORMAT_YCrCb_420_SP, |
| 104 | /*mHeapCount*/ 3 |
| 105 | }, |
| 106 | { |
| 107 | /*cameraId*/ 0, |
| 108 | /*mFormat*/ HAL_PIXEL_FORMAT_YV12, |
| 109 | /*mHeapCount*/ 1 |
| 110 | }, |
| 111 | { |
| 112 | /*cameraId*/ 0, |
| 113 | /*mFormat*/ HAL_PIXEL_FORMAT_YV12, |
| 114 | /*mHeapCount*/ 2 |
| 115 | }, |
| 116 | { |
| 117 | /*cameraId*/ 0, |
| 118 | /*mFormat*/ HAL_PIXEL_FORMAT_YV12, |
| 119 | /*mHeapCount*/ 3 |
| 120 | }, |
| 121 | { |
| 122 | /*cameraId*/ 0, |
| 123 | /*mFormat*/ HAL_PIXEL_FORMAT_RAW_SENSOR, |
| 124 | /*mHeapCount*/ 1 |
| 125 | }, |
| 126 | { |
| 127 | /*cameraId*/ 0, |
| 128 | /*mFormat*/ HAL_PIXEL_FORMAT_RAW_SENSOR, |
| 129 | /*mHeapCount*/ 2 |
| 130 | }, |
| 131 | { |
| 132 | /*cameraId*/ 0, |
| 133 | /*mFormat*/ HAL_PIXEL_FORMAT_RAW_SENSOR, |
| 134 | /*mHeapCount*/ 3 |
| 135 | }, |
| 136 | }; |
| 137 | |
Igor Murashkin | eab33fc | 2012-11-06 17:02:54 -0800 | [diff] [blame^] | 138 | INSTANTIATE_TEST_CASE_P(StreamParameterCombinations, CameraStreamTest, |
Igor Murashkin | e302ee3 | 2012-11-05 11:14:49 -0800 | [diff] [blame] | 139 | testing::ValuesIn(TestParameters)); |
| 140 | |
| 141 | |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |