1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 package libcore.java.util.tests; 19 20 import com.google.common.collect.testing.MinimalCollection; 21 import com.google.common.collect.testing.QueueTestSuiteBuilder; 22 import com.google.common.collect.testing.TestStringQueueGenerator; 23 import com.google.common.collect.testing.TestsForListsInJavaUtil; 24 import com.google.common.collect.testing.TestsForQueuesInJavaUtil; 25 import com.google.common.collect.testing.features.CollectionFeature; 26 import com.google.common.collect.testing.features.CollectionSize; 27 28 import java.util.LinkedList; 29 import java.util.Queue; 30 import junit.framework.Test; 31 32 /** 33 * Guava-testlib tests for {@code Queue} implementations from {@code java.util}. 34 */ 35 public class AndroidTestsForQueuesInJavaUtil extends TestsForQueuesInJavaUtil { 36 37 /** 38 * Override and copy the super class's implementation in order to change the name to ensure 39 * that created tests are unique and do not clash with those created by 40 * {@link TestsForListsInJavaUtil#testsForLinkedList()}, see bug 62438629. 41 */ 42 @Override 43 public Test testsForLinkedList() { 44 return QueueTestSuiteBuilder.using( 45 new TestStringQueueGenerator() { 46 @Override 47 public Queue<String> create(String[] elements) { 48 return new LinkedList<String>(MinimalCollection.of(elements)); 49 } 50 }) 51 .named("LinkedList as Queue") 52 .withFeatures( 53 CollectionFeature.GENERAL_PURPOSE, 54 CollectionFeature.ALLOWS_NULL_VALUES, 55 CollectionFeature.KNOWN_ORDER, 56 CollectionSize.ANY) 57 .skipCollectionTests() // already covered in TestsForListsInJavaUtil 58 .suppressing(suppressForLinkedList()) 59 .createTestSuite(); 60 } 61 } 62