Aaron Golden | fb4e9bc | 2019-01-04 12:03:31 -0800 | [diff] [blame] | 1 | /* |
| 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 Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 46 | 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 Golden | fb4e9bc | 2019-01-04 12:03:31 -0800 | [diff] [blame] | 52 | [_nv12TextureCache uploadFrameToTextures:badFrame]; |
| 53 | } |
| 54 | |
| 55 | @end |