Home | History | Annotate | Download | only in avrcp
      1 package com.android.bluetooth.avrcp;
      2 
      3 import android.test.AndroidTestCase;
      4 
      5 import junit.framework.Assert;
      6 
      7 /** Unit tests for {@link EvictingQueue}. */
      8 public class EvictingQueueTest extends AndroidTestCase {
      9     public void testEvictingQueue_canAddItems() {
     10         EvictingQueue<Integer> e = new EvictingQueue<Integer>(10);
     11 
     12         e.add(1);
     13 
     14         assertEquals((long) e.size(), (long) 1);
     15     }
     16 
     17     public void testEvictingQueue_maxItems() {
     18         EvictingQueue<Integer> e = new EvictingQueue<Integer>(5);
     19 
     20         e.add(1);
     21         e.add(2);
     22         e.add(3);
     23         e.add(4);
     24         e.add(5);
     25         e.add(6);
     26 
     27         assertEquals((long) e.size(), (long) 5);
     28         // Items drop off the front
     29         assertEquals((long) e.peek(), (long) 2);
     30     }
     31 
     32     public void testEvictingQueue_frontDrop() {
     33         EvictingQueue<Integer> e = new EvictingQueue<Integer>(5);
     34 
     35         e.add(1);
     36         e.add(2);
     37         e.add(3);
     38         e.add(4);
     39         e.add(5);
     40 
     41         assertEquals((long) e.size(), (long) 5);
     42 
     43         e.addFirst(6);
     44 
     45         assertEquals((long) e.size(), (long) 5);
     46         assertEquals((long) e.peek(), (long) 1);
     47     }
     48 }
     49