blob: d5fa65b17380a35eefa3db2130ead406b38ce6b7 [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;
46 RTCCVPixelBuffer *badFrameBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:nullPixelBuffer];
47 RTCVideoFrame *badFrame = [[RTCVideoFrame alloc] initWithBuffer:badFrameBuffer
48 rotation:RTCVideoRotation_0
49 timeStampNs:0];
50 [_nv12TextureCache uploadFrameToTextures:badFrame];
51}
52
53@end