summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-02-18 10:21:12 +0100
committerTobrun <tobrun@mapbox.com>2016-02-18 10:21:12 +0100
commitdaedb3ddb21c34559f2ca53d747849c10916b7c1 (patch)
treecb8d9cbe07aeaecc314bc6d4f82ac7c03e38f174 /platform
parenta331e94b1b8d7fcdffe7ef757f4f4c56c9307e8e (diff)
downloadqtlocation-mapboxgl-daedb3ddb21c34559f2ca53d747849c10916b7c1.tar.gz
[android] #4000 - add unit tests icon
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
new file mode 100644
index 0000000000..9e95451cb1
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
@@ -0,0 +1,55 @@
+package com.mapbox.mapboxsdk.annotations;
+
+import android.graphics.Bitmap;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotSame;
+
+public class IconTest {
+
+ @Mock
+ Bitmap mBitmap;
+
+ @Before
+ public void beforeTest() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testId() {
+ String id = "test";
+ Icon icon = IconFactory.recreate(id, Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
+ assertEquals("id should match", id, icon.getId());
+ }
+
+ @Test
+ public void testBitmap() {
+ Icon icon = IconFactory.recreate("test", mBitmap);
+ assertEquals("bitmap should match", mBitmap, icon.getBitmap());
+ }
+
+ @Test
+ public void testEquals() {
+ Icon icon1 = IconFactory.recreate("test", mBitmap);
+ Icon icon2 = IconFactory.recreate("test", mBitmap);
+ assertEquals("icons should not match", icon1, icon2);
+ }
+
+ @Test
+ public void testEqualsObject() {
+ Icon icon = IconFactory.recreate("test", Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
+ assertNotSame("icon should not match", new Object(), icon);
+ }
+
+ @Test
+ public void testHashcode() {
+ Icon icon = IconFactory.recreate("test", mBitmap);
+ long expectedHashcode = 31 * mBitmap.hashCode() + "test".hashCode();
+ assertEquals("hashcode should match", expectedHashcode, icon.hashCode());
+ }
+}