blob: 26b2551fd774e9dee0f0377e7edb2d6d7f579f00 [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#include <gtest/gtest.h>
18
Igor Murashkineab33fc2012-11-06 17:02:54 -080019#define LOG_TAG "CameraStreamTest"
Igor Murashkine302ee32012-11-05 11:14:49 -080020#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 Murashkineab33fc2012-11-06 17:02:54 -080033#include "TestExtensions.h"
Igor Murashkine302ee32012-11-05 11:14:49 -080034
35using namespace android;
36using namespace android::camera2;
37
38namespace android {
39namespace camera2 {
40namespace tests {
41
Igor Murashkineab33fc2012-11-06 17:02:54 -080042class CameraStreamTest
Igor Murashkine302ee32012-11-05 11:14:49 -080043 : public ::testing::TestWithParam<CameraStreamParams>,
44 public CameraStreamFixture {
45
46public:
Igor Murashkineab33fc2012-11-06 17:02:54 -080047 CameraStreamTest() : CameraStreamFixture(GetParam()) {
48 TEST_EXTENSION_FORKING_CONSTRUCTOR;
Igor Murashkine302ee32012-11-05 11:14:49 -080049 }
50
Igor Murashkineab33fc2012-11-06 17:02:54 -080051 ~CameraStreamTest() {
52 TEST_EXTENSION_FORKING_DESTRUCTOR;
Igor Murashkine302ee32012-11-05 11:14:49 -080053 }
54
55 virtual void SetUp() {
Igor Murashkineab33fc2012-11-06 17:02:54 -080056 TEST_EXTENSION_FORKING_SET_UP;
Igor Murashkine302ee32012-11-05 11:14:49 -080057 }
58 virtual void TearDown() {
Igor Murashkineab33fc2012-11-06 17:02:54 -080059 TEST_EXTENSION_FORKING_TEAR_DOWN;
Igor Murashkine302ee32012-11-05 11:14:49 -080060 }
61
62protected:
63
64};
65
Igor Murashkineab33fc2012-11-06 17:02:54 -080066TEST_P(CameraStreamTest, CreateStream) {
Igor Murashkine302ee32012-11-05 11:14:49 -080067
Igor Murashkineab33fc2012-11-06 17:02:54 -080068 TEST_EXTENSION_FORKING_INIT;
Igor Murashkine302ee32012-11-05 11:14:49 -080069
Igor Murashkineab33fc2012-11-06 17:02:54 -080070 ASSERT_NO_FATAL_FAILURE(CreateStream());
71 ASSERT_NO_FATAL_FAILURE(DeleteStream());
Igor Murashkine302ee32012-11-05 11:14:49 -080072}
73
74//TODO: use a combinatoric generator
75static 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 Murashkineab33fc2012-11-06 17:02:54 -0800138INSTANTIATE_TEST_CASE_P(StreamParameterCombinations, CameraStreamTest,
Igor Murashkine302ee32012-11-05 11:14:49 -0800139 testing::ValuesIn(TestParameters));
140
141
142}
143}
144}
145