+ doTestResult("tel:+15551212", "+15551212", ParsedResultType.TEL);
+ doTestResult("TEL:+15551212", "+15551212", ParsedResultType.TEL);
+ doTestResult("tel:212 555 1212", "212 555 1212", ParsedResultType.TEL);
+ doTestResult("tel:2125551212", "2125551212", ParsedResultType.TEL);
+ doTestResult("tel:212-555-1212", "212-555-1212", ParsedResultType.TEL);
+ doTestResult("tel", "tel", ParsedResultType.TEXT);
+ doTestResult("telephone", "telephone", ParsedResultType.TEXT);
+ }
+
+ @Test
+ public void testVCard() {
+ doTestResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedResultType.ADDRESSBOOK);
+ doTestResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
+ ParsedResultType.ADDRESSBOOK);
+ doTestResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
+ ParsedResultType.ADDRESSBOOK);
+ doTestResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
+ "Sean Owen\n123 Main St", ParsedResultType.ADDRESSBOOK);
+ doTestResult("BEGIN:VCARD", "", ParsedResultType.ADDRESSBOOK);
+ }
+
+ @Test
+ public void testVEvent() {
+ // UTC times
+ doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
+ "DTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR",
+ "foo\n20080504T123456Z\n20080505T234555Z",
+ ParsedResultType.CALENDAR);
+ doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
+ "DTEND:20080505T234555Z\r\nEND:VEVENT", "foo\n20080504T123456Z\n20080505T234555Z",
+ ParsedResultType.CALENDAR);
+ // Local times
+ doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\n" +
+ "DTEND:20080505T234555\r\nEND:VEVENT", "foo\n20080504T123456\n20080505T234555",
+ ParsedResultType.CALENDAR);
+ // Date only (all day event)
+ doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\n" +
+ "DTEND:20080505\r\nEND:VEVENT", "foo\n20080504\n20080505", ParsedResultType.CALENDAR);
+ // Start time only
+ doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT",
+ "foo\n20080504T123456Z\n20080504T123456Z", ParsedResultType.CALENDAR);
+ doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT",
+ "foo\n20080504T123456\n20080504T123456", ParsedResultType.CALENDAR);
+ doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
+ "foo\n20080504\n20080504", ParsedResultType.CALENDAR);
+ doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT",
+ "BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT);
+ // Make sure illegal entries without newlines don't crash
+ doTestResult(
+ "BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
+ "begin:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
+ ParsedResultType.URI);
+ // See above note on why this is URI
+ doTestResult("BEGIN:VEVENT", "begin:VEVENT", ParsedResultType.URI);
+ }
+
+ @Test
+ public void testSMS() {
+ doTestResult("sms:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("SMS:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("sms:+15551212;via=999333", "+15551212", ParsedResultType.SMS);
+ doTestResult("sms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS);
+ doTestResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS);
+ }
+
+ @Test
+ public void testSMSTO() {
+ doTestResult("SMSTO:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("smsto:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("smsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS);
+ doTestResult("smsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS);
+ // Need to handle question mark in the subject
+ doTestResult("smsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS);
+ // Need to handle colon in the subject
+ doTestResult("smsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
+ ParsedResultType.SMS);
+ doTestResult("smsto:212-555-1212:Here's a longer message. Should be fine.",
+ "212-555-1212\nHere's a longer message. Should be fine.",
+ ParsedResultType.SMS);
+ }
+
+ @Test
+ public void testMMS() {
+ doTestResult("mms:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("MMS:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("mms:+15551212;via=999333", "+15551212", ParsedResultType.SMS);
+ doTestResult("mms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS);
+ doTestResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS);
+ }
+
+ @Test
+ public void testMMSTO() {
+ doTestResult("MMSTO:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("mmsto:+15551212", "+15551212", ParsedResultType.SMS);
+ doTestResult("mmsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS);
+ doTestResult("mmsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS);
+ doTestResult("mmsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS);
+ doTestResult("mmsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
+ ParsedResultType.SMS);
+ doTestResult("mmsto:212-555-1212:Here's a longer message. Should be fine.",
+ "212-555-1212\nHere's a longer message. Should be fine.", ParsedResultType.SMS);