blob: ef51a5f6b8ec05145dadc921b735b1f892e9229a [file] [log] [blame]
Tanmay Patilb2897b42020-06-08 17:55:02 -07001/*
2 * Copyright 2020 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_TAG "ConfigReaderTests"
18
19#include "ConfigReader.h"
20
21#include "core_lib.h"
22
23#include <gtest/gtest.h>
24#include <string>
25
26namespace android {
27namespace hardware {
28namespace automotive {
29namespace sv {
30namespace V1_0 {
31namespace implementation {
32namespace {
33
34using android_auto::surround_view::SurroundView2dParams;
35using android_auto::surround_view::SurroundView3dParams;
36
37TEST(ConfigReaderTests, ReadConfigSuccess) {
38 SurroundViewConfig svConfig;
Tanmay Patilfcb633d2020-06-15 13:39:31 -070039 EXPECT_EQ(ReadSurroundViewConfig("/vendor/automotive/sv/sv_sample_config.xml", &svConfig),
Tanmay Patilb2897b42020-06-08 17:55:02 -070040 IOStatus::OK);
41
42 EXPECT_EQ(svConfig.version, "1.0");
43
44 // Camera config
Tanmay Patilfcb633d2020-06-15 13:39:31 -070045 EXPECT_EQ(svConfig.cameraConfig.evsGroupId, "v4l2loopback_group0");
Tanmay Patilb2897b42020-06-08 17:55:02 -070046
47 // Camera Ids
Tanmay Patilfcb633d2020-06-15 13:39:31 -070048 EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[0], "/dev/video90");
49 EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[1], "/dev/video91");
50 EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[2], "/dev/video92");
51 EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[3], "/dev/video93");
Tanmay Patilb2897b42020-06-08 17:55:02 -070052
53 // Masks
54 EXPECT_EQ(svConfig.cameraConfig.maskFilenames.size(), 4);
55 EXPECT_EQ(svConfig.cameraConfig.maskFilenames[0], "/vendor/mask_front.png");
56 EXPECT_EQ(svConfig.cameraConfig.maskFilenames[1], "/vendor/mask_right.png");
57 EXPECT_EQ(svConfig.cameraConfig.maskFilenames[2], "/vendor/mask_rear.png");
58 EXPECT_EQ(svConfig.cameraConfig.maskFilenames[3], "/vendor/mask_left.png");
59
60 // Surround view 2D
61 EXPECT_EQ(svConfig.sv2dConfig.sv2dEnabled, true);
62 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.resolution.width, 600);
63 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.resolution.height, 900);
64 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.physical_size.width, 6.0);
65 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.physical_size.height, 9.0);
66 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.physical_center.x, 0.0);
67 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.physical_center.y, 0.0);
68 EXPECT_EQ(svConfig.sv2dConfig.carBoundingBox.width, 2.0);
69 EXPECT_EQ(svConfig.sv2dConfig.carBoundingBox.height, 3.0);
70 EXPECT_EQ(svConfig.sv2dConfig.carBoundingBox.x, 1.0);
71 EXPECT_EQ(svConfig.sv2dConfig.carBoundingBox.y, 1.5);
72 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.high_quality_blending,
73 SurroundView2dParams::BlendingType::MULTIBAND);
74 EXPECT_EQ(svConfig.sv2dConfig.sv2dParams.low_quality_blending,
75 SurroundView2dParams::BlendingType::ALPHA);
76
77 // Surround view 3D
78 EXPECT_EQ(svConfig.sv3dConfig.sv3dEnabled, true);
79 EXPECT_NE(svConfig.sv3dConfig.carModelConfigFile, "");
80 EXPECT_NE(svConfig.sv3dConfig.carModelObjFile, "");
81 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.plane_radius, 6.0);
82 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.plane_divisions, 20);
83 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.curve_height, 5.0);
84 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.curve_divisions, 30);
85 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.angular_divisions, 50);
86 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.curve_coefficient, 2.0);
87 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.high_details_shadows, true);
88 EXPECT_EQ(svConfig.sv3dConfig.sv3dParams.high_details_reflections, true);
89}
90
91} // namespace
92} // namespace implementation
93} // namespace V1_0
94} // namespace sv
95} // namespace automotive
96} // namespace hardware
97} // namespace android