Skip to content

Commit 5349b84

Browse files
authored
Merge pull request #1294 from smartdevicelink/feature/add_missing_enums
Add missing enums
2 parents 9b43ce1 + 191a781 commit 5349b84

29 files changed

Lines changed: 923 additions & 52 deletions

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public void testFunctionIdsAgainstFileNames(){
2525
FunctionID[] functionIDs = FunctionID.values();
2626
for(FunctionID functionID : functionIDs) {
2727
switch (functionID){
28+
case RESERVED:
2829
case SYNC_P_DATA:
2930
case ON_SYNC_P_DATA:
3031
case ENCODED_SYNC_P_DATA:
@@ -54,6 +55,7 @@ private Class getClassForFunctionId(FunctionID functionID, boolean isResponse) {
5455
rpcClassName.append(RPC_PACKAGE);
5556

5657
switch (functionID) {
58+
case RESERVED:
5759
case SYNC_P_DATA:
5860
case ON_SYNC_P_DATA:
5961
case ENCODED_SYNC_P_DATA:
@@ -91,6 +93,7 @@ public void testRpcCreation(){
9193

9294
for(FunctionID functionID : functionIDs){
9395
switch (functionID){
96+
case RESERVED:
9497
case SYNC_P_DATA:
9598
case ON_SYNC_P_DATA:
9699
case ENCODED_SYNC_P_DATA:

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public void testValidEnums () {
4242
AppInterfaceUnregisteredReason enumAppAuthorized = AppInterfaceUnregisteredReason.valueForString(example);
4343
example = "PROTOCOL_VIOLATION";
4444
AppInterfaceUnregisteredReason enumProtocolViolation = AppInterfaceUnregisteredReason.valueForString(example);
45+
example = "UNSUPPORTED_HMI_RESOURCE";
46+
AppInterfaceUnregisteredReason enumUnsupportedHMIResource = AppInterfaceUnregisteredReason.valueForString(example);
4547

4648
assertNotNull("USER_EXIT returned null", enumUserExit);
4749
assertNotNull("IGNITION_OFF returned null", enumIgnitionOff);
@@ -55,6 +57,7 @@ public void testValidEnums () {
5557
assertNotNull("FACTORY_DEFAULTS returned null", enumFactoryDefaults);
5658
assertNotNull("APP_UNAUTHORIZED returned null", enumAppAuthorized);
5759
assertNotNull("PROTOCOL_VIOLATION returned null", enumProtocolViolation);
60+
assertNotNull("UNSUPPORTED_HMI_RESOURCE returned null", enumUnsupportedHMIResource);
5861
}
5962

6063
/**
@@ -104,6 +107,7 @@ public void testListEnum() {
104107
enumTestList.add(AppInterfaceUnregisteredReason.FACTORY_DEFAULTS);
105108
enumTestList.add(AppInterfaceUnregisteredReason.APP_UNAUTHORIZED);
106109
enumTestList.add(AppInterfaceUnregisteredReason.PROTOCOL_VIOLATION);
110+
enumTestList.add(AppInterfaceUnregisteredReason.UNSUPPORTED_HMI_RESOURCE);
107111

108112
assertTrue("Enum value list does not match enum class list",
109113
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* Copyright (c) 2020 Livio, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of the Livio Inc. nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
package com.smartdevicelink.test.rpc.enums;
34+
35+
import com.smartdevicelink.proxy.rpc.enums.MaintenanceModeStatus;
36+
37+
import junit.framework.TestCase;
38+
39+
import java.util.ArrayList;
40+
import java.util.Arrays;
41+
import java.util.List;
42+
43+
/**
44+
* This is a unit test class for the SmartDeviceLink library project class :
45+
* {@link com.smartdevicelink.proxy.rpc.enums.MaintenanceModeStatus}
46+
*/
47+
public class MaintenanceModeStatusTests extends TestCase {
48+
49+
/**
50+
* Verifies that the enum values are not null upon valid assignment.
51+
*/
52+
public void testValidEnums () {
53+
String example = "NORMAL";
54+
MaintenanceModeStatus enumNormal = MaintenanceModeStatus.valueForString(example);
55+
example = "NEAR";
56+
MaintenanceModeStatus enumNear = MaintenanceModeStatus.valueForString(example);
57+
example = "ACTIVE";
58+
MaintenanceModeStatus enumActive = MaintenanceModeStatus.valueForString(example);
59+
example = "FEATURE_NOT_PRESENT";
60+
MaintenanceModeStatus enumFeatureNotPResent = MaintenanceModeStatus.valueForString(example);
61+
62+
assertNotNull("NORMAL returned null", enumNormal);
63+
assertNotNull("NEAR returned null", enumNear);
64+
assertNotNull("ACTIVE returned null", enumActive);
65+
assertNotNull("FEATURE_NOT_PRESENT returned null", enumFeatureNotPResent);
66+
}
67+
68+
/**
69+
* Verifies that an invalid assignment is null.
70+
*/
71+
public void testInvalidEnum () {
72+
String example = "normAL";
73+
try {
74+
MaintenanceModeStatus temp = MaintenanceModeStatus.valueForString(example);
75+
assertNull("Result of valueForString should be null.", temp);
76+
}
77+
catch (IllegalArgumentException exception) {
78+
fail("Invalid enum throws IllegalArgumentException.");
79+
}
80+
}
81+
82+
/**
83+
* Verifies that a null assignment is invalid.
84+
*/
85+
public void testNullEnum () {
86+
String example = null;
87+
try {
88+
MaintenanceModeStatus temp = MaintenanceModeStatus.valueForString(example);
89+
assertNull("Result of valueForString should be null.", temp);
90+
}
91+
catch (NullPointerException exception) {
92+
fail("Null string throws NullPointerException.");
93+
}
94+
}
95+
96+
/**
97+
* Verifies the possible enum values of MaintenanceModeStatus.
98+
*/
99+
public void testListEnum() {
100+
List<MaintenanceModeStatus> enumValueList = Arrays.asList(MaintenanceModeStatus.values());
101+
102+
List<MaintenanceModeStatus> enumTestList = new ArrayList<>();
103+
enumTestList.add(MaintenanceModeStatus.NORMAL);
104+
enumTestList.add(MaintenanceModeStatus.NEAR);
105+
enumTestList.add(MaintenanceModeStatus.ACTIVE);
106+
enumTestList.add(MaintenanceModeStatus.FEATURE_NOT_PRESENT);
107+
108+
assertTrue("Enum value list does not match enum class list",
109+
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
110+
}
111+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2020 Livio, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of the Livio Inc. nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
package com.smartdevicelink.test.rpc.enums;
34+
35+
import com.smartdevicelink.proxy.rpc.enums.MessageType;
36+
37+
import junit.framework.TestCase;
38+
39+
import java.util.ArrayList;
40+
import java.util.Arrays;
41+
import java.util.List;
42+
43+
/**
44+
* This is a unit test class for the SmartDeviceLink library project class :
45+
* {@link com.smartdevicelink.proxy.rpc.enums.MessageType}
46+
*/
47+
public class MessageTypeTests extends TestCase {
48+
49+
/**
50+
* Verifies that the enum values are not null upon valid assignment.
51+
*/
52+
public void testValidEnums() {
53+
int example = 0;
54+
MessageType enumRequest = MessageType.valueForInt(example);
55+
example = 1;
56+
MessageType enumResponse = MessageType.valueForInt(example);
57+
example = 2;
58+
MessageType enumNotification = MessageType.valueForInt(example);
59+
60+
assertNotNull("REQUEST returned null", enumRequest);
61+
assertNotNull("RESPONSE returned null", enumResponse);
62+
assertNotNull("NOTIFICATION returned null", enumNotification);
63+
64+
}
65+
66+
/**
67+
* Verifies that an invalid assignment is null.
68+
*/
69+
public void testInvalidEnum() {
70+
int example = 3;
71+
try {
72+
MessageType temp = MessageType.valueForInt(example);
73+
assertNull("Result of valueForString should be null.", temp);
74+
} catch (IllegalArgumentException exception) {
75+
fail("Invalid enum throws IllegalArgumentException.");
76+
}
77+
}
78+
79+
80+
/**
81+
* Verifies the possible enum values of MessageType.
82+
*/
83+
public void testListEnum() {
84+
List<MessageType> enumValueList = Arrays.asList(MessageType.values());
85+
86+
List<MessageType> enumTestList = new ArrayList<>();
87+
enumTestList.add(MessageType.REQUEST);
88+
enumTestList.add(MessageType.RESPONSE);
89+
enumTestList.add(MessageType.NOTIFICATION);
90+
91+
assertTrue("Enum value list does not match enum class list",
92+
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
93+
}
94+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* Copyright (c) 2020 Livio, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of the Livio Inc. nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
package com.smartdevicelink.test.rpc.enums;
34+
35+
import com.smartdevicelink.proxy.rpc.enums.PermissionStatus;
36+
37+
import junit.framework.TestCase;
38+
39+
import java.util.ArrayList;
40+
import java.util.Arrays;
41+
import java.util.List;
42+
43+
/**
44+
* This is a unit test class for the SmartDeviceLink library project class :
45+
* {@link com.smartdevicelink.proxy.rpc.enums.PermissionStatus}
46+
*/
47+
public class PermissionStatusTests extends TestCase {
48+
49+
/**
50+
* Verifies that the enum values are not null upon valid assignment.
51+
*/
52+
public void testValidEnums () {
53+
String example = "ALLOWED";
54+
PermissionStatus enumAllowed = PermissionStatus.valueForString(example);
55+
example = "DISALLOWED";
56+
PermissionStatus enumDisallowed = PermissionStatus.valueForString(example);
57+
example = "USER_DISALLOWED";
58+
PermissionStatus enumUserDisallowed = PermissionStatus.valueForString(example);
59+
example = "USER_CONSENT_PENDING";
60+
PermissionStatus enumUserConsentPending = PermissionStatus.valueForString(example);
61+
62+
assertNotNull("ALLOWED returned null", enumAllowed);
63+
assertNotNull("DISALLOWED returned null", enumDisallowed);
64+
assertNotNull("USER_DISALLOWED returned null", enumUserDisallowed);
65+
assertNotNull("USER_CONSENT_PENDING returned null", enumUserConsentPending);
66+
}
67+
68+
/**
69+
* Verifies that an invalid assignment is null.
70+
*/
71+
public void testInvalidEnum () {
72+
String example = "DISALLOwed";
73+
try {
74+
PermissionStatus temp = PermissionStatus.valueForString(example);
75+
assertNull("Result of valueForString should be null.", temp);
76+
}
77+
catch (IllegalArgumentException exception) {
78+
fail("Invalid enum throws IllegalArgumentException.");
79+
}
80+
}
81+
82+
/**
83+
* Verifies that a null assignment is invalid.
84+
*/
85+
public void testNullEnum () {
86+
String example = null;
87+
try {
88+
PermissionStatus temp = PermissionStatus.valueForString(example);
89+
assertNull("Result of valueForString should be null.", temp);
90+
}
91+
catch (NullPointerException exception) {
92+
fail("Null string throws NullPointerException.");
93+
}
94+
}
95+
96+
/**
97+
* Verifies the possible enum values of PermissionStatus.
98+
*/
99+
public void testListEnum() {
100+
List<PermissionStatus> enumValueList = Arrays.asList(PermissionStatus.values());
101+
102+
List<PermissionStatus> enumTestList = new ArrayList<>();
103+
enumTestList.add(PermissionStatus.ALLOWED);
104+
enumTestList.add(PermissionStatus.DISALLOWED);
105+
enumTestList.add(PermissionStatus.USER_DISALLOWED);
106+
enumTestList.add(PermissionStatus.USER_CONSENT_PENDING);
107+
108+
assertTrue("Enum value list does not match enum class list",
109+
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
110+
}
111+
}

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public void testValidEnums () {
2828
Result enumOutOfMemory = Result.valueForString(example);
2929
example = "TOO_MANY_PENDING_REQUESTS";
3030
Result enumTooManyPendingRequests = Result.valueForString(example);
31+
example = "CHAR_LIMIT_EXCEEDED";
32+
Result enumCharLimitExceeded = Result.valueForString(example);
3133
example = "INVALID_ID";
3234
Result enumInvalidId = Result.valueForString(example);
3335
example = "DUPLICATE_NAME";
@@ -96,6 +98,7 @@ public void testValidEnums () {
9698
assertNotNull("UNSUPPORTED_REQUEST returned null", enumUnsupportedRequest);
9799
assertNotNull("OUT_OF_MEMORY returned null", enumOutOfMemory);
98100
assertNotNull("TOO_MANY_PENDING_REQUESTS returned null", enumTooManyPendingRequests);
101+
assertNotNull("CHAR_LIMIT_EXCEEDED returned null", enumCharLimitExceeded);
99102
assertNotNull("INVALID_ID returned null", enumInvalidId);
100103
assertNotNull("DUPLICATE_NAME returned null", enumDuplicateName);
101104
assertNotNull("TOO_MANY_APPLICATIONS returned null", enumTooManyApplications);
@@ -169,6 +172,7 @@ public void testListEnum() {
169172
enumTestList.add(Result.UNSUPPORTED_REQUEST);
170173
enumTestList.add(Result.OUT_OF_MEMORY);
171174
enumTestList.add(Result.TOO_MANY_PENDING_REQUESTS);
175+
enumTestList.add(Result.CHAR_LIMIT_EXCEEDED);
172176
enumTestList.add(Result.INVALID_ID);
173177
enumTestList.add(Result.DUPLICATE_NAME);
174178
enumTestList.add(Result.TOO_MANY_APPLICATIONS);

0 commit comments

Comments
 (0)