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