1 package com.android.camera.gallery; 2 3 import com.android.camera.ImageManager; 4 5 import android.test.AndroidTestCase; 6 7 public class ImageListUberUnitTests extends AndroidTestCase { 8 9 private MockImage getImageAt(ImageListUber uber, int index) { 10 return (MockImage) uber.getImageAt(index); 11 } 12 13 public void testTheOrderOfGetImageAt() { 14 MockImageList listA = new MockImageList(); 15 MockImageList listB = new MockImageList(); 16 listA.addImage(new MockImage(2, 2)); 17 listA.addImage(new MockImage(0, 0)); 18 listB.addImage(new MockImage(1, 1)); 19 ImageListUber uber = new ImageListUber( 20 new IImageList[] {listA, listB}, ImageManager.SORT_DESCENDING); 21 22 assertEquals(2, getImageAt(uber, 0).fullSizeImageId()); 23 assertEquals(1, getImageAt(uber, 1).fullSizeImageId()); 24 assertEquals(0, getImageAt(uber, 2).fullSizeImageId()); 25 uber.close(); 26 27 uber = new ImageListUber( 28 new IImageList[] {listA, listB}, ImageManager.SORT_DESCENDING); 29 assertEquals(2, getImageAt(uber, 0).fullSizeImageId()); 30 assertEquals(1, getImageAt(uber, 1).fullSizeImageId()); 31 assertEquals(0, getImageAt(uber, 2).fullSizeImageId()); 32 uber.close(); 33 } 34 35 public void testTheOrderOfGetImageAtCaseTwo() { 36 MockImageList listA = new MockImageList(); 37 MockImageList listB = new MockImageList(); 38 listA.addImage(new MockImage(2, 2)); 39 listA.addImage(new MockImage(1, 1)); 40 listB.addImage(new MockImage(0, 0)); 41 ImageListUber uber = new ImageListUber( 42 new IImageList[] {listB, listA}, ImageManager.SORT_DESCENDING); 43 44 assertEquals(2, getImageAt(uber, 0).fullSizeImageId()); 45 assertEquals(1, getImageAt(uber, 1).fullSizeImageId()); 46 assertEquals(0, getImageAt(uber, 2).fullSizeImageId()); 47 uber.close(); 48 49 uber = new ImageListUber( 50 new IImageList[] {listA, listB}, ImageManager.SORT_DESCENDING); 51 52 assertEquals(2, getImageAt(uber, 0).fullSizeImageId()); 53 assertEquals(1, getImageAt(uber, 1).fullSizeImageId()); 54 assertEquals(0, getImageAt(uber, 2).fullSizeImageId()); 55 uber.close(); 56 } 57 58 public void testRemoveImage() { 59 MockImageList listA = new MockImageList(); 60 MockImageList listB = new MockImageList(); 61 MockImage target = new MockImage(1, 1); 62 listA.addImage(new MockImage(2, 2)); 63 listA.addImage(new MockImage(0, 0)); 64 listB.addImage(target); 65 ImageListUber uber = new ImageListUber( 66 new IImageList[] {listB, listA}, ImageManager.SORT_DESCENDING); 67 uber.removeImage(target); 68 assertEquals(2, getImageAt(uber, 0).fullSizeImageId()); 69 assertEquals(0, getImageAt(uber, 1).fullSizeImageId()); 70 71 assertEquals(0, uber.getImageIndex(getImageAt(uber, 0))); 72 assertEquals(1, uber.getImageIndex(getImageAt(uber, 1))); 73 uber.close(); 74 } 75 76 public void testRemoveImageAt() { 77 MockImageList listA = new MockImageList(); 78 MockImageList listB = new MockImageList(); 79 MockImage target = new MockImage(1, 1); 80 listA.addImage(new MockImage(2, 2)); 81 listA.addImage(new MockImage(0, 0)); 82 listB.addImage(target); 83 ImageListUber uber = new ImageListUber( 84 new IImageList[] {listB, listA}, ImageManager.SORT_DESCENDING); 85 uber.removeImageAt(1); 86 assertEquals(2, getImageAt(uber, 0).fullSizeImageId()); 87 assertEquals(0, getImageAt(uber, 1).fullSizeImageId()); 88 89 assertEquals(0, uber.getImageIndex(getImageAt(uber, 0))); 90 assertEquals(1, uber.getImageIndex(getImageAt(uber, 1))); 91 uber.close(); 92 } 93 } 94