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 17package com.android.providers.contacts.sqlite; 18 19import android.test.AndroidTestCase; 20 21import com.android.providers.contacts.ContactsDatabaseHelper; 22import com.android.providers.contacts.TestUtils; 23 24import java.util.List; 25 26public class DatabaseAnalyzerTest extends AndroidTestCase { 27 public void testFindTableViewsAllowingColumns() { 28 final ContactsDatabaseHelper dbh = 29 ContactsDatabaseHelper.getNewInstanceForTest(getContext(), 30 TestUtils.getContactsDatabaseFilename(getContext())); 31 try { 32 final List<String> list = DatabaseAnalyzer.findTableViewsAllowingColumns( 33 dbh.getReadableDatabase()); 34 35 assertTrue(list.contains("contacts")); 36 assertTrue(list.contains("raw_contacts")); 37 assertTrue(list.contains("view_contacts")); 38 assertTrue(list.contains("view_raw_contacts")); 39 assertTrue(list.contains("view_data")); 40 41 assertFalse(list.contains("data")); 42 assertFalse(list.contains("_id")); 43 44 } finally { 45 dbh.close(); 46 } 47 } 48}