FileDocCategorySizeDatePackage
VCardTestUtilsTests.javaAPI DocAndroid 5.1 API4040Thu Mar 12 22:22:54 GMT 2015com.android.vcard.tests

VCardTestUtilsTests

public class VCardTestUtilsTests extends android.test.AndroidTestCase
Tests confirming utilities for vCard tests work fine. Now that the foundation classes for vCard test cases became too complicated to rely on without testing itself.

Fields Summary
Constructors Summary
Methods Summary
public voidtestShouldFailAtContentValueVerification()

        boolean failureDetected = false;
        try {
            final VCardVerifier verifier = new VCardVerifier(this);
            verifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC, R.raw.v21_backslash);
            verifier.addContentValuesVerifierElem()
                    .addExpected(StructuredName.CONTENT_ITEM_TYPE)
                            .put(StructuredName.GIVEN_NAME, "A;B\\")
                            .put(StructuredName.MIDDLE_NAME, "C\\;")
                            .put(StructuredName.PREFIX, "D")
                            .put(StructuredName.SUFFIX, ":E");
            // DISPLAY_NAME is missing.
            verifier.verify();
        } catch (AssertionFailedError e) {
            failureDetected = true;
        }
        if (!failureDetected) {
            TestCase.fail("Test case that should fail actually succeeded.");
        }
    
public voidtestShouldFailAtLineVerification()

        boolean failureDetected = false;
        try {
            final VCardVerifier verifier = new VCardVerifier(this);
            verifier.initForExportTest(VCardConfig.VCARD_TYPE_V30_GENERIC);
            verifier.addInputEntry().addContentValues(StructuredName.CONTENT_ITEM_TYPE)
                    .put(StructuredName.FAMILY_NAME, "\\")
                    .put(StructuredName.GIVEN_NAME, ";")
                    .put(StructuredName.MIDDLE_NAME, ",")
                    .put(StructuredName.PREFIX, "\n")
                    .put(StructuredName.DISPLAY_NAME, "[<{Unescaped:Asciis}>]");
            verifier.addLineVerifierElem()
                    .addExpected("TEL:1")  // wrong
                    .addExpected("FN:[<{Unescaped:Asciis}>]");
            verifier.verify();
        } catch (AssertionFailedError e) {
            failureDetected = true;
        }
        if (!failureDetected) {
            TestCase.fail("Test case that should fail actually succeeded.");
        }
    
public voidtestShouldFailAtPropertyNodeVerification()

        boolean failureDetected = false;
        try {
            final VCardVerifier verifier = new VCardVerifier(this);
            verifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC, R.raw.v21_backslash);
            verifier.addPropertyNodesVerifierElem()
                    .addExpectedNodeWithOrder("N", ";A;B\\;C\\;;D;:E;\\\\;--",  // wrong
                            Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", ""))
                    .addExpectedNodeWithOrder("FN", "A;B\\C\\;D:E\\\\");
            verifier.verify();
        } catch (AssertionFailedError e) {
            failureDetected = true;
        }
        if (!failureDetected) {
            TestCase.fail("Test case that should fail actually succeeded.");
        }