blob: b694aaf5a79352f6ade8fbd3531fa1bcad334af4 [file] [log] [blame]
Haoxiang Li0601e852020-06-19 16:41:33 -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 "SurroundViewSessionTests"
18
19#include "mock-evs/MockEvsEnumerator.h"
20#include "mock-evs/MockSurroundViewCallback.h"
21
22#include "IOModule.h"
23#include "SurroundView2dSession.h"
24#include "SurroundView3dSession.h"
25
26#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
27
28#include <android-base/logging.h>
29
30#include <gtest/gtest.h>
31
32namespace android {
33namespace hardware {
34namespace automotive {
35namespace sv {
36namespace V1_0 {
37namespace implementation {
38namespace {
39
40const char* kSvConfigFilename = "vendor/etc/automotive/sv/sv_sample_config.xml";
41
42TEST(SurroundViewSessionTests, startAndStopSurroundView2dSession) {
43 sp<IEvsEnumerator> fakeEvs = new MockEvsEnumerator();
44 IOModule* ioModule = new IOModule(kSvConfigFilename);
45 EXPECT_EQ(ioModule->initialize(), IOStatus::OK);
46
47 IOModuleConfig config;
48 ioModule->getConfig(&config);
49
50 sp<SurroundView2dSession> sv2dSession =
51 new SurroundView2dSession(fakeEvs, &config);
52
53 EXPECT_TRUE(sv2dSession->initialize());
54
55 sp<MockSurroundViewCallback> sv2dCallback =
56 new MockSurroundViewCallback(sv2dSession);
57
58 EXPECT_EQ(sv2dSession->startStream(sv2dCallback), SvResult::OK);
59
60 sv2dSession->stopStream();
61}
62
63TEST(SurroundViewSessionTests, startAndStopSurroundView3dSession) {
64 sp<IEvsEnumerator> fakeEvs = new MockEvsEnumerator();
65 IOModule* ioModule = new IOModule(kSvConfigFilename);
66 EXPECT_EQ(ioModule->initialize(), IOStatus::OK);
67
68 IOModuleConfig config;
69 ioModule->getConfig(&config);
70
71 sp<SurroundView3dSession> sv3dSession =
72 new SurroundView3dSession(fakeEvs,
73 nullptr, /* VhalHandler */
74 nullptr, /* AnimationModule */
75 &config);
76
77 EXPECT_TRUE(sv3dSession->initialize());
78
79 sp<MockSurroundViewCallback> sv3dCallback =
80 new MockSurroundViewCallback(sv3dSession);
81
82 View3d view = {};
83 vector<View3d> views;
84 views.emplace_back(view);
85 sv3dSession->setViews(views);
86
87 EXPECT_EQ(sv3dSession->startStream(sv3dCallback), SvResult::OK);
88
89 sv3dSession->stopStream();
90}
91
92} // namespace
93} // namespace implementation
94} // namespace V1_0
95} // namespace sv
96} // namespace automotive
97} // namespace hardware
98} // namespace android