1/* 2 * Copyright (C) 2009 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 */ 16package com.android.vcard.tests.testutils; 17 18import android.test.AndroidTestCase; 19 20import com.android.vcard.VCardEntry; 21import com.android.vcard.VCardEntryHandler; 22 23import java.util.ArrayList; 24import java.util.List; 25 26public class ContentValuesVerifier implements VCardEntryHandler { 27 private List<ContentValuesVerifierElem> mContentValuesVerifierElemList = 28 new ArrayList<ContentValuesVerifierElem>(); 29 private int mIndex; 30 31 public ContentValuesVerifierElem addElem(AndroidTestCase androidTestCase) { 32 ContentValuesVerifierElem elem = new ContentValuesVerifierElem(androidTestCase); 33 mContentValuesVerifierElemList.add(elem); 34 return elem; 35 } 36 37 @Override 38 public void onStart() { 39 for (ContentValuesVerifierElem elem : mContentValuesVerifierElemList) { 40 elem.onParsingStart(); 41 } 42 } 43 44 @Override 45 public void onEntryCreated(VCardEntry entry) { 46 AndroidTestCase.assertTrue(mIndex < mContentValuesVerifierElemList.size()); 47 mContentValuesVerifierElemList.get(mIndex).onEntryCreated(entry); 48 mIndex++; 49 } 50 51 @Override 52 public void onEnd() { 53 for (ContentValuesVerifierElem elem : mContentValuesVerifierElemList) { 54 elem.onParsingEnd(); 55 elem.verifyResolver(); 56 } 57 } 58} 59