webrtc_m130/sdk/android/tests/src/org/webrtc/CryptoOptionsTest.java
Xavier Lepaul a6fcbb1830 Use a standard Androidx test runner instead of the org.chromium one
Bug: webrtc:13662
Change-Id: I7ae28a61ea8f7e578d8aef8e3104f8564f3dd7b6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256621
Auto-Submit: Xavier Lepaul‎ <xalep@webrtc.org>
Reviewed-by: Linus Nilsson <lnilsson@webrtc.org>
Commit-Queue: Xavier Lepaul‎ <xalep@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36318}
2022-03-24 10:49:44 +00:00

75 lines
3.5 KiB
Java

/*
* Copyright 2018 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.
*/
package org.webrtc;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.webrtc.CryptoOptions;
@RunWith(AndroidJUnit4.class)
@Config(manifest = Config.NONE)
public class CryptoOptionsTest {
// Validates the builder builds by default all false options.
@Test
public void testBuilderDefaultsAreFalse() {
CryptoOptions cryptoOptions = CryptoOptions.builder().createCryptoOptions();
assertThat(cryptoOptions.getSrtp().getEnableGcmCryptoSuites()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableAes128Sha1_32CryptoCipher()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableEncryptedRtpHeaderExtensions()).isFalse();
assertThat(cryptoOptions.getSFrame().getRequireFrameEncryption()).isFalse();
}
// Validates the builder sets the correct parameters.
@Test
public void testBuilderCorrectlyInitializingGcmCrypto() {
CryptoOptions cryptoOptions =
CryptoOptions.builder().setEnableGcmCryptoSuites(true).createCryptoOptions();
assertThat(cryptoOptions.getSrtp().getEnableGcmCryptoSuites()).isTrue();
assertThat(cryptoOptions.getSrtp().getEnableAes128Sha1_32CryptoCipher()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableEncryptedRtpHeaderExtensions()).isFalse();
assertThat(cryptoOptions.getSFrame().getRequireFrameEncryption()).isFalse();
}
@Test
public void testBuilderCorrectlyInitializingAes128Sha1_32CryptoCipher() {
CryptoOptions cryptoOptions =
CryptoOptions.builder().setEnableAes128Sha1_32CryptoCipher(true).createCryptoOptions();
assertThat(cryptoOptions.getSrtp().getEnableGcmCryptoSuites()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableAes128Sha1_32CryptoCipher()).isTrue();
assertThat(cryptoOptions.getSrtp().getEnableEncryptedRtpHeaderExtensions()).isFalse();
assertThat(cryptoOptions.getSFrame().getRequireFrameEncryption()).isFalse();
}
@Test
public void testBuilderCorrectlyInitializingEncryptedRtpHeaderExtensions() {
CryptoOptions cryptoOptions =
CryptoOptions.builder().setEnableEncryptedRtpHeaderExtensions(true).createCryptoOptions();
assertThat(cryptoOptions.getSrtp().getEnableGcmCryptoSuites()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableAes128Sha1_32CryptoCipher()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableEncryptedRtpHeaderExtensions()).isTrue();
assertThat(cryptoOptions.getSFrame().getRequireFrameEncryption()).isFalse();
}
@Test
public void testBuilderCorrectlyInitializingRequireFrameEncryption() {
CryptoOptions cryptoOptions =
CryptoOptions.builder().setRequireFrameEncryption(true).createCryptoOptions();
assertThat(cryptoOptions.getSrtp().getEnableGcmCryptoSuites()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableAes128Sha1_32CryptoCipher()).isFalse();
assertThat(cryptoOptions.getSrtp().getEnableEncryptedRtpHeaderExtensions()).isFalse();
assertThat(cryptoOptions.getSFrame().getRequireFrameEncryption()).isTrue();
}
}