summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikayla Ray <mikayla@livioconnect.com>2015-05-13 13:38:45 -0400
committerMikayla Ray <mikayla@livioconnect.com>2015-05-13 13:38:45 -0400
commit6da3ffb46bd5c8ec2e4bf35e9b32e9a99bbab6c5 (patch)
tree45f5e9c838a79b2a57c7070415e8b6508d828bda
parentaf6d11ec8ad8a9d031dca8c8fc0685929f45733d (diff)
downloadsdl_android-6da3ffb46bd5c8ec2e4bf35e9b32e9a99bbab6c5.tar.gz
Documented and improved NativeLogToolTests class.
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/util/NativeLogToolTests.java76
1 files changed, 60 insertions, 16 deletions
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/util/NativeLogToolTests.java b/sdl_android_tests/src/com/smartdevicelink/test/util/NativeLogToolTests.java
index e748f23aa..3cfa601c5 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/util/NativeLogToolTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/util/NativeLogToolTests.java
@@ -1,32 +1,76 @@
package com.smartdevicelink.test.util;
-
-import com.smartdevicelink.util.NativeLogTool;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import junit.framework.TestCase;
+import com.smartdevicelink.util.NativeLogTool;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.util.NativeLogTool}
+ */
public class NativeLogToolTests extends TestCase {
- public void testValidEnums () {
- String test = "Info";
- NativeLogTool.LogTarget testInfo = NativeLogTool.LogTarget.valueForString(test);
- test = "Warning";
- NativeLogTool.LogTarget testWarning = NativeLogTool.LogTarget.valueForString(test);
- test = "Error";
- NativeLogTool.LogTarget testError = NativeLogTool.LogTarget.valueForString(test);
+ /**
+ * This is a unit test for the following enum :
+ * {@link com.smartdevicelink.util.NativeLogTool.LogTarget}
+ */
+ public void testLogTargetEnum () {
- assertNotNull("Info enum was null", testInfo);
- assertNotNull("Warning enum was null", testWarning);
- assertNotNull("Error enum was null", testError);
+ // Test Values
+ String testInfo = "Info";
+ String testError = "Error";
+ String testInvalid = "Invalid";
+ String testWarning = "Warning";
+
+ try {
+ // Comparison Values
+ NativeLogTool.LogTarget expectedInfoEnum = NativeLogTool.LogTarget.Info;
+ NativeLogTool.LogTarget expectedErrorEnum = NativeLogTool.LogTarget.Error;
+ NativeLogTool.LogTarget expectedWarningEnum = NativeLogTool.LogTarget.Warning;
+ List<NativeLogTool.LogTarget> expectedEnumList = new ArrayList<NativeLogTool.LogTarget>();
+ expectedEnumList.add(NativeLogTool.LogTarget.Info);
+ expectedEnumList.add(NativeLogTool.LogTarget.Error);
+ expectedEnumList.add(NativeLogTool.LogTarget.Warning);
+
+ NativeLogTool.LogTarget actualNullEnum = NativeLogTool.LogTarget.valueForString(null);
+ NativeLogTool.LogTarget actualInfoEnum = NativeLogTool.LogTarget.valueForString(testInfo);
+ NativeLogTool.LogTarget actualErrorEnum = NativeLogTool.LogTarget.valueForString(testError);
+ NativeLogTool.LogTarget actualInvalidEnum = NativeLogTool.LogTarget.valueForString(testInvalid);
+ NativeLogTool.LogTarget actualWarningEnum = NativeLogTool.LogTarget.valueForString(testWarning);
+ List<NativeLogTool.LogTarget> actualEnumList = Arrays.asList(NativeLogTool.LogTarget.values());
+
+ // Valid Tests
+ assertEquals("Values should match.", expectedInfoEnum, actualInfoEnum);
+ assertEquals("Values should match.", expectedErrorEnum, actualErrorEnum);
+ assertEquals("Values should match.", expectedWarningEnum, actualWarningEnum);
+ assertTrue("Contents should match.", expectedEnumList.containsAll(actualEnumList) && actualEnumList.containsAll(expectedEnumList));
+
+ // Invalid/Null Tests
+ assertNull("Value should be null.", actualInvalidEnum);
+ assertNull("Value should be null.", actualNullEnum);
+
+ } catch (NullPointerException e) {
+ fail("Could not retrieve value for null string, should return null.");
+ } catch (IllegalArgumentException e) {
+ fail("Could not retrieve value for invalid string, should return null.");
+ }
}
+ /**
+ * This is a unit test for the following methods :
+ * {@link com.smartdevicelink.util.NativeLogTool#setEnableState(boolean)}
+ * {@link com.smartdevicelink.util.NativeLogTool#getEnableState()}
+ */
public void testEnabled () {
NativeLogTool.setEnableState(false);
- assertFalse("Enabled status should be false.", NativeLogTool.isEnabled());
-
+ assertFalse("Value should be false.", NativeLogTool.isEnabled());
NativeLogTool.setEnableState(true);
- assertTrue("Enabled status should be true.", NativeLogTool.isEnabled());
+ assertTrue("Valueshould be true.", NativeLogTool.isEnabled());
}
- // No need to test logging.
+ // NOTE : No testing can currently be done for the logging methods.
} \ No newline at end of file