1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package android.telecom.cts; 18 19 import android.telecom.VideoProfile; 20 import android.test.AndroidTestCase; 21 22 /** 23 * Tests helper methods in the {@link VideoProfile} class. 24 */ 25 public class VideoProfileTest extends AndroidTestCase { 26 public void testIsAudioOnly() { 27 assertTrue(VideoProfile.isAudioOnly(VideoProfile.STATE_AUDIO_ONLY)); 28 assertTrue(VideoProfile.isAudioOnly(VideoProfile.STATE_PAUSED)); 29 30 assertFalse(VideoProfile.isAudioOnly(VideoProfile.STATE_BIDIRECTIONAL)); 31 assertFalse(VideoProfile.isAudioOnly(VideoProfile.STATE_TX_ENABLED)); 32 assertFalse(VideoProfile.isAudioOnly(VideoProfile.STATE_RX_ENABLED)); 33 assertFalse(VideoProfile 34 .isAudioOnly(VideoProfile.STATE_BIDIRECTIONAL | VideoProfile.STATE_PAUSED)); 35 assertFalse(VideoProfile 36 .isAudioOnly(VideoProfile.STATE_TX_ENABLED | VideoProfile.STATE_PAUSED)); 37 assertFalse(VideoProfile 38 .isAudioOnly(VideoProfile.STATE_RX_ENABLED | VideoProfile.STATE_PAUSED)); 39 } 40 41 public void testIsVideo() { 42 assertTrue(VideoProfile.isVideo(VideoProfile.STATE_BIDIRECTIONAL)); 43 assertTrue(VideoProfile.isVideo(VideoProfile.STATE_RX_ENABLED)); 44 assertTrue(VideoProfile.isVideo(VideoProfile.STATE_TX_ENABLED)); 45 assertTrue(VideoProfile.isVideo(VideoProfile.STATE_BIDIRECTIONAL | 46 VideoProfile.STATE_PAUSED)); 47 assertTrue(VideoProfile.isVideo(VideoProfile.STATE_RX_ENABLED | VideoProfile.STATE_PAUSED)); 48 assertTrue(VideoProfile.isVideo(VideoProfile.STATE_TX_ENABLED | VideoProfile.STATE_PAUSED)); 49 50 assertFalse(VideoProfile.isVideo(VideoProfile.STATE_AUDIO_ONLY)); 51 assertFalse(VideoProfile.isVideo(VideoProfile.STATE_PAUSED)); 52 } 53 54 public void testIsBidirectional() { 55 assertTrue(VideoProfile.isBidirectional(VideoProfile.STATE_BIDIRECTIONAL)); 56 assertTrue(VideoProfile.isBidirectional(VideoProfile.STATE_BIDIRECTIONAL | 57 VideoProfile.STATE_PAUSED)); 58 59 assertFalse(VideoProfile.isBidirectional(VideoProfile.STATE_TX_ENABLED)); 60 assertFalse(VideoProfile.isBidirectional(VideoProfile.STATE_TX_ENABLED | 61 VideoProfile.STATE_PAUSED)); 62 assertFalse(VideoProfile.isBidirectional(VideoProfile.STATE_RX_ENABLED)); 63 assertFalse(VideoProfile.isBidirectional(VideoProfile.STATE_RX_ENABLED | 64 VideoProfile.STATE_PAUSED)); 65 } 66 67 public void testIsPaused() { 68 assertTrue(VideoProfile.isPaused(VideoProfile.STATE_PAUSED)); 69 assertTrue(VideoProfile.isPaused(VideoProfile.STATE_BIDIRECTIONAL | 70 VideoProfile.STATE_PAUSED)); 71 assertTrue(VideoProfile.isPaused(VideoProfile.STATE_TX_ENABLED | 72 VideoProfile.STATE_PAUSED)); 73 assertTrue(VideoProfile.isPaused(VideoProfile.STATE_RX_ENABLED | 74 VideoProfile.STATE_PAUSED)); 75 76 assertFalse(VideoProfile.isPaused(VideoProfile.STATE_AUDIO_ONLY)); 77 assertFalse(VideoProfile.isPaused(VideoProfile.STATE_TX_ENABLED)); 78 assertFalse(VideoProfile.isPaused(VideoProfile.STATE_RX_ENABLED)); 79 assertFalse(VideoProfile.isPaused(VideoProfile.STATE_BIDIRECTIONAL)); 80 } 81 82 public void testIsReceptionEnabled() { 83 assertTrue(VideoProfile.isReceptionEnabled(VideoProfile.STATE_RX_ENABLED)); 84 assertTrue(VideoProfile.isReceptionEnabled(VideoProfile.STATE_BIDIRECTIONAL)); 85 assertTrue(VideoProfile.isReceptionEnabled(VideoProfile.STATE_RX_ENABLED | 86 VideoProfile.STATE_PAUSED)); 87 assertTrue(VideoProfile.isReceptionEnabled(VideoProfile.STATE_BIDIRECTIONAL | 88 VideoProfile.STATE_PAUSED)); 89 90 assertFalse(VideoProfile.isReceptionEnabled(VideoProfile.STATE_AUDIO_ONLY)); 91 assertFalse(VideoProfile.isReceptionEnabled(VideoProfile.STATE_TX_ENABLED)); 92 assertFalse(VideoProfile.isReceptionEnabled(VideoProfile.STATE_PAUSED)); 93 } 94 95 public void testIsTransmissionEnabled() { 96 assertTrue(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_TX_ENABLED)); 97 assertTrue(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_BIDIRECTIONAL)); 98 assertTrue(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_TX_ENABLED | 99 VideoProfile.STATE_PAUSED)); 100 assertTrue(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_BIDIRECTIONAL | 101 VideoProfile.STATE_PAUSED)); 102 103 assertFalse(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_AUDIO_ONLY)); 104 assertFalse(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_RX_ENABLED)); 105 assertFalse(VideoProfile.isTransmissionEnabled(VideoProfile.STATE_PAUSED)); 106 } 107 108 public void testCameraCapability() { 109 VideoProfile.CameraCapabilities cp = new VideoProfile.CameraCapabilities( 110 1, 1, true, 0.5f); 111 assertEquals(1, cp.getWidth()); 112 assertEquals(1, cp.getHeight()); 113 assertTrue(cp.isZoomSupported()); 114 assertEquals(0.5f, cp.getMaxZoom()); 115 } 116 } 117