2 * Copyright 2007 ZXing authors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.google.zxing.client.result;
19 import com.google.zxing.BarcodeFormat;
20 import com.google.zxing.Result;
21 import junit.framework.TestCase;
24 * Tests {@link CalendarParsedResult}.
28 public final class CalendarParsedResultTestCase extends TestCase {
30 public void testStartEnd() {
32 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
33 "DTSTART:20080504T123456Z\r\n" +
34 "DTEND:20080505T234555Z\r\n" +
35 "END:VEVENT\r\nEND:VCALENDAR",
36 null, null, null, "20080504T123456Z", "20080505T234555Z", null);
39 public void testStart() {
41 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
42 "DTSTART:20080504T123456Z\r\n" +
43 "END:VEVENT\r\nEND:VCALENDAR",
44 null, null, null, "20080504T123456Z", "20080504T123456Z", null);
47 public void testSummary() {
49 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
51 "DTSTART:20080504T123456Z\r\n" +
52 "END:VEVENT\r\nEND:VCALENDAR",
53 null, "foo", null, "20080504T123456Z", "20080504T123456Z", null);
56 public void testLocation() {
58 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
59 "LOCATION:Miami\r\n" +
60 "DTSTART:20080504T123456Z\r\n" +
61 "END:VEVENT\r\nEND:VCALENDAR",
62 null, null, "Miami", "20080504T123456Z", "20080504T123456Z", null);
65 public void testDescription() {
67 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
68 "DTSTART:20080504T123456Z\r\n" +
69 "DESCRIPTION:This is a test\r\n" +
70 "END:VEVENT\r\nEND:VCALENDAR",
71 "This is a test", null, null, "20080504T123456Z", "20080504T123456Z", null);
73 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
74 "DTSTART:20080504T123456Z\r\n" +
75 "DESCRIPTION:This is a test\r\n\t with a continuation\r\n" +
76 "END:VEVENT\r\nEND:VCALENDAR",
77 "This is a test with a continuation", null, null, "20080504T123456Z", "20080504T123456Z", null);
80 private static void doTest(String contents,
87 Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
88 ParsedResult result = ResultParser.parseResult(fakeResult);
89 assertSame(ParsedResultType.CALENDAR, result.getType());
90 CalendarParsedResult calResult = (CalendarParsedResult) result;
91 assertEquals(description, calResult.getDescription());
92 assertEquals(summary, calResult.getSummary());
93 assertEquals(location, calResult.getLocation());
94 assertEquals(start, calResult.getStart());
95 assertEquals(end, calResult.getEnd());
96 assertEquals(attendee, calResult.getAttendee());