webrtc/sdk/objc/unittests/RTCEncodedImage_xctest.mm
Kári Tristan Helgason ecbdbf6ee8 Reland "Update RTCEncodedImage to not use deprecated mutable_data call."
This reverts commit 966bcc4bd5.

Reason for revert: Fixing upstream issues.

Original change's description:
> Revert "Update RTCEncodedImage to not use deprecated mutable_data call."
> 
> This reverts commit 677e62785d.
> 
> Reason for revert:
> The RTC_DCHECK_EQ(self.buffer.bytes, self.encodedData->data()) line is triggering for every call
> 
> Original change's description:
> > Update RTCEncodedImage to not use deprecated mutable_data call.
> > 
> > Bug: webrtc:9378
> > Change-Id: If1e6284e2d11009097c87d15b98a2768a1d71521
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168524
> > Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#30518}
> 
> TBR=nisse@webrtc.org,kthelgason@webrtc.org
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Bug: webrtc:9378
> Change-Id: I91b6df1148224785c209a7306ec186a952f5e289
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168620
> Reviewed-by: Zeke Chin <tkchin@webrtc.org>
> Commit-Queue: Zeke Chin <tkchin@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30527}

TBR=nisse@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:9378
Change-Id: I1c0e61d8a390a5999f8dbbbda6f094d71f9b0678
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168740
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30588}
2020-02-24 09:46:35 +00:00

54 lines
1.9 KiB
Text

/*
* Copyright 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import "api/peerconnection/RTCEncodedImage+Private.h"
#import <XCTest/XCTest.h>
@interface RTCEncodedImageTests : XCTestCase
@end
@implementation RTCEncodedImageTests
- (void)testInitializedWithNativeEncodedImage {
const auto encoded_data = webrtc::EncodedImageBuffer::Create();
webrtc::EncodedImage encoded_image;
encoded_image.SetEncodedData(encoded_data);
RTCEncodedImage *encodedImage =
[[RTCEncodedImage alloc] initWithNativeEncodedImage:encoded_image];
XCTAssertEqual([encodedImage nativeEncodedImage].GetEncodedData(), encoded_data);
}
- (void)testInitWithNSData {
NSData *bufferData = [NSData data];
RTCEncodedImage *encodedImage = [[RTCEncodedImage alloc] init];
encodedImage.buffer = bufferData;
webrtc::EncodedImage result_encoded_image = [encodedImage nativeEncodedImage];
XCTAssertTrue(result_encoded_image.GetEncodedData() != nullptr);
XCTAssertEqual(result_encoded_image.GetEncodedData()->data(), bufferData.bytes);
}
- (void)testRetainsNativeEncodedImage {
RTCEncodedImage *encodedImage;
{
const auto encoded_data = webrtc::EncodedImageBuffer::Create();
webrtc::EncodedImage encoded_image;
encoded_image.SetEncodedData(encoded_data);
encodedImage = [[RTCEncodedImage alloc] initWithNativeEncodedImage:encoded_image];
}
webrtc::EncodedImage result_encoded_image = [encodedImage nativeEncodedImage];
XCTAssertTrue(result_encoded_image.GetEncodedData() != nullptr);
XCTAssertTrue(result_encoded_image.GetEncodedData()->data() != nullptr);
}
@end