blob: 7bdc538f67590786e4f4d27fecb25eb10e114688 [file] [log] [blame]
Aaron Goldenfb4e9bc2019-01-04 12:03:31 -08001/*
2 * Copyright 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#import <CoreVideo/CoreVideo.h>
12#import <Foundation/Foundation.h>
13#import <GLKit/GLKit.h>
14#import <XCTest/XCTest.h>
15
16#import "base/RTCVideoFrame.h"
17#import "base/RTCVideoFrameBuffer.h"
18#import "components/renderer/opengl/RTCNV12TextureCache.h"
19#import "components/video_frame_buffer/RTCCVPixelBuffer.h"
20
21@interface RTCNV12TextureCacheTests : XCTestCase
22@end
23
24@implementation RTCNV12TextureCacheTests {
25 EAGLContext *_glContext;
26 RTCNV12TextureCache *_nv12TextureCache;
27}
28
29- (void)setUp {
30 [super setUp];
31 _glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
32 if (!_glContext) {
33 _glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
34 }
35 _nv12TextureCache = [[RTCNV12TextureCache alloc] initWithContext:_glContext];
36}
37
38- (void)tearDown {
39 _nv12TextureCache = nil;
40 _glContext = nil;
41 [super tearDown];
42}
43
44- (void)testNV12TextureCacheDoesNotCrashOnEmptyFrame {
45 CVPixelBufferRef nullPixelBuffer = NULL;
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020046 RTC_OBJC_TYPE(RTCCVPixelBuffer) *badFrameBuffer =
47 [[RTC_OBJC_TYPE(RTCCVPixelBuffer) alloc] initWithPixelBuffer:nullPixelBuffer];
48 RTC_OBJC_TYPE(RTCVideoFrame) *badFrame =
49 [[RTC_OBJC_TYPE(RTCVideoFrame) alloc] initWithBuffer:badFrameBuffer
50 rotation:RTCVideoRotation_0
51 timeStampNs:0];
Aaron Goldenfb4e9bc2019-01-04 12:03:31 -080052 [_nv12TextureCache uploadFrameToTextures:badFrame];
53}
54
55@end