1/* 2 * Copyright (C) 2011 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; 18 19import android.content.ContentResolver; 20import android.test.suitebuilder.annotation.MediumTest; 21 22import com.android.providers.contacts.testutil.RawContactUtil; 23import com.android.vcard.VCardComposer; 24import com.android.vcard.VCardConfig; 25 26/** 27 * Tests (or integration tests) verifying if vCard library works well with {@link ContentResolver}. 28 * 29 * Unit tests for vCard itself should be availabel in vCard library. 30 */ 31@MediumTest 32public class VCardTest extends BaseContactsProvider2Test { 33 private static final String TAG = "VCardTest"; 34 private static final boolean DEBUG = false; 35 36 /** 37 * Confirms the app fetches a stored contact from resolver and output the name as part of 38 * a vCard string. 39 */ 40 public void testCompose() { 41 RawContactUtil.createRawContactWithName(mResolver, "John", "Doe"); 42 final VCardComposer composer = new VCardComposer( 43 getContext(), mResolver, VCardConfig.VCARD_TYPE_DEFAULT, null, true); 44 assertTrue(composer.init()); 45 int total = composer.getCount(); 46 assertEquals(1, total); 47 String vcard = composer.createOneEntry(); 48 assertNotNull(vcard); 49 50 // Check vCard very roughly. 51 assertTrue(vcard.contains("John")); 52 assertTrue(vcard.contains("Doe")); 53 } 54} 55