forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a unit test for FlutterFrameBufferProvider (flutter#27591)
- Loading branch information
George Wright
authored
Jul 21, 2021
1 parent
a3de969
commit e2c75a2
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |