Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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>
#include <iostream>

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