summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java
blob: 94617493cc011a235239146e17f729cdacc8e700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.smartdevicelink.test.rpc.enums;

import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;

import junit.framework.TestCase;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This is a unit test class for the SmartDeviceLink library project class : 
 * {@link com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType}
 */
public class SystemCapabilityTypeTests extends TestCase {

	/**
	 * Verifies that the enum values are not null upon valid assignment.
	 */
	public void testValidEnums () {	
		String example = "NAVIGATION";
		SystemCapabilityType enumNavigation = SystemCapabilityType.valueForString(example);
		example = "PHONE_CALL";
		SystemCapabilityType enumPhoneCall = SystemCapabilityType.valueForString(example);
		example = "VIDEO_STREAMING";
		SystemCapabilityType enumVideoStreaming = SystemCapabilityType.valueForString(example);
		example = "REMOTE_CONTROL";
		SystemCapabilityType enumRemoteControl = SystemCapabilityType.valueForString(example);
		example = "HMI";
		SystemCapabilityType enumHmi = SystemCapabilityType.valueForString(example);
		example = "DISPLAY";
		SystemCapabilityType enumDisplay = SystemCapabilityType.valueForString(example);
		example = "AUDIO_PASSTHROUGH";
		SystemCapabilityType enumAudioPassThrough = SystemCapabilityType.valueForString(example);
		example = "BUTTON";
		SystemCapabilityType enumButton = SystemCapabilityType.valueForString(example);
		example = "HMI_ZONE";
		SystemCapabilityType enumHmiZone = SystemCapabilityType.valueForString(example);
		example = "PRESET_BANK";
		SystemCapabilityType enumPresetBank = SystemCapabilityType.valueForString(example);
		example = "SOFTBUTTON";
		SystemCapabilityType enumSoftButton = SystemCapabilityType.valueForString(example);
		example = "SPEECH";
		SystemCapabilityType enumSpeech = SystemCapabilityType.valueForString(example);
		example = "VOICE_RECOGNITION";
		SystemCapabilityType enumVoiceRecognition = SystemCapabilityType.valueForString(example);
		example = "PCM_STREAMING";
		SystemCapabilityType enumPCM = SystemCapabilityType.valueForString(example);
		example = "APP_SERVICES";
		SystemCapabilityType enumAppServices = SystemCapabilityType.valueForString(example);
		example = "SEAT_LOCATION";
		SystemCapabilityType enumSeatLocation = SystemCapabilityType.valueForString(example);
		example = "PRERECORDED_SPEECH";
		SystemCapabilityType enumPrerecordedSpeech = SystemCapabilityType.valueForString(example);
		example = "DISPLAYS";
		SystemCapabilityType enumDisplays = SystemCapabilityType.valueForString(example);
		example = "DRIVER_DISTRACTION";
		SystemCapabilityType enumDriverDistraction = SystemCapabilityType.valueForString(example);

		assertNotNull("NAVIGATION returned null", enumNavigation);
		assertNotNull("PHONE_CALL returned null", enumPhoneCall);
		assertNotNull("VIDEO_STREAMING returned null", enumVideoStreaming);
		assertNotNull("REMOTE_CONTROL returned null", enumRemoteControl);
		assertNotNull("HMI returned null", enumHmi);
		assertNotNull("DISPLAY returned null", enumDisplay);
		assertNotNull("AUDIO_PASSTHROUGH returned null", enumAudioPassThrough);
		assertNotNull("BUTTON returned null", enumButton);
		assertNotNull("HMI_ZONE returned null", enumHmiZone);
		assertNotNull("PRESET_BANK returned null", enumPresetBank);
		assertNotNull("SOFTBUTTON returned null", enumSoftButton);
		assertNotNull("SPEECH returned null", enumSpeech);
		assertNotNull("VOICE_RECOGNITION returned null", enumVoiceRecognition);
		assertNotNull("PCM_STREAMING", enumPCM);
		assertNotNull("APP_SERVICES", enumAppServices);
		assertNotNull("SEAT_LOCATION return null", enumSeatLocation);
		assertNotNull("PRERECORDED_SPEECH", enumPrerecordedSpeech);
		assertNotNull("DISPLAYS", enumDisplays);
		assertNotNull("DRIVER_DISTRACTION", enumDriverDistraction);

	}

	/**
	 * Verifies that an invalid assignment is null.
	 */
	public void testInvalidEnum () {
		String example = "nAVIGATION";
		try {
			SystemCapabilityType temp = SystemCapabilityType.valueForString(example);
            assertNull("Result of valueForString should be null.", temp);
		}
		catch (IllegalArgumentException exception) {
            fail("Invalid enum throws IllegalArgumentException.");
		}
	}

	/**
	 * Verifies that a null assignment is invalid.
	 */
	public void testNullEnum () {
		String example = null;
		try {
			SystemCapabilityType temp = SystemCapabilityType.valueForString(example);
            assertNull("Result of valueForString should be null.", temp);
		}
		catch (NullPointerException exception) {
            fail("Null string throws NullPointerException.");
		}
	}

	/**
	 * Verifies the possible enum values of SystemCapabilityType.
	 */
	public void testListEnum() {
 		List<SystemCapabilityType> enumValueList = Arrays.asList(SystemCapabilityType.values());

		List<SystemCapabilityType> enumTestList = new ArrayList<SystemCapabilityType>();
		enumTestList.add(SystemCapabilityType.NAVIGATION);
		enumTestList.add(SystemCapabilityType.PHONE_CALL);
		enumTestList.add(SystemCapabilityType.VIDEO_STREAMING);
		enumTestList.add(SystemCapabilityType.REMOTE_CONTROL);
		enumTestList.add(SystemCapabilityType.HMI);
		enumTestList.add(SystemCapabilityType.DISPLAY);
		enumTestList.add(SystemCapabilityType.AUDIO_PASSTHROUGH);
		enumTestList.add(SystemCapabilityType.BUTTON);
		enumTestList.add(SystemCapabilityType.HMI_ZONE);
		enumTestList.add(SystemCapabilityType.PRESET_BANK);
		enumTestList.add(SystemCapabilityType.SOFTBUTTON);
		enumTestList.add(SystemCapabilityType.SPEECH);
		enumTestList.add(SystemCapabilityType.VOICE_RECOGNITION);
		enumTestList.add(SystemCapabilityType.PCM_STREAMING);
		enumTestList.add(SystemCapabilityType.APP_SERVICES);
		enumTestList.add(SystemCapabilityType.SEAT_LOCATION);
		enumTestList.add(SystemCapabilityType.PRERECORDED_SPEECH);
		enumTestList.add(SystemCapabilityType.DISPLAYS);
		enumTestList.add(SystemCapabilityType.DRIVER_DISTRACTION);


		assertTrue("Enum value list does not match enum class list", 
				enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
	}	
}