diff options
Diffstat (limited to 'tests/AndroidTests')
4 files changed, 85 insertions, 24 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java index 4eb47c0..190a355 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java @@ -139,6 +139,12 @@ class PropertyNodesVerifierElem { return addNodeWithOrder(propName, propValue, null, null, contentValues, null, null); } + public PropertyNodesVerifierElem addNodeWithOrder(String propName, + List<String> propValueList, ContentValues contentValues) { + return addNodeWithOrder(propName, null, propValueList, + null, contentValues, null, null); + } + public PropertyNodesVerifierElem addNodeWithOrder(String propName, String propValue, List<String> propValueList) { return addNodeWithOrder(propName, propValue, propValueList, null, null, null, null); @@ -157,8 +163,7 @@ class PropertyNodesVerifierElem { public PropertyNodesVerifierElem addNodeWithOrder(String propName, List<String> propValueList, TypeSet paramMap_TYPE) { - final String propValue = concatinateListWithSemiColon(propValueList); - return addNodeWithOrder(propName, propValue, propValueList, null, null, + return addNodeWithOrder(propName, null, propValueList, null, null, paramMap_TYPE, null); } @@ -177,6 +182,9 @@ class PropertyNodesVerifierElem { public PropertyNodesVerifierElem addNodeWithOrder(String propName, String propValue, List<String> propValueList, byte[] propValue_bytes, ContentValues paramMap, TypeSet paramMap_TYPE, GroupSet propGroupSet) { + if (propValue == null && propValueList != null) { + propValue = concatinateListWithSemiColon(propValueList); + } PropertyNode propertyNode = new PropertyNode(propName, propValue, propValueList, propValue_bytes, paramMap, paramMap_TYPE, propGroupSet); @@ -200,14 +208,20 @@ class PropertyNodesVerifierElem { return addNodeWithoutOrder(propName, propValue, null, null, contentValues, null, null); } + public PropertyNodesVerifierElem addNodeWithoutOrder(String propName, + List<String> propValueList, ContentValues contentValues) { + return addNodeWithoutOrder(propName, null, + propValueList, null, contentValues, null, null); + } + public PropertyNodesVerifierElem addNodeWithoutOrder(String propName, String propValue, List<String> propValueList) { return addNodeWithoutOrder(propName, propValue, propValueList, null, null, null, null); } - public PropertyNodesVerifierElem addNodeWithoutOrder(String propName, List<String> propValueList) { - final String propValue = concatinateListWithSemiColon(propValueList); - return addNodeWithoutOrder(propName, propValue, propValueList, + public PropertyNodesVerifierElem addNodeWithoutOrder(String propName, + List<String> propValueList) { + return addNodeWithoutOrder(propName, null, propValueList, null, null, null, null); } @@ -238,6 +252,9 @@ class PropertyNodesVerifierElem { public PropertyNodesVerifierElem addNodeWithoutOrder(String propName, String propValue, List<String> propValueList, byte[] propValue_bytes, ContentValues paramMap, TypeSet paramMap_TYPE, GroupSet propGroupSet) { + if (propValue == null && propValueList != null) { + propValue = concatinateListWithSemiColon(propValueList); + } mUnorderedNodeList.add(new PropertyNode(propName, propValue, propValueList, propValue_bytes, paramMap, paramMap_TYPE, propGroupSet)); return this; diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java index a1db051..616d451 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java @@ -546,12 +546,9 @@ public class VCardExporterTests extends VCardTestsBase { testEmailPrefHandlingCommon(V30); } - private void testPostalOnlyWithStructuredDataCommon(int vcardType) { + private void testPostalAddressCommon(int vcardType) { VCardVerifier verifier = new VCardVerifier(vcardType); ContactEntry entry = verifier.addInputEntry(); - // adr-value = 0*6(text-value ";") text-value - // ; PO Box, Extended Address, Street, Locality, Region, Postal Code, - // ; Country Name entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) .put(StructuredPostal.POBOX, "Pobox") .put(StructuredPostal.NEIGHBORHOOD, "Neighborhood") @@ -559,27 +556,33 @@ public class VCardExporterTests extends VCardTestsBase { .put(StructuredPostal.CITY, "City") .put(StructuredPostal.REGION, "Region") .put(StructuredPostal.POSTCODE, "100") - .put(StructuredPostal.COUNTRY, "Country"); + .put(StructuredPostal.COUNTRY, "Country") + .put(StructuredPostal.FORMATTED_ADDRESS, "Formatted Address") + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK); + // adr-value = 0*6(text-value ";") text-value + // ; PO Box, Extended Address, Street, Locality, Region, Postal Code, + // ; Country Name verifier.addPropertyNodesVerifierElemWithEmptyName() - .addNodeWithoutOrder("ADR", "Pobox;Neighborhood;Street;City;Region;100;Country", + .addNodeWithoutOrder("ADR", Arrays.asList("Pobox", "Neighborhood", "Street", "City", - "Region", "100", "Country"), new TypeSet("HOME")); + "Region", "100", "Country"), new TypeSet("WORK")); verifier.verify(); } - public void testPostalOnlyWithStructuredDataV21() { - testPostalOnlyWithStructuredDataCommon(V21); + public void testPostalAddressV21() { + testPostalAddressCommon(V21); } - public void testPostalOnlyWithStructuredDataV30() { - testPostalOnlyWithStructuredDataCommon(V30); + public void testPostalAddressV30() { + testPostalAddressCommon(V30); } private void testPostalOnlyWithFormattedAddressCommon(int vcardType) { VCardVerifier verifier = new VCardVerifier(vcardType); ContactEntry entry = verifier.addInputEntry(); entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.REGION, "") // Must be ignored. .put(StructuredPostal.FORMATTED_ADDRESS, "Formatted address CA 123-334 United Statue"); @@ -587,7 +590,6 @@ public class VCardExporterTests extends VCardTestsBase { .addNodeWithOrder("ADR", ";Formatted address CA 123-334 United Statue;;;;;", Arrays.asList("", "Formatted address CA 123-334 United Statue", "", "", "", "", ""), new TypeSet("HOME")); - verifier.verify(); } diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java index 0522867..dd20ec6 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java @@ -205,11 +205,50 @@ public class VCardJapanizationTests extends VCardTestsBase { verifier.verify(); } + private void testPostalAddressWithJapaneseCommon(int vcardType) { + VCardVerifier verifier = new VCardVerifier(vcardType); + ContactEntry entry = verifier.addInputEntry(); + entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "\u79C1\u66F8\u7BB107") + .put(StructuredPostal.NEIGHBORHOOD, + "\u30A2\u30D1\u30FC\u30C8\u0020\u0033\u0034\u53F7\u5BA4") + .put(StructuredPostal.STREET, "\u96DB\u898B\u6CA2\u6751") + .put(StructuredPostal.CITY, "\u9E7F\u9AA8\u5E02") + .put(StructuredPostal.REGION, "\u00D7\u00D7\u770C") + .put(StructuredPostal.POSTCODE, "494-1313") + .put(StructuredPostal.COUNTRY, "\u65E5\u672C") + .put(StructuredPostal.FORMATTED_ADDRESS, + "\u3053\u3093\u306A\u3068\u3053\u308D\u3092\u898B" + + "\u308B\u306A\u3093\u3066\u6687\u4EBA\u3067\u3059\u304B\uFF1F") + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM) + .put(StructuredPostal.LABEL, "\u304A\u3082\u3061\u304B\u3048\u308A"); + + ContentValues contentValues = (VCardConfig.usesShiftJis(vcardType) ? + (VCardConfig.isV30(vcardType) ? mContentValuesForSJis : + mContentValuesForQPAndSJis) : + (VCardConfig.isV30(vcardType) ? mContentValuesForUtf8 : + mContentValuesForQPAndUtf8)); + + PropertyNodesVerifierElem elem = verifier.addPropertyNodesVerifierElemWithEmptyName(); + // LABEL must be ignored in vCard 2.1. As for vCard 3.0, the current behavior is + // same as that in vCard 3.0, which can be changed in the future. + elem.addNodeWithoutOrder("ADR", Arrays.asList("\u79C1\u66F8\u7BB107", + "\u30A2\u30D1\u30FC\u30C8\u0020\u0033\u0034\u53F7\u5BA4", + "\u96DB\u898B\u6CA2\u6751", "\u9E7F\u9AA8\u5E02", "\u00D7\u00D7\u770C", + "494-1313", "\u65E5\u672C"), + contentValues); + verifier.verify(); + } + + public void testPostalAddresswithJapaneseV21() { + testPostalAddressWithJapaneseCommon(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS); + } + /** * Verifies that only one address field is emitted toward DoCoMo phones. * Prefered type must (should?) be: HOME > WORK > OTHER > CUSTOM */ - public void testAdrressFieldEmittionForDoCoMo_1() { + public void testPostalAdrressForDoCoMo_1() { VCardVerifier verifier = new VCardVerifier(VCardConfig.VCARD_TYPE_DOCOMO); ContactEntry entry = verifier.addInputEntry(); entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) @@ -238,7 +277,7 @@ public class VCardJapanizationTests extends VCardTestsBase { verifier.verify(); } - public void testAdrressFieldEmittionForDoCoMo_2() { + public void testPostalAdrressForDoCoMo_2() { VCardVerifier verifier = new VCardVerifier(VCardConfig.VCARD_TYPE_DOCOMO); ContactEntry entry = verifier.addInputEntry(); entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) @@ -264,7 +303,7 @@ public class VCardJapanizationTests extends VCardTestsBase { verifier.verify(); } - public void testAdrressFieldEmittionForDoCoMo_3() { + public void testPostalAdrressForDoCoMo_3() { VCardVerifier verifier = new VCardVerifier(VCardConfig.VCARD_TYPE_DOCOMO); ContactEntry entry = verifier.addInputEntry(); entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) @@ -293,7 +332,7 @@ public class VCardJapanizationTests extends VCardTestsBase { /** * Verifies the vCard exporter tolerates null TYPE. */ - public void testAdrressFieldEmittionForDoCoMo_4() { + public void testPostalAdrressForDoCoMo_4() { VCardVerifier verifier = new VCardVerifier(VCardConfig.VCARD_TYPE_DOCOMO); ContactEntry entry = verifier.addInputEntry(); entry.buildData(StructuredPostal.CONTENT_ITEM_TYPE) diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java index 6202bdb..592c285 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java @@ -22,7 +22,8 @@ import junit.framework.TestCase; public class VCardUtilsTests extends TestCase { public void testContainsOnlyPrintableAscii() { - assertTrue(VCardUtils.containsOnlyPrintableAscii(null)); + assertTrue(VCardUtils.containsOnlyPrintableAscii((String)null)); + assertTrue(VCardUtils.containsOnlyPrintableAscii((String[])null)); assertTrue(VCardUtils.containsOnlyPrintableAscii("")); assertTrue(VCardUtils.containsOnlyPrintableAscii("abcdefghijklmnopqrstuvwxyz")); assertTrue(VCardUtils.containsOnlyPrintableAscii("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); @@ -37,7 +38,8 @@ public class VCardUtilsTests extends TestCase { } public void testContainsOnlyNonCrLfPrintableAscii() { - assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii(null)); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii((String)null)); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii((String[])null)); assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("")); assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("abcdefghijklmnopqrstuvwxyz")); assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); @@ -53,7 +55,8 @@ public class VCardUtilsTests extends TestCase { } public void testContainsOnlyAlphaDigitHyphen() { - assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen(null)); + assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen((String)null)); + assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen((String[])null)); assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen("")); assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("abcdefghijklmnopqrstuvwxyz")); assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); |