• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.bluetooth.avrcp;
2 
3 import android.support.test.filters.MediumTest;
4 import android.support.test.runner.AndroidJUnit4;
5 
6 import org.junit.Assert;
7 import org.junit.Test;
8 import org.junit.runner.RunWith;
9 
10 /**
11  *  Unit tests for {@link EvictingQueue}.
12  */
13 @MediumTest
14 @RunWith(AndroidJUnit4.class)
15 public class EvictingQueueTest {
16     @Test
testEvictingQueue_canAddItems()17     public void testEvictingQueue_canAddItems() {
18         EvictingQueue<Integer> e = new EvictingQueue<Integer>(10);
19 
20         e.add(1);
21 
22         Assert.assertEquals((long) e.size(), (long) 1);
23     }
24 
25     @Test
testEvictingQueue_maxItems()26     public void testEvictingQueue_maxItems() {
27         EvictingQueue<Integer> e = new EvictingQueue<Integer>(5);
28 
29         e.add(1);
30         e.add(2);
31         e.add(3);
32         e.add(4);
33         e.add(5);
34         e.add(6);
35 
36         Assert.assertEquals((long) e.size(), (long) 5);
37         // Items drop off the front
38         Assert.assertEquals((long) e.peek(), (long) 2);
39     }
40 
41     @Test
testEvictingQueue_frontDrop()42     public void testEvictingQueue_frontDrop() {
43         EvictingQueue<Integer> e = new EvictingQueue<Integer>(5);
44 
45         e.add(1);
46         e.add(2);
47         e.add(3);
48         e.add(4);
49         e.add(5);
50 
51         Assert.assertEquals((long) e.size(), (long) 5);
52 
53         e.addFirst(6);
54 
55         Assert.assertEquals((long) e.size(), (long) 5);
56         Assert.assertEquals((long) e.peek(), (long) 1);
57     }
58 }
59