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 junit.framework.TestCase; 21 22import java.util.ArrayList; 23 24public class LineVerifier { 25 private final AndroidTestCase mAndroidTestCase; 26 private final ArrayList<LineVerifierElem> mLineVerifierElemList; 27 private int mVCardType; 28 private int index; 29 30 public LineVerifier(AndroidTestCase androidTestCase, int vcardType) { 31 mAndroidTestCase = androidTestCase; 32 mLineVerifierElemList = new ArrayList<LineVerifierElem>(); 33 mVCardType = vcardType; 34 } 35 36 public LineVerifierElem addLineVerifierElem() { 37 LineVerifierElem lineVerifier = new LineVerifierElem(mAndroidTestCase, mVCardType); 38 mLineVerifierElemList.add(lineVerifier); 39 return lineVerifier; 40 } 41 42 public void verify(String vcard) { 43 if (index >= mLineVerifierElemList.size()) { 44 TestCase.fail("Insufficient number of LineVerifier (" + index + ")"); 45 } 46 47 final LineVerifierElem lineVerifier = mLineVerifierElemList.get(index); 48 lineVerifier.verify(vcard); 49 50 index++; 51 } 52} 53