blob: 7f2e1589ae6c7ed74647a33d3a284b9b78f1c172 [file] [log] [blame]
John Reck064650b2021-01-19 21:29:24 -05001/*
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"
Nader Jawad086645d2021-09-24 13:42:47 -070020#include "renderthread/RenderEffectCapabilityQuery.h"
John Reck064650b2021-01-19 21:29:24 -050021#include "tests/common/TestContext.h"
22
23using namespace android;
24using namespace android::uirenderer;
25using namespace android::uirenderer::renderthread;
26using namespace android::uirenderer::test;
27
28TEST(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();
Nader Jawad086645d2021-09-24 13:42:47 -070045}
46
47TEST(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();
John Reck064650b2021-01-19 21:29:24 -050058}