summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java
blob: af0881ad6ee5f8602f53e794856cf0029c48819a (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
package com.smartdevicelink.test.rpc.enums;

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

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.AppHMIType}
 */
public class AppHmiTypeTests extends TestCase {

	/**
	 * Verifies that the enum values are not null upon valid assignment.
	 */
	public void testValidEnums () {	
		String example = "DEFAULT";
		AppHMIType enumDefault = AppHMIType.valueForString(example);
		example = "COMMUNICATION";
		AppHMIType enumCommunication = AppHMIType.valueForString(example);
		example = "MEDIA";
		AppHMIType enumMedia = AppHMIType.valueForString(example);
		example = "MESSAGING";
		AppHMIType enumMessaging = AppHMIType.valueForString(example);
		example = "NAVIGATION";
		AppHMIType enumNavigation = AppHMIType.valueForString(example);
		example = "INFORMATION";
		AppHMIType enumInformation = AppHMIType.valueForString(example);
		example = "SOCIAL";
		AppHMIType enumSocial = AppHMIType.valueForString(example);
		example = "BACKGROUND_PROCESS";
		AppHMIType enumBackgroundProcess = AppHMIType.valueForString(example);
		example = "PROJECTION";
		AppHMIType enumProjection = AppHMIType.valueForString(example);
		example = "TESTING";
		AppHMIType enumTesting = AppHMIType.valueForString(example);
		example = "SYSTEM";
		AppHMIType enumSystem = AppHMIType.valueForString(example);
		example = "REMOTE_CONTROL";
		AppHMIType enumRemoteControl = AppHMIType.valueForString(example);
		example = "WEB_VIEW";
		AppHMIType enumWebView = AppHMIType.valueForString(example);
		
		assertNotNull("DEFAULT returned null", enumDefault);
		assertNotNull("COMMUNICATION returned null", enumCommunication);
		assertNotNull("MEDIA returned null", enumMedia);
		assertNotNull("MESSAGING returned null", enumMessaging);
		assertNotNull("NAVIGATION returned null", enumNavigation);
		assertNotNull("INFORMATION returned null", enumInformation);
		assertNotNull("SOCIAL returned null", enumSocial);
		assertNotNull("BACKGROUND_PROCESS returned null", enumBackgroundProcess);
		assertNotNull("PROJECTION returned null", enumProjection);
		assertNotNull("TESTING returned null", enumTesting);
		assertNotNull("SYSTEM returned null", enumSystem);
		assertNotNull("REMOTE_CONTROL returned null", enumRemoteControl);
		assertNotNull("WEB_VIEW returned null", enumWebView);
	}
	
	/**
	 * Verifies that an invalid assignment is null.
	 */
	public void testInvalidEnum () {
		String example = "deFaUlt";
		try {
		    AppHMIType temp = AppHMIType.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 {
		    AppHMIType temp = AppHMIType.valueForString(example);
            assertNull("Result of valueForString should be null.", temp);
		}
		catch (NullPointerException exception) {
            fail("Null string throws NullPointerException.");
		}
	}	
	
	/**
	 * Verifies the possible enum values of AmbientLightStatus.
	 */
	public void testListEnum() {
 		List<AppHMIType> enumValueList = Arrays.asList(AppHMIType.values());
 		
		List<AppHMIType> enumTestList = new ArrayList<AppHMIType>();
		enumTestList.add(AppHMIType.DEFAULT);
		enumTestList.add(AppHMIType.COMMUNICATION);
		enumTestList.add(AppHMIType.MEDIA);
		enumTestList.add(AppHMIType.MESSAGING);
		enumTestList.add(AppHMIType.NAVIGATION);
		enumTestList.add(AppHMIType.INFORMATION);		
		enumTestList.add(AppHMIType.SOCIAL);
		enumTestList.add(AppHMIType.BACKGROUND_PROCESS);
		enumTestList.add(AppHMIType.PROJECTION);
		enumTestList.add(AppHMIType.TESTING);
		enumTestList.add(AppHMIType.SYSTEM);
		enumTestList.add(AppHMIType.REMOTE_CONTROL);
		enumTestList.add(AppHMIType.WEB_VIEW);

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