Anders Carlsson | 79ce820 | 2018-06-01 10:51:09 | [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 | |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 11 | #import "components/video_codec/RTCH264ProfileLevelId.h" |
Anders Carlsson | 79ce820 | 2018-06-01 10:51:09 | [diff] [blame] | 12 | |
| 13 | #import <XCTest/XCTest.h> |
| 14 | |
| 15 | @interface RTCH264ProfileLevelIdTests : XCTestCase |
| 16 | |
| 17 | @end |
| 18 | |
| 19 | static NSString *level31ConstrainedHigh = @"640c1f"; |
| 20 | static NSString *level31ConstrainedBaseline = @"42e01f"; |
| 21 | |
| 22 | @implementation RTCH264ProfileLevelIdTests |
| 23 | |
| 24 | - (void)testInitWithString { |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 25 | RTC_OBJC_TYPE(RTCH264ProfileLevelId) *profileLevelId = |
| 26 | [[RTC_OBJC_TYPE(RTCH264ProfileLevelId) alloc] initWithHexString:level31ConstrainedHigh]; |
Anders Carlsson | 79ce820 | 2018-06-01 10:51:09 | [diff] [blame] | 27 | XCTAssertEqual(profileLevelId.profile, RTCH264ProfileConstrainedHigh); |
| 28 | XCTAssertEqual(profileLevelId.level, RTCH264Level3_1); |
| 29 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 30 | profileLevelId = |
| 31 | [[RTC_OBJC_TYPE(RTCH264ProfileLevelId) alloc] initWithHexString:level31ConstrainedBaseline]; |
Anders Carlsson | 79ce820 | 2018-06-01 10:51:09 | [diff] [blame] | 32 | XCTAssertEqual(profileLevelId.profile, RTCH264ProfileConstrainedBaseline); |
| 33 | XCTAssertEqual(profileLevelId.level, RTCH264Level3_1); |
| 34 | } |
| 35 | |
| 36 | - (void)testInitWithProfileAndLevel { |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 37 | RTC_OBJC_TYPE(RTCH264ProfileLevelId) *profileLevelId = |
| 38 | [[RTC_OBJC_TYPE(RTCH264ProfileLevelId) alloc] initWithProfile:RTCH264ProfileConstrainedHigh |
| 39 | level:RTCH264Level3_1]; |
Anders Carlsson | 79ce820 | 2018-06-01 10:51:09 | [diff] [blame] | 40 | XCTAssertEqualObjects(profileLevelId.hexString, level31ConstrainedHigh); |
| 41 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 42 | profileLevelId = [[RTC_OBJC_TYPE(RTCH264ProfileLevelId) alloc] |
| 43 | initWithProfile:RTCH264ProfileConstrainedBaseline |
| 44 | level:RTCH264Level3_1]; |
Anders Carlsson | 79ce820 | 2018-06-01 10:51:09 | [diff] [blame] | 45 | XCTAssertEqualObjects(profileLevelId.hexString, level31ConstrainedBaseline); |
| 46 | } |
| 47 | |
| 48 | @end |