Back to project page adventure.datetime.
The source code is released under:
MIT License
If you think the Android project adventure.datetime listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ca.cmput301f13t03.adventure_datetime.model; /* ww w. j av a 2 s .c om*/ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.test.AndroidTestCase; import ca.cmput301f13t03.adventure_datetime.R; import com.google.gson.Gson; public class ImageTest extends AndroidTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void testJson() throws Exception { Image image = new Image(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.grumpy_cat)); Gson gson = new Gson(); Bitmap bitmap = image.decodeBitmap(); assertEquals(bitmap, image.decodeBitmap()); String json = gson.toJson(image); Image image2 = gson.fromJson(json, Image.class); assertEquals(image.getId(), image2.getId()); assertEquals(image.getEncodedBitmap(), image2.getEncodedBitmap()); image.setBitmap(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.launch_icon)); assertFalse(bitmap.equals(image.decodeBitmap())); } }