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 org.junit.Assert;
22 import org.junit.Test;
25 * Tests {@link CalendarParsedResult}.
29 public final class CalendarParsedResultTestCase extends Assert {
32 public void testStartEnd() {
34 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
35 "DTSTART:20080504T123456Z\r\n" +
36 "DTEND:20080505T234555Z\r\n" +
37 "END:VEVENT\r\nEND:VCALENDAR",
38 null, null, null, "20080504T123456Z", "20080505T234555Z", null);
42 public void testStart() {
44 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
45 "DTSTART:20080504T123456Z\r\n" +
46 "END:VEVENT\r\nEND:VCALENDAR",
47 null, null, null, "20080504T123456Z", "20080504T123456Z", null);
51 public void testSummary() {
53 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
55 "DTSTART:20080504T123456Z\r\n" +
56 "END:VEVENT\r\nEND:VCALENDAR",
57 null, "foo", null, "20080504T123456Z", "20080504T123456Z", null);
61 public void testLocation() {
63 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
64 "LOCATION:Miami\r\n" +
65 "DTSTART:20080504T123456Z\r\n" +
66 "END:VEVENT\r\nEND:VCALENDAR",
67 null, null, "Miami", "20080504T123456Z", "20080504T123456Z", null);
71 public void testDescription() {
73 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
74 "DTSTART:20080504T123456Z\r\n" +
75 "DESCRIPTION:This is a test\r\n" +
76 "END:VEVENT\r\nEND:VCALENDAR",
77 "This is a test", null, null, "20080504T123456Z", "20080504T123456Z", null);
79 "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
80 "DTSTART:20080504T123456Z\r\n" +
81 "DESCRIPTION:This is a test\r\n\t with a continuation\r\n" +
82 "END:VEVENT\r\nEND:VCALENDAR",
83 "This is a test with a continuation", null, null, "20080504T123456Z", "20080504T123456Z", null);
86 private static void doTest(String contents,
93 Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
94 ParsedResult result = ResultParser.parseResult(fakeResult);
95 assertSame(ParsedResultType.CALENDAR, result.getType());
96 CalendarParsedResult calResult = (CalendarParsedResult) result;
97 assertEquals(description, calResult.getDescription());
98 assertEquals(summary, calResult.getSummary());
99 assertEquals(location, calResult.getLocation());
100 assertEquals(start, calResult.getStart());
101 assertEquals(end, calResult.getEnd());
102 assertEquals(attendee, calResult.getAttendee());