Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: webrtc/sdk/objc/Framework/UnitTests/objc_video_decoder_factory_tests.mm

Issue 3007433002: Let CreateVideoDecoder take a cricket::VideoCodec. (Closed)
Patch Set: Remove unrelated change Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import <Foundation/Foundation.h> 11 #import <Foundation/Foundation.h>
12 #import <OCMock/OCMock.h> 12 #import <OCMock/OCMock.h>
13 13
14 #include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/objc_video_decoder_fact ory.h" 14 #include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/objc_video_decoder_fact ory.h"
15 15
16 #import "WebRTC/RTCVideoCodec.h" 16 #import "WebRTC/RTCVideoCodec.h"
17 #import "WebRTC/RTCVideoCodecFactory.h" 17 #import "WebRTC/RTCVideoCodecFactory.h"
18 #include "webrtc/media/base/codec.h"
18 #include "webrtc/modules/include/module_common_types.h" 19 #include "webrtc/modules/include/module_common_types.h"
19 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 20 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
20 #include "webrtc/modules/video_coding/include/video_error_codes.h" 21 #include "webrtc/modules/video_coding/include/video_error_codes.h"
21 #include "webrtc/rtc_base/gunit.h" 22 #include "webrtc/rtc_base/gunit.h"
22 23
23 id<RTCVideoDecoderFactory> CreateDecoderFactoryReturning(int return_code) { 24 id<RTCVideoDecoderFactory> CreateDecoderFactoryReturning(int return_code) {
24 id decoderMock = OCMProtocolMock(@protocol(RTCVideoDecoder)); 25 id decoderMock = OCMProtocolMock(@protocol(RTCVideoDecoder));
25 OCMStub([decoderMock startDecodeWithSettings:[OCMArg any] numberOfCores:1]) 26 OCMStub([decoderMock startDecodeWithSettings:[OCMArg any] numberOfCores:1])
26 .andReturn(return_code); 27 .andReturn(return_code);
27 OCMStub([decoderMock decode:[OCMArg any] 28 OCMStub([decoderMock decode:[OCMArg any]
(...skipping 14 matching lines...) Expand all
42 id<RTCVideoDecoderFactory> CreateOKDecoderFactory() { 43 id<RTCVideoDecoderFactory> CreateOKDecoderFactory() {
43 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_OK); 44 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_OK);
44 } 45 }
45 46
46 id<RTCVideoDecoderFactory> CreateErrorDecoderFactory() { 47 id<RTCVideoDecoderFactory> CreateErrorDecoderFactory() {
47 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_ERROR); 48 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_ERROR);
48 } 49 }
49 50
50 webrtc::VideoDecoder *GetObjCDecoder(id<RTCVideoDecoderFactory> factory) { 51 webrtc::VideoDecoder *GetObjCDecoder(id<RTCVideoDecoderFactory> factory) {
51 webrtc::ObjCVideoDecoderFactory decoder_factory(factory); 52 webrtc::ObjCVideoDecoderFactory decoder_factory(factory);
52 return decoder_factory.CreateVideoDecoder(webrtc::kVideoCodecH264); 53 return decoder_factory.CreateVideoDecoder(cricket::VideoCodec(cricket::kH264Co decName));
53 } 54 }
54 55
55 #pragma mark - 56 #pragma mark -
56 57
57 TEST(ObjCVideoDecoderFactoryTest, InitDecodeReturnsOKOnSuccess) { 58 TEST(ObjCVideoDecoderFactoryTest, InitDecodeReturnsOKOnSuccess) {
58 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory()); 59 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory());
59 60
60 auto settings = new webrtc::VideoCodec(); 61 auto settings = new webrtc::VideoCodec();
61 EXPECT_EQ(decoder->InitDecode(settings, 1), WEBRTC_VIDEO_CODEC_OK); 62 EXPECT_EQ(decoder->InitDecode(settings, 1), WEBRTC_VIDEO_CODEC_OK);
62 } 63 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory()); 95 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory());
95 96
96 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_OK); 97 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_OK);
97 } 98 }
98 99
99 TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsErrorOnFail) { 100 TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsErrorOnFail) {
100 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory()); 101 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory());
101 102
102 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_ERROR); 103 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_ERROR);
103 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698