Add a unit test for FlutterFrameBufferProvider (flutter/engine#27591)
This commit is contained in:
@@ -1194,6 +1194,7 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExter
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm
|
||||
|
||||
@@ -178,6 +178,7 @@ executable("flutter_desktop_darwin_unittests") {
|
||||
"framework/Source/FlutterEngineTest.mm",
|
||||
"framework/Source/FlutterEngineTestUtils.h",
|
||||
"framework/Source/FlutterEngineTestUtils.mm",
|
||||
"framework/Source/FlutterFrameBufferProviderUnittests.mm",
|
||||
"framework/Source/FlutterGLCompositorUnittests.mm",
|
||||
"framework/Source/FlutterKeyboardManagerUnittests.mm",
|
||||
"framework/Source/FlutterMetalCompositorUnittests.mm",
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h"
|
||||
#import "flutter/testing/testing.h"
|
||||
|
||||
#import <OpenGL/gl.h>
|
||||
|
||||
namespace flutter::testing {
|
||||
|
||||
TEST(FlutterFrameBufferProviderTest, TestCreate) {
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFAColorSize, 24, NSOpenGLPFAAlphaSize, 8, 0,
|
||||
};
|
||||
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
||||
|
||||
[context makeCurrentContext];
|
||||
FlutterFrameBufferProvider* framebufferProvider =
|
||||
[[FlutterFrameBufferProvider alloc] initWithOpenGLContext:context];
|
||||
|
||||
GLuint fbo = [framebufferProvider glFrameBufferId];
|
||||
GLuint texture = [framebufferProvider glTextureId];
|
||||
|
||||
// Normally we'd back this using an IOSurface but for this test let's just create a TexImage2D
|
||||
// with no backing data.
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, texture,
|
||||
0);
|
||||
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
|
||||
EXPECT_TRUE(status == GL_FRAMEBUFFER_COMPLETE);
|
||||
}
|
||||
|
||||
} // flutter::testing
|
||||
Reference in New Issue
Block a user