VCardTestUtilsTestspublic 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. |
Methods Summary |
---|
public void | testShouldFailAtContentValueVerification()
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 void | testShouldFailAtLineVerification()
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 void | testShouldFailAtPropertyNodeVerification()
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.");
}
|
|