1 /*
2 * Copyright (C) 2021 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
19 #include "renderthread/EglManager.h"
20 #include "renderthread/RenderEffectCapabilityQuery.h"
21 #include "tests/common/TestContext.h"
22
23 using namespace android;
24 using namespace android::uirenderer;
25 using namespace android::uirenderer::renderthread;
26 using namespace android::uirenderer::test;
27
TEST(EglManager,doesSurfaceLeak)28 TEST(EglManager, doesSurfaceLeak) {
29 EglManager eglManager;
30 eglManager.initialize();
31
32 ASSERT_TRUE(eglManager.hasEglContext());
33
34 auto colorSpace = SkColorSpace::MakeSRGB();
35 for (int i = 0; i < 100; i++) {
36 TestContext context;
37 auto result =
38 eglManager.createSurface(context.surface().get(), ColorMode::Default, colorSpace);
39 EXPECT_TRUE(result);
40 EGLSurface surface = result.unwrap();
41 eglManager.destroySurface(surface);
42 }
43
44 eglManager.destroy();
45 }
46
TEST(EglManager,verifyRenderEffectCacheSupported)47 TEST(EglManager, verifyRenderEffectCacheSupported) {
48 EglManager eglManager;
49 eglManager.initialize();
50 auto* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
51 auto* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
52 // Make sure that EglManager initializes Properties::enableRenderEffectCache
53 // based on the given gl vendor and version within EglManager->initialize()
54 bool renderEffectCacheSupported = supportsRenderEffectCache(vendor, version);
55 EXPECT_EQ(renderEffectCacheSupported,
56 Properties::enableRenderEffectCache);
57 eglManager.destroy();
58 }