SearchableCorporaTest.java revision 883c1bf364e38c5b133afb55f8493a14b65f4dd4
13e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/* 23e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Copyright (C) 2009 The Android Open Source Project 33e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 43e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 53e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * you may not use this file except in compliance with the License. 63e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * You may obtain a copy of the License at 73e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 83e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 93e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 103e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Unless required by applicable law or agreed to in writing, software 113e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 123e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * See the License for the specific language governing permissions and 143e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * limitations under the License. 153e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 163e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 173e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertpackage com.android.quicksearchbox; 183e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 193e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.test.AndroidTestCase; 203e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.test.suitebuilder.annotation.MediumTest; 213e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 223e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport java.util.Collection; 233e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 243e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/** 25fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert * Tests for {@link SearchableCorpora}. 263e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 273e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 283e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert@MediumTest 29883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringertpublic class SearchableCorporaTest extends AndroidTestCase { 303e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 31fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert protected SearchableCorpora mCorpora; 323e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 333e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert @Override 343e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert protected void setUp() throws Exception { 353e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert super.setUp(); 363e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 373e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert Config config = new Config(mContext); 38883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert MockSources sources = new MockSources(); 39883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert sources.addSource(MockSource.SOURCE_1); 40883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert sources.addSource(MockSource.SOURCE_2); 41883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert mCorpora = new SearchableCorpora(mContext, config, new MockHandler(), 42883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert sources, new MockCorpusFactory()); 43fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert mCorpora.load(); 443e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 453e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 46883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert public void testGetAllCorpora() { 47fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert assertNotEmpty(mCorpora.getAllCorpora()); 483e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 493e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 503e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert public void testEnabledSuggestionSources() { 51883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert assertNotNull(mCorpora.getEnabledCorpora()); 52883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert } 53883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert 54883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert public void testGetCorpusForSource() { 55883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert assertNotNull(mCorpora.getCorpusForSource(MockSource.SOURCE_1)); 56883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert assertNotNull(mCorpora.getCorpusForSource(MockSource.SOURCE_2)); 57883c1bf364e38c5b133afb55f8493a14b65f4dd4Bjorn Bringert assertNull(mCorpora.getCorpusForSource(MockSource.SOURCE_3)); 583e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 593e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 603e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert static void assertEmpty(Collection<?> collection) { 613e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert assertNotNull(collection); 623e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert assertTrue(collection.isEmpty()); 633e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 643e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 653e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert static void assertNotEmpty(Collection<?> collection) { 663e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert assertNotNull(collection); 673e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert assertFalse(collection.isEmpty()); 683e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert } 693e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 703e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert} 71