blob: 86fc50cabb56d08e2d669e40ce4954af4e12421f [file] [log] [blame]
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +01001/*
2 * Copyright (C) 2023 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#include "util/EglDisplayContext.h"
19#include "util/EglProgram.h"
20#include "util/EglUtil.h"
21
22namespace android {
23namespace companion {
24namespace virtualcamera {
25namespace {
26
27constexpr char kGlExtYuvTarget[] = "GL_EXT_YUV_target";
28
29TEST(EglDisplayContextTest, SuccessfulInitialization) {
30 EglDisplayContext displayContext;
31
32 EXPECT_TRUE(displayContext.isInitialized());
33}
34
35class EglProgramTest : public ::testing::Test {
36 public:
37 void SetUp() override {
38 ASSERT_TRUE(mEglDisplayContext.isInitialized());
39 ASSERT_TRUE(mEglDisplayContext.makeCurrent());
40 }
41
42 private:
43 EglDisplayContext mEglDisplayContext;
44};
45
46TEST_F(EglProgramTest, EglTestPatternProgramSuccessfulInit) {
47 EglTestPatternProgram eglTestPatternProgram;
48
49 // Verify the shaders compiled and linked successfully.
50 EXPECT_TRUE(eglTestPatternProgram.isInitialized());
51}
52
53TEST_F(EglProgramTest, EglTextureProgramSuccessfulInit) {
54 if (!isGlExtensionSupported(kGlExtYuvTarget)) {
55 GTEST_SKIP() << "Skipping test because of missing required GL extension "
56 << kGlExtYuvTarget;
57 }
58
59 EglTextureProgram eglTextureProgram;
60
61 // Verify the shaders compiled and linked successfully.
62 EXPECT_TRUE(eglTextureProgram.isInitialized());
63}
64
65} // namespace
66} // namespace virtualcamera
67} // namespace companion
68} // namespace android