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
142
143
144
145
146
147
148
|
package com.smartdevicelink.test.rpc.enums;
import com.smartdevicelink.proxy.rpc.enums.PredefinedLayout;
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.PredefinedLayout}
*/
public class PredefinedLayoutTests extends TestCase {
/**
* Verifies that the enum values are not null upon valid assignment.
*/
public void testValidEnums () {
String example = "DEFAULT";
PredefinedLayout defaultenum = PredefinedLayout.valueForString(example);
example = "MEDIA";
PredefinedLayout media = PredefinedLayout.valueForString(example);
example = "NON-MEDIA";
PredefinedLayout nonmedia = PredefinedLayout.valueForString(example);
example = "ONSCREEN_PRESETS";
PredefinedLayout onscreen_presets = PredefinedLayout.valueForString(example);
example = "NAV_FULLSCREEN_MAP";
PredefinedLayout nav_fullscreen_map = PredefinedLayout.valueForString(example);
example = "NAV_LIST";
PredefinedLayout nav_list = PredefinedLayout.valueForString(example);
example = "NAV_KEYBOARD";
PredefinedLayout nav_keyboard = PredefinedLayout.valueForString(example);
example = "GRAPHIC_WITH_TEXT";
PredefinedLayout graphic_with_text = PredefinedLayout.valueForString(example);
example = "TEXT_WITH_GRAPHIC";
PredefinedLayout text_with_graphic = PredefinedLayout.valueForString(example);
example = "TILES_ONLY";
PredefinedLayout tiles_only = PredefinedLayout.valueForString(example);
example = "TEXTBUTTONS_ONLY";
PredefinedLayout textbuttons_only = PredefinedLayout.valueForString(example);
example = "GRAPHIC_WITH_TILES";
PredefinedLayout graphic_with_tiles = PredefinedLayout.valueForString(example);
example = "TILES_WITH_GRAPHIC";
PredefinedLayout tiles_with_graphic = PredefinedLayout.valueForString(example);
example = "GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS";
PredefinedLayout graphic_with_text_and_softbuttons = PredefinedLayout.valueForString(example);
example = "TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC";
PredefinedLayout text_and_softbuttons_with_graphics = PredefinedLayout.valueForString(example);
example = "GRAPHIC_WITH_TEXTBUTTONS";
PredefinedLayout graphic_with_textbuttons = PredefinedLayout.valueForString(example);
example = "TEXTBUTTONS_WITH_GRAPHIC";
PredefinedLayout textbuttons_with_graphic = PredefinedLayout.valueForString(example);
example = "LARGE_GRAPHIC_WITH_SOFTBUTTONS";
PredefinedLayout large_graphic_with_softbuttons = PredefinedLayout.valueForString(example);
example = "DOUBLE_GRAPHIC_WITH_SOFTBUTTONS";
PredefinedLayout double_graphic_with_softbuttons = PredefinedLayout.valueForString(example);
example = "LARGE_GRAPHIC_ONLY";
PredefinedLayout large_graphic_only = PredefinedLayout.valueForString(example);
example = "WEB_VIEW";
PredefinedLayout web_view = PredefinedLayout.valueForString(example);
assertNotNull("DEFAULT returned null", defaultenum);
assertNotNull("MEDIA returned null", media);
assertNotNull("NON-MEDIA returned null", nonmedia);
assertNotNull("ONSCREEN_PRESETS returned null", onscreen_presets);
assertNotNull("NAV_FULLSCREEN_MAP returned null", nav_fullscreen_map);
assertNotNull("NAV_LIST returned null", nav_list);
assertNotNull("NAV_KEYBOARD returned null", nav_keyboard);
assertNotNull("GRAPHIC_WITH_TEXT returned null", graphic_with_text);
assertNotNull("TEXT_WITH_GRAPHIC returned null", text_with_graphic);
assertNotNull("TILES_ONLY returned null", tiles_only);
assertNotNull("TEXTBUTTONS_ONLY returned null", textbuttons_only);
assertNotNull("GRAPHIC_WITH_TILES returned null", graphic_with_tiles);
assertNotNull("TILES_WITH_GRAPHIC returned null", tiles_with_graphic);
assertNotNull("GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS returned null", graphic_with_text_and_softbuttons);
assertNotNull("TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC returned null", text_and_softbuttons_with_graphics);
assertNotNull("GRAPHIC_WITH_TEXTBUTTONS returned null", graphic_with_textbuttons);
assertNotNull("TEXTBUTTONS_WITH_GRAPHIC returned null", textbuttons_with_graphic);
assertNotNull("LARGE_GRAPHIC_WITH_SOFTBUTTONS returned null", large_graphic_with_softbuttons);
assertNotNull("DOUBLE_GRAPHIC_WITH_SOFTBUTTONS returned null", double_graphic_with_softbuttons);
assertNotNull("LARGE_GRAPHIC_ONLY returned null", large_graphic_only);
assertNotNull("WEB_VIEW returned null", web_view);
}
/**
* Verifies that an invalid assignment is null.
*/
public void testInvalidEnum () {
String example = "LARGE_GRApHIC_ONLY";
try {
PredefinedLayout temp = PredefinedLayout.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 {
PredefinedLayout temp = PredefinedLayout.valueForString(example);
assertNull("Result of valueForString should be null.", temp);
}
catch (NullPointerException exception) {
fail("Null string throws NullPointerException.");
}
}
/**
* Verifies the possible enum values of PredefinedLayout.
*/
public void testListEnum() {
List<PredefinedLayout> enumValueList = Arrays.asList(PredefinedLayout.values());
List<PredefinedLayout> enumTestList = new ArrayList<>();
enumTestList.add(PredefinedLayout.DEFAULT);
enumTestList.add(PredefinedLayout.MEDIA);
enumTestList.add(PredefinedLayout.NON_MEDIA);
enumTestList.add(PredefinedLayout.ONSCREEN_PRESETS);
enumTestList.add(PredefinedLayout.NAV_FULLSCREEN_MAP);
enumTestList.add(PredefinedLayout.NAV_LIST);
enumTestList.add(PredefinedLayout.NAV_KEYBOARD);
enumTestList.add(PredefinedLayout.GRAPHIC_WITH_TEXT);
enumTestList.add(PredefinedLayout.TEXT_WITH_GRAPHIC);
enumTestList.add(PredefinedLayout.TILES_ONLY);
enumTestList.add(PredefinedLayout.TEXTBUTTONS_ONLY);
enumTestList.add(PredefinedLayout.GRAPHIC_WITH_TILES);
enumTestList.add(PredefinedLayout.TILES_WITH_GRAPHIC);
enumTestList.add(PredefinedLayout.GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS);
enumTestList.add(PredefinedLayout.TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC);
enumTestList.add(PredefinedLayout.GRAPHIC_WITH_TEXTBUTTONS);
enumTestList.add(PredefinedLayout.TEXTBUTTONS_WITH_GRAPHIC);
enumTestList.add(PredefinedLayout.LARGE_GRAPHIC_WITH_SOFTBUTTONS);
enumTestList.add(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS);
enumTestList.add(PredefinedLayout.LARGE_GRAPHIC_ONLY);
enumTestList.add(PredefinedLayout.WEB_VIEW);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
}
}
|