VCardImporterTests.java revision f4d2a98d3088641e86fed2ca26ca368b289a9aec
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
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
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16package com.android.vcard.tests;
17
18import android.content.ContentValues;
19import android.provider.ContactsContract.CommonDataKinds.Email;
20import android.provider.ContactsContract.CommonDataKinds.Event;
21import android.provider.ContactsContract.CommonDataKinds.Im;
22import android.provider.ContactsContract.CommonDataKinds.Nickname;
23import android.provider.ContactsContract.CommonDataKinds.Note;
24import android.provider.ContactsContract.CommonDataKinds.Organization;
25import android.provider.ContactsContract.CommonDataKinds.Phone;
26import android.provider.ContactsContract.CommonDataKinds.Photo;
27import android.provider.ContactsContract.CommonDataKinds.SipAddress;
28import android.provider.ContactsContract.CommonDataKinds.StructuredName;
29import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
30import android.provider.ContactsContract.CommonDataKinds.Website;
31import android.provider.ContactsContract.Data;
32
33import com.android.vcard.VCardConfig;
34import com.android.vcard.tests.testutils.ContentValuesVerifier;
35import com.android.vcard.tests.testutils.ContentValuesVerifierElem;
36import com.android.vcard.tests.testutils.PropertyNodesVerifierElem.TypeSet;
37import com.android.vcard.tests.testutils.VCardTestsBase;
38
39import java.util.Arrays;
40
41public class VCardImporterTests extends VCardTestsBase {
42    // Push data into int array at first since values like 0x80 are
43    // interpreted as int by the compiler and casting all of them is
44    // cumbersome...
45    private static final int[] sPhotoIntArrayForComplicatedCase = {
46        0xff, 0xd8, 0xff, 0xe1, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x66, 0x00,
47        0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0d,
48        0x01, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
49        0xaa, 0x01, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
50        0x00, 0xba, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00,
51        0x00, 0x00, 0xc2, 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01,
52        0x00, 0x01, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00,
53        0x01, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00,
54        0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x28, 0x00, 0x03, 0x00,
55        0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02,
56        0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xd8, 0x01, 0x32, 0x00,
57        0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xe6, 0x02, 0x13,
58        0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x82,
59        0x98, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xfa,
60        0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
61        0x84, 0xc4, 0xa5, 0x00, 0x07, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
62        0x01, 0x08, 0x00, 0x00, 0x04, 0x1e, 0x32, 0x30, 0x30, 0x38, 0x31,
63        0x30, 0x32, 0x39, 0x31, 0x33, 0x35, 0x35, 0x33, 0x31, 0x00, 0x00,
64        0x44, 0x6f, 0x43, 0x6f, 0x4d, 0x6f, 0x00, 0x00, 0x44, 0x39, 0x30,
65        0x35, 0x69, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01,
66        0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x44, 0x39, 0x30,
67        0x35, 0x69, 0x20, 0x56, 0x65, 0x72, 0x31, 0x2e, 0x30, 0x30, 0x00,
68        0x32, 0x30, 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20,
69        0x31, 0x33, 0x3a, 0x35, 0x35, 0x3a, 0x34, 0x37, 0x00, 0x20, 0x20,
70        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
71        0x00, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x49, 0x4d, 0x00, 0x30, 0x33,
72        0x30, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x14, 0x00,
73        0x14, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
74        0x00, 0x34, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
75        0x00, 0x00, 0x00, 0x01, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
76        0x11, 0x09, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x0f, 0x0b, 0x00,
77        0x00, 0x27, 0x10, 0x00, 0x00, 0x05, 0x97, 0x00, 0x00, 0x27, 0x10,
78        0x00, 0x00, 0x08, 0xb0, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x1c,
79        0x01, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x02, 0x5e, 0x00, 0x00,
80        0x27, 0x10, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x27, 0x10, 0x00,
81        0x00, 0x03, 0xcb, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x1b, 0xe5,
82        0x00, 0x00, 0x27, 0x10, 0x00, 0x28, 0x82, 0x9a, 0x00, 0x05, 0x00,
83        0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x6a, 0x82, 0x9d, 0x00, 0x05,
84        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x72, 0x88, 0x22, 0x00,
85        0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x90, 0x00,
86        0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, 0x32, 0x32, 0x30, 0x90,
87        0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x03, 0x7a,
88        0x90, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x03,
89        0x8e, 0x91, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x01, 0x02,
90        0x03, 0x00, 0x91, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00,
91        0x00, 0x03, 0xa2, 0x92, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01,
92        0x00, 0x00, 0x03, 0xaa, 0x92, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
93        0x01, 0x00, 0x00, 0x03, 0xb2, 0x92, 0x04, 0x00, 0x0a, 0x00, 0x00,
94        0x00, 0x01, 0x00, 0x00, 0x03, 0xba, 0x92, 0x05, 0x00, 0x05, 0x00,
95        0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xc2, 0x92, 0x07, 0x00, 0x03,
96        0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x92, 0x08, 0x00,
97        0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09,
98        0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92,
99        0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xca,
100        0x92, 0x7c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
101        0x00, 0x92, 0x86, 0x00, 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00,
102        0x03, 0xd2, 0xa0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30,
103        0x31, 0x30, 0x30, 0xa0, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01,
104        0x00, 0x01, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00,
105        0x01, 0x00, 0x60, 0x00, 0x00, 0xa0, 0x03, 0x00, 0x03, 0x00, 0x00,
106        0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x04, 0x00,
107        0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0xa2, 0x0e, 0x00, 0x05,
108        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe8, 0xa2, 0x0f, 0x00,
109        0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xf0, 0xa2, 0x10,
110        0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0xa2,
111        0x17, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00,
112        0xa3, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
113        0x00, 0xa3, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
114        0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00,
115        0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01,
116        0x00, 0x00, 0x00, 0x00, 0xa4, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
117        0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x04, 0x00, 0x05, 0x00, 0x00,
118        0x00, 0x01, 0x00, 0x00, 0x03, 0xf8, 0xa4, 0x05, 0x00, 0x03, 0x00,
119        0x00, 0x00, 0x01, 0x00, 0x1d, 0x00, 0x00, 0xa4, 0x06, 0x00, 0x03,
120        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x07, 0x00,
121        0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x08,
122        0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4,
123        0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
124        0xa4, 0x0a, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
125        0x00, 0xa4, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
126        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00,
127        0x00, 0x27, 0x10, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, 0x64,
128        0x32, 0x30, 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20,
129        0x31, 0x33, 0x3a, 0x35, 0x35, 0x3a, 0x33, 0x31, 0x00, 0x32, 0x30,
130        0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, 0x31, 0x33,
131        0x3a, 0x35, 0x35, 0x3a, 0x34, 0x37, 0x00, 0x00, 0x00, 0x29, 0x88,
132        0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0xb2, 0x00, 0x00, 0x00,
133        0x64, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
134        0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x25, 0x00,
135        0x00, 0x00, 0x0a, 0x00, 0x00, 0x0e, 0x92, 0x00, 0x00, 0x03, 0xe8,
136        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x30, 0x30,
137        0x38, 0x31, 0x30, 0x32, 0x39, 0x31, 0x33, 0x35, 0x35, 0x33, 0x31,
138        0x00, 0x00, 0x20, 0x2a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x2a,
139        0xe2, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140        0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
141        0x04, 0x52, 0x39, 0x38, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00,
142        0x00, 0x04, 0x30, 0x31, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
143        0x06, 0x01, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06,
144        0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00,
145        0x00, 0x04, 0x6c, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01,
146        0x00, 0x00, 0x04, 0x74, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00,
147        0x01, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x00,
148        0x00, 0x01, 0x00, 0x00, 0x04, 0x7c, 0x02, 0x02, 0x00, 0x04, 0x00,
149        0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0x8b, 0x00, 0x00, 0x00, 0x00,
150        0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
151        0x48, 0x00, 0x00, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84,
152        0x00, 0x20, 0x16, 0x18, 0x1c, 0x18, 0x14, 0x20, 0x1c, 0x1a, 0x1c,
153        0x24, 0x22, 0x20, 0x26, 0x30, 0x50, 0x34, 0x30, 0x2c, 0x2c, 0x30,
154        0x62, 0x46, 0x4a, 0x3a, 0x50, 0x74, 0x66, 0x7a, 0x78, 0x72, 0x66,
155        0x70, 0x6e, 0x80, 0x90, 0xb8, 0x9c, 0x80, 0x88, 0xae, 0x8a, 0x6e,
156        0x70, 0xa0, 0xda, 0xa2, 0xae, 0xbe, 0xc4, 0xce, 0xd0, 0xce, 0x7c,
157        0x9a, 0xe2, 0xf2, 0xe0, 0xc8, 0xf0, 0xb8, 0xca, 0xce, 0xc6, 0x01,
158        0x22, 0x24, 0x24, 0x30, 0x2a, 0x30, 0x5e, 0x34, 0x34, 0x5e, 0xc6,
159        0x84, 0x70, 0x84, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
160        0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
161        0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
162        0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
163        0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xff, 0xc0,
164        0x00, 0x11, 0x08, 0x00, 0x78, 0x00, 0xa0, 0x03, 0x01, 0x21, 0x00,
165        0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x01, 0xa2, 0x00,
166        0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
167        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
168        0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03,
169        0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01,
170        0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31,
171        0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81,
172        0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
173        0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19,
174        0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37,
175        0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
176        0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65,
177        0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
178        0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92,
179        0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4,
180        0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
181        0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
182        0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
183        0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1,
184        0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x01, 0x00,
185        0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
186        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
187        0x07, 0x08, 0x09, 0x0a, 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04,
188        0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77,
189        0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12,
190        0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14,
191        0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15,
192        0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17,
193        0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37,
194        0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
195        0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65,
196        0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
197        0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
198        0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
199        0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5,
200        0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
201        0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
202        0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2,
203        0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00,
204        0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00,
205        0x14, 0x54, 0xaa, 0x2a, 0x46, 0x48, 0xa2, 0xa4, 0x55, 0xa6, 0x04,
206        0x8a, 0x29, 0xe0, 0x53, 0x10, 0xe0, 0x29, 0xc0, 0x50, 0x03, 0xb1,
207        0x46, 0x29, 0x80, 0x84, 0x52, 0x11, 0x40, 0x0d, 0x22, 0x9a, 0x45,
208        0x20, 0x23, 0x61, 0x51, 0x30, 0xa0, 0x08, 0xc8, 0xa8, 0xd8, 0x52,
209        0x02, 0x26, 0x15, 0x0b, 0x0a, 0x00, 0xb4, 0xa2, 0xa5, 0x5a, 0x00,
210        0x91, 0x45, 0x4a, 0xa2, 0x81, 0x92, 0x01, 0x4e, 0x02, 0x98, 0x87,
211        0x0a, 0x70, 0xa0, 0x07, 0x62, 0x8c, 0x50, 0x21, 0x0d, 0x25, 0x00,
212        0x34, 0x8a, 0x61, 0x14, 0x0c, 0x63, 0x0a, 0x89, 0x85, 0x00, 0x46,
213        0xd5, 0x1b, 0x52, 0x02, 0x16, 0xa8, 0x98, 0x50, 0x05, 0x94, 0xa9,
214        0x16, 0x80, 0x25, 0x5a, 0x95, 0x68, 0x18, 0xf1, 0x4f, 0x14, 0xc4,
215        0x3b, 0xb5, 0x22, 0xb6, 0x38, 0x34, 0x00, 0xe3, 0x22, 0x8e, 0xf4,
216        0x79, 0x8a, 0x7b, 0xd1, 0x71, 0x03, 0x30, 0xc7, 0x14, 0x83, 0xa5,
217        0x00, 0x06, 0x98, 0x68, 0x01, 0x8d, 0x51, 0x35, 0x03, 0x22, 0x6a,
218        0x8d, 0xa9, 0x01, 0x13, 0x54, 0x4d, 0x40, 0x13, 0xa5, 0x4a, 0x28,
219        0x02, 0x45, 0x35, 0x2a, 0x9a, 0x00, 0x78, 0x34, 0xf0, 0x69, 0x80,
220        0x34, 0x81, 0x45, 0x40, 0xce, 0x58, 0xe6, 0xa2, 0x4c, 0x06, 0xe4,
221        0xfa, 0xd1, 0x93, 0x50, 0x21, 0xca, 0xe4, 0x55, 0x84, 0x90, 0x30,
222        0xab, 0x8b, 0x18, 0xa6, 0x9a, 0x6a, 0xc4, 0x31, 0xaa, 0x26, 0xa0,
223        0x64, 0x4d, 0x51, 0xb5, 0x20, 0x23, 0x6a, 0x89, 0xa8, 0x02, 0x44,
224        0x35, 0x2a, 0x9a, 0x00, 0x95, 0x4d, 0x48, 0xa6, 0x80, 0x24, 0x53,
225        0x4e, 0xce, 0x05, 0x30, 0x2b, 0x3b, 0xee, 0x6a, 0x91, 0x5d, 0x76,
226        0x63, 0xbd, 0x65, 0x7d, 0x40, 0x66, 0x68, 0xa9, 0x02, 0x45, 0x2b,
227        0xb3, 0x9e, 0xb4, 0xc5, 0x6d, 0xad, 0x9a, 0xa0, 0x2c, 0x06, 0xc8,
228        0xcd, 0x04, 0xd6, 0xa2, 0x23, 0x63, 0x51, 0xb1, 0xa0, 0x64, 0x4d,
229        0x51, 0x93, 0x48, 0x08, 0xda, 0xa2, 0x6a, 0x00, 0x72, 0x1a, 0x99,
230        0x4d, 0x00, 0x48, 0xa6, 0xa4, 0x53, 0x4c, 0x07, 0x86, 0x03, 0xbd,
231        0x2b, 0x9c, 0xa7, 0x14, 0x98, 0x10, 0x85, 0x34, 0xe0, 0xa6, 0xb3,
232        0xb0, 0x0b, 0xb5, 0xa8, 0x0a, 0xd4, 0x58, 0x42, 0xed, 0x3e, 0x94,
233        0xd2, 0xa6, 0x8b, 0x01, 0x34, 0x44, 0xed, 0xe6, 0x9c, 0x4d, 0x6a,
234        0x80, 0x8d, 0x8d, 0x46, 0xc6, 0x80, 0x23, 0x63, 0x51, 0x9a, 0x06,
235        0x46, 0xd5, 0x13, 0x52, 0x01, 0x54, 0xd4, 0xaa, 0x68, 0x02, 0x40,
236        0x6a, 0x40, 0x78, 0xa0, 0x08, 0x59, 0xce, 0xee, 0xb5, 0x2a, 0x39,
237        0xd9, 0x59, 0xa7, 0xa8, 0x00, 0x73, 0xeb, 0x4e, 0x0e, 0x7d, 0x69,
238        0x5c, 0x05, 0xf3, 0x0f, 0xad, 0x1e, 0x61, 0xf5, 0xa7, 0x71, 0x0b,
239        0xe6, 0x35, 0x21, 0x90, 0xd3, 0xb8, 0x0e, 0x32, 0x10, 0x95, 0x10,
240        0x91, 0xb3, 0xd6, 0x9b, 0x60, 0x4b, 0x9c, 0x8a, 0x63, 0x1a, 0xb0,
241        0x18, 0x4d, 0x46, 0xc6, 0x80, 0x22, 0x6a, 0x61, 0xa4, 0x31, 0xaa,
242        0x6a, 0x55, 0x34, 0x01, 0x2a, 0x9a, 0x7e, 0x78, 0xa0, 0x08, 0x09,
243        0xf9, 0xaa, 0x58, 0xcf, 0xca, 0x6b, 0x3e, 0xa0, 0x00, 0xd3, 0x81,
244        0xa9, 0x01, 0x73, 0x46, 0x69, 0x80, 0xb9, 0xa4, 0xcd, 0x00, 0x2b,
245        0x1f, 0x92, 0xa3, 0x07, 0x9a, 0x6f, 0x70, 0x26, 0xcf, 0x14, 0xd2,
246        0x6b, 0x51, 0x0c, 0x63, 0x51, 0xb1, 0xa0, 0x08, 0xda, 0x98, 0x69,
247        0x0c, 0x8d, 0x4d, 0x4a, 0xa6, 0x80, 0x24, 0x53, 0x52, 0x03, 0xc5,
248        0x02, 0x21, 0x27, 0xe6, 0xa9, 0x23, 0x3f, 0x29, 0xac, 0xfa, 0x8c,
249        0x01, 0xe6, 0x9c, 0x0d, 0x48, 0x0a, 0x0d, 0x2e, 0x68, 0x01, 0x73,
250        0x49, 0x9a, 0x60, 0x2b, 0x1f, 0x92, 0x98, 0x3a, 0xd3, 0x7b, 0x81,
251        0x36, 0x78, 0xa6, 0x93, 0x5a, 0x88, 0x8c, 0x9a, 0x63, 0x1a, 0x00,
252        0x8c, 0xd3, 0x0d, 0x21, 0x91, 0x29, 0xa9, 0x14, 0xd0, 0x04, 0x8a,
253        0x69, 0xe0, 0xd3, 0x11, 0x1b, 0x1e, 0x6a, 0x48, 0xcf, 0xca, 0x6b,
254        0x3e, 0xa3, 0x10, 0x1a, 0x70, 0x35, 0x20, 0x38, 0x1a, 0x5c, 0xd2,
255        0x01, 0x73, 0x49, 0x9a, 0x60, 0x39, 0x8f, 0xca, 0x29, 0x8b, 0xf7,
256        0xaa, 0xba, 0x88, 0x96, 0x9a, 0x6b, 0x40, 0x18, 0xc6, 0xa3, 0x26,
257        0x80, 0x18, 0x69, 0xa6, 0x90, 0xc8, 0x14, 0xd4, 0x8a, 0x69, 0x80,
258        0xf0, 0x6a, 0x40, 0x68, 0x10, 0xbb, 0x41, 0xa7, 0xe3, 0x0b, 0xc5,
259        0x2b, 0x01, 0x10, 0xa7, 0x03, 0x59, 0x0c, 0x76, 0x69, 0x73, 0x40,
260        0x0b, 0x9a, 0x28, 0x11, 0x28, 0x19, 0x5e, 0x69, 0x02, 0x81, 0x5a,
261        0xd8, 0x00, 0xd3, 0x4d, 0x50, 0x0c, 0x6a, 0x8c, 0xd2, 0x01, 0xa6,
262        0x98, 0x69, 0x0c, 0xae, 0xa6, 0xa4, 0x06, 0x80, 0x1e, 0xa6, 0x9e,
263        0x0d, 0x31, 0x12, 0x03, 0x4f, 0x06, 0x80, 0x13, 0x60, 0x34, 0xd3,
264        0xc1, 0xa8, 0x92, 0x01, 0xf1, 0x8d, 0xdd, 0x69, 0xcc, 0xa1, 0x69,
265        0x5b, 0x4b, 0x80, 0x83, 0x93, 0x52, 0x04, 0x14, 0xe2, 0xae, 0x03,
266        0xa9, 0x0d, 0x68, 0x03, 0x4d, 0x34, 0xd0, 0x03, 0x0d, 0x30, 0xd2,
267        0x01, 0x86, 0x9a, 0x68, 0x19, 0x58, 0x1a, 0x78, 0xa4, 0x04, 0x8a,
268        0x69, 0xe0, 0xd3, 0x10, 0xe0, 0x69, 0xe0, 0xd0, 0x03, 0xc1, 0xa8,
269        0xdb, 0xad, 0x4c, 0x81, 0x12, 0x45, 0xd6, 0x9d, 0x25, 0x1d, 0x00,
270        0x6a, 0xf5, 0xa9, 0xe8, 0x80, 0x31, 0x29, 0x0d, 0x58, 0x08, 0x69,
271        0x86, 0x80, 0x1a, 0x69, 0x86, 0x90, 0x0c, 0x34, 0xd3, 0x48, 0x65,
272        0x51, 0x4f, 0x06, 0x98, 0x0f, 0x14, 0xf0, 0x68, 0x10, 0xf0, 0x69,
273        0xe0, 0xd0, 0x03, 0x81, 0xa5, 0x2b, 0x9a, 0x1a, 0xb8, 0x87, 0xa8,
274        0xdb, 0x4a, 0x46, 0x68, 0xb6, 0x80, 0x2a, 0xa8, 0x14, 0xea, 0x12,
275        0xb0, 0x05, 0x21, 0xa6, 0x02, 0x1a, 0x61, 0xa0, 0x06, 0x9a, 0x61,
276        0xa4, 0x31, 0x86, 0x9a, 0x69, 0x0c, 0xa8, 0x0d, 0x3c, 0x53, 0x01,
277        0xe2, 0x9e, 0x28, 0x10, 0xf1, 0x4e, 0x06, 0x98, 0x0f, 0x06, 0x9e,
278        0x0d, 0x02, 0x1c, 0x29, 0xc2, 0x80, 0x16, 0x96, 0x80, 0x0a, 0x4a,
279        0x00, 0x43, 0x4d, 0x34, 0x0c, 0x61, 0xa6, 0x1a, 0x40, 0x34, 0xd3,
280        0x4d, 0x21, 0x80, 0xff, 0xd9, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0a,
281        0x07, 0x07, 0x08, 0x07, 0x06, 0x0a, 0x08, 0x08, 0x08, 0x0b, 0x0a,
282        0x0a, 0x0b, 0x0e, 0x18, 0x10, 0x0e, 0x0d, 0x0d, 0x0e, 0x1d, 0x15,
283        0x16, 0x11, 0x18, 0x23, 0x1f, 0x25, 0x24, 0x22, 0x1f, 0x22, 0x21,
284        0x26, 0x2b, 0x37, 0x2f, 0x26, 0x29, 0x34, 0x29, 0x21, 0x22, 0x30,
285        0x41, 0x31, 0x34, 0x39, 0x3b, 0x3e, 0x3e, 0x3e, 0x25, 0x2e, 0x44,
286        0x49, 0x43, 0x3c, 0x48, 0x37, 0x3d, 0x3e, 0x3b, 0x01, 0x0a, 0x0b,
287        0x0b, 0x0e, 0x0d, 0x0e, 0x1c, 0x10, 0x10, 0x1c, 0x3b, 0x28, 0x22,
288        0x28, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
289        0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
290        0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
291        0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
292        0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0xff, 0xc0, 0x00, 0x11,
293        0x08, 0x00, 0x48, 0x00, 0x60, 0x03, 0x01, 0x21, 0x00, 0x02, 0x11,
294        0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x01,
295        0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
296        0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
297        0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02,
298        0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01,
299        0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06,
300        0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1,
301        0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33,
302        0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25,
303        0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
304        0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54,
305        0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67,
306        0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
307        0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
308        0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
309        0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
310        0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca,
311        0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
312        0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3,
313        0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x01, 0x00, 0x03, 0x01,
314        0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
315        0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
316        0x09, 0x0a, 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03,
317        0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01,
318        0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51,
319        0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
320        0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72,
321        0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
322        0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39,
323        0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54,
324        0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67,
325        0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
326        0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93,
327        0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
328        0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
329        0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
330        0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2,
331        0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4,
332        0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03,
333        0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x9e, 0xd2,
334        0x2e, 0x07, 0x15, 0xaf, 0x6d, 0x08, 0xe2, 0xb3, 0x45, 0x1a, 0xf6,
335        0xd0, 0x00, 0x01, 0xc5, 0x68, 0x45, 0x17, 0x4a, 0xb4, 0x22, 0xe4,
336        0x70, 0x8c, 0x74, 0xa9, 0x3c, 0xa1, 0x8e, 0x95, 0x48, 0x96, 0x31,
337        0xe2, 0x18, 0xe9, 0x55, 0xa5, 0x8c, 0x7a, 0x50, 0x05, 0x0b, 0x88,
338        0x86, 0x0f, 0x15, 0x8f, 0x75, 0x1f, 0x26, 0x93, 0x19, 0x91, 0x77,
339        0x18, 0xc1, 0xac, 0x4b, 0xc8, 0xfa, 0xd6, 0x63, 0x37, 0x6d, 0x31,
340        0xb4, 0x73, 0x5b, 0x36, 0xa0, 0x1c, 0x50, 0x80, 0xd7, 0x83, 0xa0,
341        0xab, 0xd1, 0x62, 0xad, 0x09, 0x8f, 0x17, 0x29, 0x03, 0xb2, 0xcc,
342        0xe0, 0x77, 0x14, 0xa3, 0x56, 0xb3, 0x27, 0x1e, 0x67, 0xe9, 0x52,
343        0xea, 0xc6, 0x3a, 0x36, 0x48, 0xef, 0x3d, 0x27, 0x70, 0x22, 0x60,
344        0x47, 0x52, 0x69, 0xb2, 0xe2, 0xad, 0x3b, 0xea, 0x80, 0xa3, 0x38,
345        0xe0, 0xd6, 0x3d, 0xd8, 0x1c, 0xd0, 0xca, 0x46, 0x3d, 0xd0, 0x18,
346        0x35, 0x89, 0x78, 0xa3, 0x9a, 0xcd, 0x8c, 0xd2, 0xb3, 0x93, 0x2a,
347        0x2b, 0x66, 0xd5, 0xf1, 0x8a, 0x10, 0x1a, 0xd6, 0xf2, 0x03, 0x8a,
348        0x9e, 0xe6, 0xf4, 0x5a, 0xdb, 0xef, 0xfe, 0x23, 0xc0, 0xa7, 0x27,
349        0xcb, 0x16, 0xc4, 0xcc, 0xdd, 0xe2, 0x78, 0x9a, 0x69, 0x66, 0xcc,
350        0x99, 0xe1, 0x4d, 0x47, 0xba, 0xbc, 0xd9, 0x6a, 0xee, 0x26, 0x59,
351        0x59, 0x4d, 0xac, 0x69, 0x34, 0x52, 0xe5, 0x8f, 0x55, 0xad, 0x58,
352        0xae, 0x85, 0xc4, 0x22, 0x41, 0xdf, 0xad, 0x76, 0x61, 0xe5, 0x6f,
353        0x74, 0x45, 0x69, 0xdc, 0x00, 0x79, 0xac, 0x8b, 0xa6, 0xc9, 0x35,
354        0xd4, 0x34, 0x64, 0xdc, 0x37, 0x06, 0xb1, 0xae, 0x88, 0xc1, 0xac,
355        0xd8, 0xc9, 0x2c, 0xa6, 0xe0, 0x73, 0x5b, 0x36, 0xf3, 0x74, 0xe6,
356        0x84, 0x05, 0xe3, 0xa9, 0x47, 0x6a, 0x14, 0xb6, 0x49, 0x3d, 0x85,
357        0x3a, 0xee, 0xee, 0x2b, 0xa8, 0xe2, 0x6f, 0x30, 0x81, 0xe9, 0x8a,
358        0xca, 0xa4, 0xe2, 0xd3, 0x8b, 0x01, 0xb1, 0xf9, 0x04, 0x7f, 0xaf,
359        0x23, 0xf0, 0xa9, 0x54, 0x41, 0x9c, 0xfd, 0xa3, 0xf4, 0xae, 0x65,
360        0x18, 0xf7, 0x25, 0x8a, 0xe2, 0x02, 0x38, 0xb8, 0xfd, 0x2a, 0x7b,
361        0x5b, 0xa8, 0x6d, 0x6d, 0x5d, 0x9a, 0x5d, 0xcb, 0xbb, 0xd2, 0xb6,
362        0xa6, 0xa3, 0x19, 0x5e, 0xe2, 0x03, 0x7b, 0x1d, 0xc2, 0x17, 0x8d,
363        0xb8, 0xac, 0xfb, 0x89, 0x39, 0x35, 0xd6, 0x9a, 0x6a, 0xe8, 0x66,
364        0x55, 0xcb, 0xf5, 0xac, 0x7b, 0x96, 0xeb, 0x50, 0xc6, 0x88, 0x6d,
365        0x66, 0xe9, 0xcd, 0x6c, 0xdb, 0x4f, 0xd3, 0x9a, 0x00, 0x2f, 0xe6,
366        0xf9, 0xa3, 0xe7, 0xb5, 0x4a, 0x93, 0x7f, 0xa2, 0xc6, 0x73, 0xdc,
367        0xd7, 0x15, 0x55, 0xef, 0x48, 0x7d, 0x09, 0x52, 0x6e, 0x3a, 0xd4,
368        0xab, 0x2f, 0xbd, 0x61, 0x16, 0x0c, 0x73, 0x49, 0xc5, 0x24, 0x92,
369        0x7f, 0xa2, 0x63, 0xfd, 0xaa, 0xd6, 0x2f, 0x71, 0x0e, 0xb1, 0x93,
370        0xf7, 0x2d, 0xf5, 0xa4, 0x9e, 0x4e, 0xb5, 0xdd, 0x4b, 0xf8, 0x68,
371        0x4c, 0xcb, 0xb9, 0x93, 0xad, 0x65, 0xce, 0xd9, 0x26, 0xa9, 0x8d,
372        0x19, 0xf6, 0xf2, 0xf4, 0xe6, 0xb5, 0xad, 0xe7, 0xc6, 0x39, 0xa0,
373        0x18, 0xeb, 0xc9, 0x77, 0x6c, 0x35, 0x2a, 0x4b, 0xfe, 0x8a, 0x9c,
374        0xff, 0x00, 0x11, 0xae, 0x3a, 0x8b, 0xde, 0x61, 0xd0, 0x9e, 0x39,
375        0xb8, 0xeb, 0x53, 0xac, 0xb9, 0xae, 0x5b, 0x00, 0xf3, 0x27, 0x14,
376        0x92, 0xc9, 0xfe, 0x8a, 0x3f, 0xde, 0x35, 0xac, 0x3a, 0x88, 0x92,
377        0xcd, 0xb1, 0x6e, 0x7d, 0xcd, 0x32, 0x67, 0xeb, 0xcd, 0x7a, 0x14,
378        0xfe, 0x04, 0x26, 0x66, 0xce, 0xf9, 0x26, 0xb3, 0xe6, 0x6e, 0xb4,
379        0xd9, 0x48, 0xc8, 0x82, 0x4e, 0x07, 0x35, 0xa7, 0x6f, 0x2f, 0x02,
380        0x9a, 0x06, 0x5f, 0x8c, 0xa4, 0x83, 0x0e, 0x32, 0x2a, 0x69, 0xe3,
381        0xdd, 0x12, 0x08, 0x97, 0x85, 0xec, 0x2a, 0x2a, 0x42, 0xf1, 0x76,
382        0x26, 0xe4, 0x6a, 0x59, 0x0e, 0x18, 0x10, 0x6a, 0xd2, 0x89, 0x02,
383        0x6e, 0x2a, 0x71, 0xeb, 0x5c, 0x1c, 0x8c, 0xa6, 0x48, 0xbb, 0xdc,
384        0x61, 0x41, 0x35, 0x72, 0x28, 0x87, 0xd9, 0xf6, 0x4a, 0xb9, 0xe7,
385        0x38, 0xae, 0x8c, 0x3d, 0x36, 0xdd, 0xde, 0xc4, 0xb0, 0x21, 0x51,
386        0x76, 0xa8, 0xc0, 0xaa, 0x93, 0x31, 0xe6, 0xbb, 0x2d, 0x65, 0x61,
387        0x19, 0xd3, 0x1e, 0xb5, 0x46, 0x5a, 0x96, 0x5a, 0x30, 0xa0, 0x7e,
388        0x05, 0x69, 0x5b, 0xc9, 0xc6, 0x28, 0x40, 0xcd, 0x08, 0x64, 0x3c,
389        0x73, 0x57, 0xe1, 0x94, 0xf1, 0xcd, 0x5a, 0x21, 0x8c, 0xb9, 0x63,
390        0xe7, 0x67, 0x1d, 0xab, 0x40, 0xb1, 0xfb, 0x00, 0x1d, 0xf0, 0x2b,
391        0x99, 0x2d, 0x66, 0x3e, 0x88, 0x75, 0x81, 0x3f, 0x31, 0xf6, 0xab,
392        0x64, 0xd6, 0xb4, 0x17, 0xee, 0xd0, 0x9e, 0xe4, 0x32, 0x1a, 0xa7,
393        0x31, 0xad, 0x18, 0x14, 0x26, 0xef, 0x54, 0xa5, 0xa8, 0x65, 0xa3,
394        0x9c, 0x81, 0xfa, 0x56, 0x8c, 0x2d, 0xce, 0x68, 0x40, 0xcb, 0xf1,
395        0x37, 0xbd, 0x5e, 0x85, 0xea, 0xd1, 0x0c, 0xbb, 0x19, 0x56, 0x23,
396        0x20, 0x1f, 0xad, 0x5c, 0x42, 0x08, 0x03, 0xb5, 0x55, 0x91, 0x04,
397        0xc9, 0x80, 0x38, 0x00, 0x0a, 0x71, 0x34, 0x6c, 0x32, 0x27, 0xe9,
398        0x55, 0x25, 0x15, 0x2c, 0x68, 0xa3, 0x30, 0xeb, 0x54, 0xa5, 0x15,
399        0x0c, 0xd1, 0x00, 0xff, 0xd9};
400
401    /* package */ static final byte[] sPhotoByteArrayForComplicatedCase;
402
403    static {
404        final int length = sPhotoIntArrayForComplicatedCase.length;
405        sPhotoByteArrayForComplicatedCase = new byte[length];
406        for (int i = 0; i < length; i++) {
407            sPhotoByteArrayForComplicatedCase[i] = (byte)sPhotoIntArrayForComplicatedCase[i];
408        }
409    }
410
411    public void testV21SimpleCase1_Parsing() {
412        mVerifier.initForImportTest(V21, R.raw.v21_simple_1);
413        mVerifier.addPropertyNodesVerifierElemWithoutVersion()  // no "VERSION:2.1" line.
414                .addExpectedNodeWithOrder("N", "Ando;Roid;", Arrays.asList("Ando", "Roid", ""));
415    }
416
417    public void testV21SimpleCase1_Type_Generic() {
418        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC, R.raw.v21_simple_1);
419        mVerifier.addContentValuesVerifierElem()
420                .addExpected(StructuredName.CONTENT_ITEM_TYPE)
421                        .put(StructuredName.FAMILY_NAME, "Ando")
422                        .put(StructuredName.GIVEN_NAME, "Roid")
423                        .put(StructuredName.DISPLAY_NAME, "Roid Ando");
424    }
425
426    public void testV21SimpleCase1_Type_Japanese() {
427        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_simple_1);
428        mVerifier.addContentValuesVerifierElem()
429                .addExpected(StructuredName.CONTENT_ITEM_TYPE)
430                        .put(StructuredName.FAMILY_NAME, "Ando")
431                        .put(StructuredName.GIVEN_NAME, "Roid")
432                        // If name-related strings only contains printable Ascii,
433                        // the order is remained to be US's:
434                        // "Prefix Given Middle Family Suffix"
435                        .put(StructuredName.DISPLAY_NAME, "Roid Ando");
436    }
437
438    public void testV21SimpleCase2() {
439        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_simple_2);
440        mVerifier.addContentValuesVerifierElem()
441                .addExpected(StructuredName.CONTENT_ITEM_TYPE)
442                        .put(StructuredName.DISPLAY_NAME, "Ando Roid");
443    }
444
445    public void testV21SimpleCase3() {
446        mVerifier.initForImportTest(V21, R.raw.v21_simple_3);
447        mVerifier.addContentValuesVerifierElem()
448                .addExpected(StructuredName.CONTENT_ITEM_TYPE)
449                        .put(StructuredName.FAMILY_NAME, "Ando")
450                        .put(StructuredName.GIVEN_NAME, "Roid")
451                        // "FN" field should be prefered since it should contain the original
452                        // order intended by the author of the file.
453                        .put(StructuredName.DISPLAY_NAME, "Ando Roid");
454    }
455
456    /**
457     * Tests ';' is properly handled by VCardParser implementation.
458     */
459    public void testV21BackslashCase_Parsing() {
460        mVerifier.initForImportTest(V21, R.raw.v21_backslash);
461        mVerifier.addPropertyNodesVerifierElem()
462                .addExpectedNodeWithOrder("N", ";A;B\\;C\\;;D;:E;\\\\;",
463                        Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", ""))
464                .addExpectedNodeWithOrder("FN", "A;B\\C\\;D:E\\\\");
465
466    }
467
468    /**
469     * Tests ContactStruct correctly ignores redundant fields in "N" property values and
470     * inserts name related data.
471     */
472    public void testV21BackslashCase() {
473        mVerifier.initForImportTest(V21, R.raw.v21_backslash);
474        mVerifier.addContentValuesVerifierElem()
475                .addExpected(StructuredName.CONTENT_ITEM_TYPE)
476                        // FAMILY_NAME is empty and removed in this test...
477                        .put(StructuredName.GIVEN_NAME, "A;B\\")
478                        .put(StructuredName.MIDDLE_NAME, "C\\;")
479                        .put(StructuredName.PREFIX, "D")
480                        .put(StructuredName.SUFFIX, ":E")
481                        .put(StructuredName.DISPLAY_NAME, "A;B\\C\\;D:E\\\\");
482    }
483
484    public void testOrgBeforTitle() {
485        mVerifier.initForImportTest(V21, R.raw.v21_org_before_title);
486        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
487        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
488                .put(StructuredName.DISPLAY_NAME, "Normal Guy");
489        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
490                .put(Organization.COMPANY, "Company")
491                .put(Organization.DEPARTMENT, "Organization Devision Room Sheet No.")
492                .put(Organization.TITLE, "Excellent Janitor")
493                .put(Organization.TYPE, Organization.TYPE_WORK);
494    }
495
496    public void testTitleBeforOrg() {
497        mVerifier.initForImportTest(V21, R.raw.v21_title_before_org);
498        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
499        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
500                .put(StructuredName.DISPLAY_NAME, "Nice Guy");
501        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
502                .put(Organization.COMPANY, "Marverous")
503                .put(Organization.DEPARTMENT, "Perfect Great Good Bad Poor")
504                .put(Organization.TITLE, "Cool Title")
505                .put(Organization.TYPE, Organization.TYPE_WORK);
506    }
507
508    /**
509     * Verifies that vCard importer correctly interpret "PREF" attribute to IS_PRIMARY.
510     * The data contain three cases: one "PREF", no "PREF" and multiple "PREF", in each type.
511     */
512    public void testV21PrefToIsPrimary() {
513        mVerifier.initForImportTest(V21, R.raw.v21_pref_handling);
514        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
515        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
516                .put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
517                .put(StructuredName.DISPLAY_NAME, "Smith");
518        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
519                .put(Phone.NUMBER, "1")
520                .put(Phone.TYPE, Phone.TYPE_HOME);
521        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
522                .put(Phone.NUMBER, "2")
523                .put(Phone.TYPE, Phone.TYPE_WORK)
524                .put(Phone.IS_PRIMARY, 1);
525        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
526                .put(Phone.NUMBER, "3")
527                .put(Phone.TYPE, Phone.TYPE_ISDN);
528        elem.addExpected(Email.CONTENT_ITEM_TYPE)
529                .put(Email.DATA, "test@example.com")
530                .put(Email.TYPE, Email.TYPE_HOME)
531                .put(Email.IS_PRIMARY, 1);
532        elem.addExpected(Email.CONTENT_ITEM_TYPE)
533                .put(Email.DATA, "test2@examination.com")
534                .put(Email.TYPE, Email.TYPE_MOBILE)
535                .put(Email.IS_PRIMARY, 1);
536        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
537                .put(Organization.COMPANY, "Company")
538                .put(Organization.TITLE, "Engineer")
539                .put(Organization.TYPE, Organization.TYPE_WORK);
540        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
541                .put(Organization.COMPANY, "Mystery")
542                .put(Organization.TITLE, "Blogger")
543                .put(Organization.TYPE, Organization.TYPE_WORK);
544        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
545                .put(Organization.COMPANY, "Poetry")
546                .put(Organization.TITLE, "Poet")
547                .put(Organization.TYPE, Organization.TYPE_WORK);
548    }
549
550    /**
551     * Tests all the properties in a complicated vCard are correctly parsed by the VCardParser for
552     * both v2.1 and v3.0 cards.
553     */
554    public void testV21ComplicatedCase_Parsing() {
555        testComplicatedCase_Parsing(V21, R.raw.v21_complicated);
556    }
557
558    public void testV30ComplicatedCase_Parsing() {
559        testComplicatedCase_Parsing(V30, R.raw.v30_complicated);
560    }
561
562    public void testComplicatedCase_Parsing(int vcardType, int resId) {
563        mVerifier.initForImportTest(vcardType, resId);
564        mVerifier.addPropertyNodesVerifierElem()
565                .addExpectedNodeWithOrder("N", "Gump;Forrest;Hoge;Pos;Tao",
566                        Arrays.asList("Gump", "Forrest", "Hoge", "Pos", "Tao"))
567                .addExpectedNodeWithOrder("FN", "Joe Due")
568                .addExpectedNodeWithOrder("ORG",
569                        "Gump Shrimp Co.;Sales Dept.;Manager;Fish keeper",
570                        Arrays.asList("Gump Shrimp Co.", "Sales Dept.;Manager", "Fish keeper"))
571                .addExpectedNodeWithOrder("ROLE", "Fish Cake Keeper!")
572                .addExpectedNodeWithOrder("TITLE", "Shrimp Man")
573                .addExpectedNodeWithOrder("X-CLASS", "PUBLIC")
574                .addExpectedNodeWithOrder("TEL", "(111) 555-1212", new TypeSet("WORK", "VOICE"))
575                .addExpectedNodeWithOrder("TEL", "(404) 555-1212", new TypeSet("HOME", "VOICE"))
576                .addExpectedNodeWithOrder("TEL", "(404) 555-1212P*#55", new TypeSet("FAX"))
577                .addExpectedNodeWithOrder("TEL", "0311111111", new TypeSet("CELL"))
578                .addExpectedNodeWithOrder("TEL", "0322222222", new TypeSet("VIDEO"))
579                .addExpectedNodeWithOrder("TEL", "0333333333", new TypeSet("VOICE"))
580                .addExpectedNodeWithOrder("ADR",
581                        ";;100 Waters Edge;Baytown;LA;30314;United States of America",
582                        Arrays.asList("", "", "100 Waters Edge", "Baytown",
583                                "LA", "30314", "United States of America"),
584                                null, null, new TypeSet("WORK"), null)
585                .addExpectedNodeWithOrder("LABEL",
586                        "100 Waters Edge\r\nBaytown, LA 30314\r\nUnited  States of America",
587                        null, null, mContentValuesForQP, new TypeSet("WORK"), null)
588                .addExpectedNodeWithOrder("ADR",
589                        ";;42 Plantation St.;Baytown;LA;30314;United States of America",
590                        Arrays.asList("", "", "42 Plantation St.", "Baytown",
591                                "LA", "30314", "United States of America"), null, null,
592                                new TypeSet("HOME"), null)
593                .addExpectedNodeWithOrder("LABEL",
594                        "42 Plantation St.\r\nBaytown, LA 30314\r\nUnited  States of America",
595                        null, null, mContentValuesForQP,
596                        new TypeSet("HOME"), null)
597                .addExpectedNodeWithOrder("EMAIL", "forrestgump@walladalla.com",
598                        new TypeSet("PREF", "INTERNET"))
599                .addExpectedNodeWithOrder("EMAIL", "cell@example.com", new TypeSet("CELL"))
600                .addExpectedNodeWithOrder("NOTE",
601                        "The following note is the example from RFC 2045.")
602                .addExpectedNodeWithOrder("NOTE",
603                        "Now's the time for all folk to come to the aid of their country.",
604                        null, null, mContentValuesForQP, null, null)
605                .addExpectedNodeWithOrder("PHOTO", null,
606                        null, sPhotoByteArrayForComplicatedCase, mContentValuesForBase64V21,
607                        new TypeSet("JPEG"), null)
608                .addExpectedNodeWithOrder("X-ATTRIBUTE", "Some String")
609                .addExpectedNodeWithOrder("BDAY", "19800101")
610                .addExpectedNodeWithOrder("GEO", "35.6563854,139.6994233")
611                .addExpectedNodeWithOrder("URL", "http://www.example.com/")
612                .addExpectedNodeWithOrder("REV", "20080424T195243Z");
613    }
614
615    /**
616     * Checks ContactStruct correctly inserts values in a complicated vCard
617     * into ContentResolver.
618     */
619    public void testV21ComplicatedCase() {
620        testComplicatedCase(V21, R.raw.v21_complicated);
621    }
622
623    public void testV30ComplicatedCase() {
624        testComplicatedCase(V30, R.raw.v30_complicated);
625    }
626    public void testComplicatedCase(int vcardType, int resId) {
627        mVerifier.initForImportTest(vcardType, resId);
628        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
629        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
630                .put(StructuredName.FAMILY_NAME, "Gump")
631                .put(StructuredName.GIVEN_NAME, "Forrest")
632                .put(StructuredName.MIDDLE_NAME, "Hoge")
633                .put(StructuredName.PREFIX, "Pos")
634                .put(StructuredName.SUFFIX, "Tao")
635                .put(StructuredName.DISPLAY_NAME, "Joe Due");
636        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
637                .put(Organization.TYPE, Organization.TYPE_WORK)
638                .put(Organization.COMPANY, "Gump Shrimp Co.")
639                .put(Organization.DEPARTMENT, "Sales Dept.;Manager Fish keeper")
640                .put(Organization.TITLE, "Shrimp Man");
641        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
642                .put(Phone.TYPE, Phone.TYPE_WORK)
643                // Phone number is expected to be formated with NAMP format in default.
644                .put(Phone.NUMBER, "111-555-1212");
645        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
646                .put(Phone.TYPE, Phone.TYPE_HOME)
647                .put(Phone.NUMBER, "404-555-1212");
648        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
649                .put(Phone.TYPE, Phone.TYPE_FAX_HOME)
650                .put(Phone.NUMBER, "4045551212,*#55");
651        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
652                .put(Phone.TYPE, Phone.TYPE_MOBILE)
653                .put(Phone.NUMBER, "031-111-1111");
654        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
655                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
656                .put(Phone.LABEL, "VIDEO")
657                .put(Phone.NUMBER, "032-222-2222");
658        // vCard's VOICE type should become OTHER type on Android devices.
659        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
660                .put(Phone.TYPE, Phone.TYPE_OTHER)
661                .put(Phone.NUMBER, "033-333-3333");
662        elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE)
663                .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK)
664                .put(StructuredPostal.COUNTRY, "United States of America")
665                .put(StructuredPostal.POSTCODE, "30314")
666                .put(StructuredPostal.REGION, "LA")
667                .put(StructuredPostal.CITY, "Baytown")
668                .put(StructuredPostal.STREET, "100 Waters Edge")
669                .put(StructuredPostal.FORMATTED_ADDRESS,
670                        "100 Waters Edge Baytown LA 30314 United States of America");
671        elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE)
672                .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME)
673                .put(StructuredPostal.COUNTRY, "United States of America")
674                .put(StructuredPostal.POSTCODE, "30314")
675                .put(StructuredPostal.REGION, "LA")
676                .put(StructuredPostal.CITY, "Baytown")
677                .put(StructuredPostal.STREET, "42 Plantation St.")
678                .put(StructuredPostal.FORMATTED_ADDRESS,
679                        "42 Plantation St. Baytown LA 30314 United States of America");
680        elem.addExpected(Email.CONTENT_ITEM_TYPE)
681                // "TYPE=INTERNET" -> TYPE_CUSTOM + the label "INTERNET"
682                .put(Email.TYPE, Email.TYPE_CUSTOM)
683                .put(Email.LABEL, "INTERNET")
684                .put(Email.DATA, "forrestgump@walladalla.com")
685                .put(Email.IS_PRIMARY, 1);
686        elem.addExpected(Email.CONTENT_ITEM_TYPE)
687                .put(Email.TYPE, Email.TYPE_MOBILE)
688                .put(Email.DATA, "cell@example.com");
689        elem.addExpected(Note.CONTENT_ITEM_TYPE)
690                .put(Note.NOTE, "The following note is the example from RFC 2045.");
691        elem.addExpected(Note.CONTENT_ITEM_TYPE)
692                .put(Note.NOTE,
693                        "Now's the time for all folk to come to the aid of their country.");
694        elem.addExpected(Photo.CONTENT_ITEM_TYPE)
695                // No information about its image format can be inserted.
696                .put(Photo.PHOTO, sPhotoByteArrayForComplicatedCase);
697        elem.addExpected(Event.CONTENT_ITEM_TYPE)
698                .put(Event.START_DATE, "19800101")
699                .put(Event.TYPE, Event.TYPE_BIRTHDAY);
700        elem.addExpected(Website.CONTENT_ITEM_TYPE)
701                .put(Website.URL, "http://www.example.com/")
702                .put(Website.TYPE, Website.TYPE_HOMEPAGE);
703    }
704
705    public void testInvalidMultipleLineV21() {
706        mVerifier.initForImportTest(V21, R.raw.v21_invalid_multiple_line);
707        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
708        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
709                .put(StructuredName.GIVEN_NAME, "Omega")
710                .put(StructuredName.DISPLAY_NAME, "Omega");
711        elem.addExpected(Email.CONTENT_ITEM_TYPE)
712                .put(Email.TYPE, Email.TYPE_CUSTOM)
713                .put(Email.LABEL, "INTERNET")
714                .put(Email.ADDRESS, "\"Omega\" <omega@example.com>");
715    }
716
717    public void testAdrMultipleLineV21() {
718        ContentValues contentValuesForValue = new ContentValues();
719        contentValuesForValue.put("VALUE", "DATE");
720
721        mVerifier.initForImportTest(V21, R.raw.v21_adr_multiple_line);
722        mVerifier.addPropertyNodesVerifierElem()
723                .addExpectedNodeWithOrder("N", "bogus")
724                .addExpectedNodeWithOrder("URL", "http://bogus.com/")
725                .addExpectedNodeWithOrder("ADR",
726                        ";;Grindelberg 999;Hamburg;;99999;Deutschland",
727                        Arrays.asList("", "", "Grindelberg 999", "Hamburg", "", "99999",
728                                "Deutschland"),
729                        new TypeSet("HOME"))
730                .addExpectedNodeWithOrder("ADR", ";;Hermann v. Brevern\\ 9999999\\ " +
731                        "Packstation 999;Hamburg;;99999;Deutschland",
732                        Arrays.asList("", "", "Hermann v. Brevern\\ 9999999\\ Packstation 999",
733                                "Hamburg", "", "99999", "Deutschland"),
734                        new TypeSet("HOME"))
735                .addExpectedNodeWithOrder("BDAY", "20081203", contentValuesForValue);
736    }
737
738    public void testV30Simple_Parsing() {
739        mVerifier.initForImportTest(V30, R.raw.v30_simple);
740        mVerifier.addPropertyNodesVerifierElem()
741                .addExpectedNodeWithOrder("FN", "And Roid")
742                .addExpectedNodeWithOrder("N", "And;Roid;;;",
743                        Arrays.asList("And", "Roid", "", "", ""))
744                .addExpectedNodeWithOrder("ORG", "Open;Handset; Alliance",
745                        Arrays.asList("Open", "Handset", " Alliance"))
746                .addExpectedNodeWithOrder("SORT-STRING", "android")
747                .addExpectedNodeWithOrder("TEL", "0300000000", new TypeSet("PREF", "VOICE"))
748                .addExpectedNodeWithOrder("CLASS", "PUBLIC")
749                .addExpectedNodeWithOrder("X-GNO", "0")
750                .addExpectedNodeWithOrder("X-GN", "group0")
751                .addExpectedNodeWithOrder("X-REDUCTION", "0")
752                .addExpectedNodeWithOrder("REV", "20081031T065854Z");
753    }
754
755    public void testV30Simple() {
756        mVerifier.initForImportTest(V30, R.raw.v30_simple);
757        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
758        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
759                .put(StructuredName.FAMILY_NAME, "And")
760                .put(StructuredName.GIVEN_NAME, "Roid")
761                .put(StructuredName.DISPLAY_NAME, "And Roid")
762                .put(StructuredName.PHONETIC_GIVEN_NAME, "android");
763        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
764                .put(Organization.COMPANY, "Open")
765                .put(Organization.DEPARTMENT, "Handset  Alliance")
766                .put(Organization.TYPE, Organization.TYPE_WORK);
767        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
768                .put(Phone.TYPE, Phone.TYPE_OTHER)
769                .put(Phone.NUMBER, "030-000-0000")
770                .put(Phone.IS_PRIMARY, 1);
771    }
772
773    public void testV21Japanese1_Parsing() {
774        // Though Japanese careers append ";;;;" at the end of the value of "SOUND",
775        // vCard 2.1/3.0 specification does not allow multiple values.
776        // Do not need to handle it as multiple values.
777        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_japanese_1);
778        mVerifier.addPropertyNodesVerifierElem()
779                .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9;;;;",
780                        Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9", "", "", "", ""),
781                        null, mContentValuesForSJis, null, null)
782                .addExpectedNodeWithOrder("SOUND",
783                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E;;;;",
784                        null, null, mContentValuesForSJis,
785                        new TypeSet("X-IRMC-N"), null)
786                .addExpectedNodeWithOrder("TEL", "0300000000", null, null, null,
787                        new TypeSet("VOICE", "PREF"), null);
788    }
789
790    private void testV21Japanese1Common(int resId, int vcardType, boolean japanese) {
791        mVerifier.initForImportTest(vcardType, resId);
792        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
793        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
794                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9")
795                .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9")
796                // While vCard parser does not split "SOUND" property values,
797                // ContactStruct care it.
798                .put(StructuredName.PHONETIC_GIVEN_NAME,
799                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E");
800        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
801                // Phone number formatting is different.
802                .put(Phone.NUMBER, (japanese ? "03-0000-0000" : "030-000-0000"))
803                .put(Phone.TYPE, Phone.TYPE_OTHER)
804                .put(Phone.IS_PRIMARY, 1);
805    }
806
807    /**
808     * Verifies vCard with Japanese can be parsed correctly with
809     * {@link com.android.vcard.VCardConfig#VCARD_TYPE_V21_GENERIC}.
810     */
811    public void testV21Japanese1_Type_Generic_Utf8() {
812        testV21Japanese1Common(
813                R.raw.v21_japanese_1, VCardConfig.VCARD_TYPE_V21_GENERIC, false);
814    }
815
816    /**
817     * Verifies vCard with Japanese can be parsed correctly with
818     * {@link com.android.vcard.VCardConfig#VCARD_TYPE_V21_JAPANESE}.
819     */
820    public void testV21Japanese1_Type_Japanese_Sjis() {
821        testV21Japanese1Common(
822                R.raw.v21_japanese_1, VCardConfig.VCARD_TYPE_V21_JAPANESE, true);
823    }
824
825    /**
826     * Verifies vCard with Japanese can be parsed correctly with
827     * {@link com.android.vcard.VCardConfig#VCARD_TYPE_V21_JAPANESE}.
828     * since vCard 2.1 specifies the charset of each line if it contains non-Ascii.
829     */
830    public void testV21Japanese1_Type_Japanese_Utf8() {
831        testV21Japanese1Common(
832                R.raw.v21_japanese_1, VCardConfig.VCARD_TYPE_V21_JAPANESE, true);
833    }
834
835    public void testV21Japanese2_Parsing() {
836        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_japanese_2);
837        mVerifier.addPropertyNodesVerifierElem()
838                .addExpectedNodeWithOrder("N", "\u5B89\u85E4;\u30ED\u30A4\u30C9\u0031;;;",
839                        Arrays.asList("\u5B89\u85E4", "\u30ED\u30A4\u30C9\u0031",
840                                "", "", ""),
841                        null, mContentValuesForSJis, null, null)
842                .addExpectedNodeWithOrder("FN", "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9\u0020\u0031",
843                        null, null, mContentValuesForSJis, null, null)
844                .addExpectedNodeWithOrder("SOUND",
845                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73;\uFF9B\uFF72\uFF84\uFF9E\u0031;;;",
846                        null, null, mContentValuesForSJis,
847                        new TypeSet("X-IRMC-N"), null)
848                .addExpectedNodeWithOrder("ADR",
849                        ";\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" +
850                        "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" +
851                        "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC\u0036" +
852                        "\u968E;;;;150-8512;",
853                        Arrays.asList("",
854                                "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" +
855                                "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" +
856                                "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" +
857                                "\u0036\u968E", "", "", "", "150-8512", ""),
858                        null, mContentValuesForQPAndSJis, new TypeSet("HOME"), null)
859                .addExpectedNodeWithOrder("NOTE", "\u30E1\u30E2", null, null,
860                        mContentValuesForQPAndSJis, null, null);
861    }
862
863    public void testV21Japanese2_Type_Generic_Utf8() {
864        mVerifier.initForImportTest(V21, R.raw.v21_japanese_2);
865        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
866        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
867                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4")
868                .put(StructuredName.GIVEN_NAME, "\u30ED\u30A4\u30C9\u0031")
869                .put(StructuredName.DISPLAY_NAME,
870                        "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9\u0020\u0031")
871                // ContactStruct should correctly split "SOUND" property into several elements,
872                // even though VCardParser side does not care it.
873                .put(StructuredName.PHONETIC_FAMILY_NAME, "\uFF71\uFF9D\uFF84\uFF9E\uFF73")
874                .put(StructuredName.PHONETIC_GIVEN_NAME, "\uFF9B\uFF72\uFF84\uFF9E\u0031");
875        elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE)
876                .put(StructuredPostal.POSTCODE, "150-8512")
877                .put(StructuredPostal.STREET,
878                        "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" +
879                        "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" +
880                        "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" +
881                        "\u0036\u968E")
882                .put(StructuredPostal.FORMATTED_ADDRESS,
883                        "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" +
884                        "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" +
885                        "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" +
886                        "\u0036\u968E 150-8512")
887                .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME);
888        elem.addExpected(Note.CONTENT_ITEM_TYPE)
889                .put(Note.NOTE, "\u30E1\u30E2");
890    }
891
892    public void testV21Japanese3_Parsing() {
893        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_japanese_3);
894        mVerifier.addPropertyNodesVerifierElem()
895                .addExpectedNodeWithOrder("N", "\u4f0a\u80fd;\u572d\u4e00;\u4f0a\u4e88;;",
896                        Arrays.asList("\u4f0a\u80fd", "\u572d\u4e00", "\u4f0a\u4e88",
897                                "", ""),
898                        null, mContentValuesForSJis, null, null)
899                .addExpectedNodeWithOrder("FN", "\u4f0a\u80fd\u0020\u572d\u4e00\u0020\u4f0a\u4e88",
900                        null, null, mContentValuesForSJis, null, null);
901    }
902
903    public void testV21Japanese3_Parsing_Utf8() {
904        mVerifier.initForImportTest(V21, R.raw.v21_japanese_3);
905        mVerifier.addPropertyNodesVerifierElem()
906                .addExpectedNodeWithOrder("N", "\u4f0a\u80fd;\u572d\u4e00;\u4f0a\u4e88;;",
907                        Arrays.asList("\u4f0a\u80fd", "\u572d\u4e00", "\u4f0a\u4e88",
908                                "", ""),
909                        null, mContentValuesForSJis, null, null)
910                .addExpectedNodeWithOrder("FN", "\u4f0a\u80fd\u0020\u572d\u4e00\u0020\u4f0a\u4e88",
911                        null, null, mContentValuesForSJis, null, null);
912    }
913
914    public void testV30Japanese_Parsing() {
915        mVerifier.initForImportTest(V30, R.raw.v30_japanese);
916        mVerifier.addPropertyNodesVerifierElem()
917                .addExpectedNodeWithOrder("N", "\u4f0a\u80fd;\u572d\u4e00;\u4f0a\u4e88;;",
918                        Arrays.asList("\u4f0a\u80fd", "\u572d\u4e00", "\u4f0a\u4e88",
919                                "", ""),
920                        null, mContentValuesForSJis, null, null)
921                .addExpectedNodeWithOrder("FN", "\u4f0a\u80fd\u0020\u572d\u4e00\u0020\u4f0a\u4e88",
922                        null, null, mContentValuesForSJis, null, null);
923    }
924
925    public void testV21MultipleEntryCase_Parse() {
926        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_multiple_entry);
927        mVerifier.addPropertyNodesVerifierElem()
928                .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033;;;;",
929                        Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0033", "", "", "", ""),
930                        null, mContentValuesForSJis, null, null)
931                .addExpectedNodeWithOrder("SOUND",
932                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0033;;;;",
933                        null, null, mContentValuesForSJis,
934                        new TypeSet("X-IRMC-N"), null)
935                .addExpectedNodeWithOrder("TEL", "9", new TypeSet("X-NEC-SECRET"))
936                .addExpectedNodeWithOrder("TEL", "10", new TypeSet("X-NEC-HOTEL"))
937                .addExpectedNodeWithOrder("TEL", "11", new TypeSet("X-NEC-SCHOOL"))
938                .addExpectedNodeWithOrder("TEL", "12", new TypeSet("FAX", "HOME"));
939        mVerifier.addPropertyNodesVerifierElem()
940                .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034;;;;",
941                        Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0034", "", "", "", ""),
942                        null, mContentValuesForSJis, null, null)
943                .addExpectedNodeWithOrder("SOUND",
944                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0034;;;;",
945                        null, null, mContentValuesForSJis,
946                        new TypeSet("X-IRMC-N"), null)
947                .addExpectedNodeWithOrder("TEL", "13", new TypeSet("MODEM"))
948                .addExpectedNodeWithOrder("TEL", "14", new TypeSet("PAGER"))
949                .addExpectedNodeWithOrder("TEL", "15", new TypeSet("X-NEC-FAMILY"))
950                .addExpectedNodeWithOrder("TEL", "16", new TypeSet("X-NEC-GIRL"));
951        mVerifier.addPropertyNodesVerifierElem()
952                .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035;;;;",
953                        Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0035", "", "", "", ""),
954                        null, mContentValuesForSJis, null, null)
955                .addExpectedNodeWithOrder("SOUND",
956                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0035;;;;",
957                        null, null, mContentValuesForSJis,
958                        new TypeSet("X-IRMC-N"), null)
959                .addExpectedNodeWithOrder("TEL", "17", new TypeSet("X-NEC-BOY"))
960                .addExpectedNodeWithOrder("TEL", "18", new TypeSet("X-NEC-FRIEND"))
961                .addExpectedNodeWithOrder("TEL", "19", new TypeSet("X-NEC-PHS"))
962                .addExpectedNodeWithOrder("TEL", "20", new TypeSet("X-NEC-RESTAURANT"));
963    }
964
965    public void testV21MultipleEntryCase() {
966        mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE, R.raw.v21_multiple_entry);
967        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
968        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
969                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033")
970                .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033")
971                .put(StructuredName.PHONETIC_GIVEN_NAME,
972                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0033");
973        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
974                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
975                .put(Phone.LABEL, "NEC-SECRET")
976                .put(Phone.NUMBER, "9");
977        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
978                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
979                .put(Phone.LABEL, "NEC-HOTEL")
980                .put(Phone.NUMBER, "10");
981        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
982                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
983                .put(Phone.LABEL, "NEC-SCHOOL")
984                .put(Phone.NUMBER, "11");
985        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
986                .put(Phone.TYPE, Phone.TYPE_FAX_HOME)
987                .put(Phone.NUMBER, "12");
988
989        elem = mVerifier.addContentValuesVerifierElem();
990        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
991                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034")
992                .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034")
993                .put(StructuredName.PHONETIC_GIVEN_NAME,
994                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0034");
995        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
996                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
997                .put(Phone.LABEL, "MODEM")
998                .put(Phone.NUMBER, "13");
999        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1000                .put(Phone.TYPE, Phone.TYPE_PAGER)
1001                .put(Phone.NUMBER, "14");
1002        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1003                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1004                .put(Phone.LABEL, "NEC-FAMILY")
1005                .put(Phone.NUMBER, "15");
1006        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1007                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1008                .put(Phone.LABEL, "NEC-GIRL")
1009                .put(Phone.NUMBER, "16");
1010
1011        elem = mVerifier.addContentValuesVerifierElem();
1012        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1013                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035")
1014                .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035")
1015                .put(StructuredName.PHONETIC_GIVEN_NAME,
1016                        "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0035");
1017        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1018                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1019                .put(Phone.LABEL, "NEC-BOY")
1020                .put(Phone.NUMBER, "17");
1021        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1022                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1023                .put(Phone.LABEL, "NEC-FRIEND")
1024                .put(Phone.NUMBER, "18");
1025        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1026                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1027                .put(Phone.LABEL, "NEC-PHS")
1028                .put(Phone.NUMBER, "19");
1029        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1030                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1031                .put(Phone.LABEL, "NEC-RESTAURANT")
1032                .put(Phone.NUMBER, "20");
1033    }
1034
1035    public void testIgnoreAgentV21_Parse() {
1036        mVerifier.initForImportTest(V21, R.raw.v21_winmo_65);
1037        ContentValues contentValuesForValue = new ContentValues();
1038        contentValuesForValue.put("VALUE", "DATE");
1039        mVerifier.addPropertyNodesVerifierElem()
1040                .addExpectedNodeWithOrder("N", Arrays.asList("Example", "", "", "", ""))
1041                .addExpectedNodeWithOrder("FN", "Example")
1042                .addExpectedNodeWithOrder("ANNIVERSARY", "20091010", contentValuesForValue)
1043                .addExpectedNodeWithOrder("AGENT", "")
1044                .addExpectedNodeWithOrder("X-CLASS", "PUBLIC")
1045                .addExpectedNodeWithOrder("X-REDUCTION", "")
1046                .addExpectedNodeWithOrder("X-NO", "");
1047    }
1048
1049    public void testIgnoreAgentV21() {
1050        mVerifier.initForImportTest(V21, R.raw.v21_winmo_65);
1051        ContentValuesVerifier verifier = new ContentValuesVerifier();
1052        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1053        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1054                .put(StructuredName.FAMILY_NAME, "Example")
1055                .put(StructuredName.DISPLAY_NAME, "Example");
1056        elem.addExpected(Event.CONTENT_ITEM_TYPE)
1057                .put(Event.TYPE, Event.TYPE_ANNIVERSARY)
1058                .put(Event.START_DATE, "20091010");
1059    }
1060
1061    public void testTolerateInvalidCommentLikeLineV21() {
1062        mVerifier.initForImportTest(V21, R.raw.v21_invalid_comment_line);
1063        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1064        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1065                .put(StructuredName.GIVEN_NAME, "Conference Call")
1066                .put(StructuredName.DISPLAY_NAME, "Conference Call");
1067        elem.addExpected(Note.CONTENT_ITEM_TYPE)
1068                .put(Note.NOTE, "This is an (sharp ->#<- sharp) example. "
1069                        + "This message must NOT be ignored.");
1070    }
1071
1072    public void testPagerV30_Parse() {
1073        mVerifier.initForImportTest(V30, R.raw.v30_pager);
1074        mVerifier.addPropertyNodesVerifierElem()
1075                .addExpectedNodeWithOrder("N", Arrays.asList("F", "G", "M", "", ""))
1076                .addExpectedNodeWithOrder("TEL", "6101231234@pagersample.com",
1077                        new TypeSet("WORK", "MSG", "PAGER"));
1078    }
1079
1080    public void testPagerV30() {
1081        mVerifier.initForImportTest(V30, R.raw.v30_pager);
1082        ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1083        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1084                .put(StructuredName.FAMILY_NAME, "F")
1085                .put(StructuredName.MIDDLE_NAME, "M")
1086                .put(StructuredName.GIVEN_NAME, "G")
1087                .put(StructuredName.DISPLAY_NAME, "G M F");
1088        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1089                .put(Phone.TYPE, Phone.TYPE_PAGER)
1090                .put(Phone.NUMBER, "6101231234@pagersample.com");
1091    }
1092
1093    public void testMultiBytePropV30_Parse() {
1094        mVerifier.initForImportTest(V30, R.raw.v30_multibyte_param);
1095        mVerifier.addPropertyNodesVerifierElem()
1096                .addExpectedNodeWithOrder("N", Arrays.asList("F", "G", "M", "", ""))
1097                .addExpectedNodeWithOrder("TEL", "1", new TypeSet("\u8D39"));
1098    }
1099
1100    public void testMultiBytePropV30() {
1101        mVerifier.initForImportTest(V30, R.raw.v30_multibyte_param);
1102        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1103        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1104                .put(StructuredName.FAMILY_NAME, "F")
1105                .put(StructuredName.MIDDLE_NAME, "M")
1106                .put(StructuredName.GIVEN_NAME, "G")
1107                .put(StructuredName.DISPLAY_NAME, "G M F");
1108        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1109                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1110                .put(Phone.LABEL, "\u8D39")
1111                .put(Phone.NUMBER, "1");
1112    }
1113
1114    public void testCommaSeparatedParamsV30_Parse() {
1115        mVerifier.initForImportTest(V30, R.raw.v30_comma_separated);
1116        mVerifier.addPropertyNodesVerifierElem()
1117                .addExpectedNodeWithOrder("N", Arrays.asList("F", "G", "M", "", ""),
1118                        new TypeSet("PREF", "HOME"))
1119                .addExpectedNodeWithOrder("TEL", "1",
1120                        new TypeSet("COMMA,SEPARATED:INSIDE.DQUOTE", "PREF"));
1121    }
1122
1123    public void testSortAsV40_Parse() {
1124        mVerifier.initForImportTest(V40, R.raw.v40_sort_as);
1125
1126        final ContentValues contentValuesForSortAsN = new ContentValues();
1127        contentValuesForSortAsN.put("SORT-AS",
1128                "\u3042\u3093\u3069\u3046;\u308D\u3044\u3069");
1129        final ContentValues contentValuesForSortAsOrg = new ContentValues();
1130        contentValuesForSortAsOrg.put("SORT-AS",
1131                "\u3050\u30FC\u3050\u308B;\u3051\u3093\u3055\u304F\u3076\u3082\u3093");
1132
1133        mVerifier.addPropertyNodesVerifierElem()
1134                .addExpectedNodeWithOrder("FN", "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9")
1135                .addExpectedNodeWithOrder("N",
1136                        Arrays.asList("\u5B89\u85E4", "\u30ED\u30A4\u30C9", "", "", ""),
1137                        contentValuesForSortAsN)
1138                .addExpectedNodeWithOrder("ORG",
1139                        Arrays.asList("\u30B0\u30FC\u30B0\u30EB", "\u691C\u7D22\u90E8\u9580"),
1140                        contentValuesForSortAsOrg, new TypeSet("WORK"));
1141    }
1142
1143    public void testSortAsV40() {
1144        mVerifier.initForImportTest(V40, R.raw.v40_sort_as);
1145        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1146        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1147                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4")
1148                .put(StructuredName.GIVEN_NAME, "\u30ED\u30A4\u30C9")
1149                .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9")
1150                .put(StructuredName.PHONETIC_FAMILY_NAME, "\u3042\u3093\u3069\u3046")
1151                .put(StructuredName.PHONETIC_GIVEN_NAME,
1152                        "\u308D\u3044\u3069");
1153        elem.addExpected(Organization.CONTENT_ITEM_TYPE)
1154                .put(Organization.TYPE, Organization.TYPE_WORK)
1155                .put(Organization.COMPANY, "\u30B0\u30FC\u30B0\u30EB")
1156                .put(Organization.DEPARTMENT, "\u691C\u7D22\u90E8\u9580")
1157                .put(Organization.PHONETIC_NAME,
1158                        "\u3050\u30FC\u3050\u308B\u3051\u3093\u3055\u304F\u3076\u3082\u3093");
1159    }
1160
1161    public void testIMV21_Parse() {
1162        mVerifier.initForImportTest(V21, R.raw.v21_im);
1163        mVerifier.addPropertyNodesVerifierElem()
1164                .addExpectedNodeWithOrder("X-ANDROID-CUSTOM",
1165                        Arrays.asList("vnd.android.cursor.item/nickname", "Nick", "1",
1166                                "", "", "", "", "", "", "", "", "", "", "", "", ""))  // 13
1167                .addExpectedNodeWithOrder("X-GOOGLE-TALK", "hhh@gmail.com");
1168    }
1169
1170    public void testIMV21() {
1171        mVerifier.initForImportTest(V21, R.raw.v21_im);
1172        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1173        elem.addExpected(Nickname.CONTENT_ITEM_TYPE)
1174                .put(Nickname.NAME, "Nick")
1175                .put(Nickname.TYPE, "1");
1176        elem.addExpected(Im.CONTENT_ITEM_TYPE)
1177                .put(Im.PROTOCOL, Im.PROTOCOL_GOOGLE_TALK)
1178                .put(Im.TYPE, Im.TYPE_HOME)
1179                .put(Im.DATA, "hhh@gmail.com");
1180    }
1181
1182    public void testSipV30_Parse() {
1183        mVerifier.initForImportTest(V30, R.raw.v30_sip);
1184        mVerifier.addPropertyNodesVerifierElem()
1185                .addExpectedNodeWithOrder("FN", "Android")
1186                .addExpectedNodeWithOrder("IMPP", "sip:android@android.example.com",
1187                        new TypeSet("personal"));
1188    }
1189
1190    public void testSipV30() {
1191        mVerifier.initForImportTest(V30, R.raw.v30_sip);
1192        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1193        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1194                .put(StructuredName.DISPLAY_NAME, "Android");
1195        // Type is ignored silently.
1196        elem.addExpected(SipAddress.CONTENT_ITEM_TYPE)
1197                .put(SipAddress.TYPE, SipAddress.TYPE_CUSTOM)
1198                .put(SipAddress.LABEL, "personal")
1199                .put(SipAddress.SIP_ADDRESS, "android@android.example.com");
1200    }
1201
1202    public void testSipV21_Parse() {
1203        mVerifier.initForImportTest(V21, R.raw.v21_sip);
1204        mVerifier.addPropertyNodesVerifierElem()
1205                .addExpectedNodeWithOrder("FN", "Android")
1206                .addExpectedNodeWithOrder("X-SIP", "888")
1207                .addExpectedNodeWithOrder("X-SIP", "sip:90-180-360");
1208    }
1209
1210    public void testSipV21() {
1211        mVerifier.initForImportTest(V21, R.raw.v21_sip);
1212        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1213        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1214                .put(StructuredName.DISPLAY_NAME, "Android");
1215        elem.addExpected(SipAddress.CONTENT_ITEM_TYPE)
1216                .put(SipAddress.TYPE, SipAddress.TYPE_OTHER)
1217                .put(SipAddress.SIP_ADDRESS, "888");
1218        // "sip:" should be removed.
1219        elem.addExpected(SipAddress.CONTENT_ITEM_TYPE)
1220                .put(SipAddress.TYPE, SipAddress.TYPE_OTHER)
1221                .put(SipAddress.SIP_ADDRESS, "90-180-360");
1222    }
1223
1224    public void testSipV40() {
1225        mVerifier.initForImportTest(V40, R.raw.v40_sip);
1226        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1227        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1228                .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4")
1229                .put(StructuredName.GIVEN_NAME, "\u30ED\u30A4\u30C9")
1230                .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9");
1231        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1232                .put(Phone.TYPE, Phone.TYPE_HOME)
1233                .put(Phone.NUMBER, "1");
1234        elem.addExpected(SipAddress.CONTENT_ITEM_TYPE)
1235                .put(SipAddress.TYPE, SipAddress.TYPE_HOME)
1236                .put(SipAddress.SIP_ADDRESS, "example@example.com");
1237    }
1238
1239    public void testCustomPropertyV21_Parse() {
1240        mVerifier.initForImportTest(V21, R.raw.v21_x_param);
1241        mVerifier.addPropertyNodesVerifierElem()
1242                .addExpectedNodeWithOrder("N", "Ando;Roid;", Arrays.asList("Ando", "Roid", ""))
1243                .addExpectedNodeWithOrder("ADR", "pobox;street", Arrays.asList("pobox", "street"),
1244                        new TypeSet("X-custom"))
1245                .addExpectedNodeWithOrder("TEL", "1", new TypeSet("X-CuStoMpRop"))
1246                .addExpectedNodeWithOrder("TEL", "2", new TypeSet("custompropertywithoutx"))
1247                .addExpectedNodeWithOrder("EMAIL", "email@example.com",
1248                        new TypeSet("X-cUstomPrOperty"))
1249                .addExpectedNodeWithOrder("EMAIL", "email2@example.com",
1250                        new TypeSet("CUSTOMPROPERTYWITHOUTX"));
1251    }
1252
1253    public void testCustomPropertyV21() {
1254        mVerifier.initForImportTest(V21, R.raw.v21_x_param);
1255        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1256        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1257                .put(StructuredName.FAMILY_NAME, "Ando")
1258                .put(StructuredName.GIVEN_NAME, "Roid")
1259                .put(StructuredName.DISPLAY_NAME, "Roid Ando");
1260        elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE)
1261                .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM)
1262                .put(StructuredPostal.LABEL, "custom")
1263                .put(StructuredPostal.POBOX, "pobox")
1264                .put(StructuredPostal.STREET, "street")
1265                .put(StructuredPostal.FORMATTED_ADDRESS, "pobox street");
1266        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1267                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1268                .put(Phone.LABEL, "CuStoMpRop")
1269                .put(Phone.NUMBER, "1");
1270        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1271                .put(Phone.TYPE, Phone.TYPE_CUSTOM)
1272                .put(Phone.LABEL, "custompropertywithoutx")
1273                .put(Phone.NUMBER, "2");
1274        elem.addExpected(Email.CONTENT_ITEM_TYPE)
1275                .put(Email.TYPE, Email.TYPE_CUSTOM)
1276                .put(Email.LABEL, "cUstomPrOperty")
1277                .put(Email.ADDRESS, "email@example.com");
1278        elem.addExpected(Email.CONTENT_ITEM_TYPE)
1279                .put(Email.TYPE, Email.TYPE_CUSTOM)
1280                .put(Email.LABEL, "CUSTOMPROPERTYWITHOUTX")
1281                .put(Email.ADDRESS, "email2@example.com");
1282    }
1283
1284    public void testBase64Without2CrLf_Parse() {
1285        mVerifier.initForImportTest(V21, R.raw.v21_base64_no_2_crlf);
1286        mVerifier.addPropertyNodesVerifierElem()
1287                .addExpectedNodeWithOrder("N", "name")
1288                .addExpectedNodeWithOrder("FN", "fullname")
1289                .addExpectedNodeWithOrder("PHOTO", null,
1290                        null, sPhotoByteArrayForComplicatedCase, mContentValuesForBase64V21,
1291                        new TypeSet("JPEG"), null);
1292    }
1293
1294    public void testBase64Without2CrLfForBlackBerry_Parse() {
1295        mVerifier.initForImportTest(V21, R.raw.v21_blackberry_photo);
1296        mVerifier.addPropertyNodesVerifierElem()
1297                .addExpectedNodeWithOrder("FN", "boogie")
1298                .addExpectedNodeWithOrder("N", "boogie")
1299                .addExpectedNodeWithOrder("PHOTO", null,
1300                        null, sPhotoByteArrayForComplicatedCase, mContentValuesForBase64V21,
1301                        null, null)
1302                .addExpectedNodeWithOrder("TEL", "+5555555", new TypeSet("WORK"))
1303                .addExpectedNodeWithOrder("TEL", "+5555556", new TypeSet("CELL"))
1304                .addExpectedNodeWithOrder("EMAIL", "forrestgump@walladalla.com",
1305                        new TypeSet("INTERNET"));
1306    }
1307
1308    public void testMalformedBase64PhotoThrowsVCardException() {
1309        mVerifier.initForImportTest(V21, R.raw.v21_malformed_photo);
1310
1311        String expectedMsgContent = "qgEPAAIAAAAHAAAAugEQAAIAAAAG:ASDF==";
1312        mVerifier.addVCardExceptionVerifier(expectedMsgContent);
1313    }
1314
1315    public void testAndroidCustomPropertyV21() {
1316        mVerifier.initForImportTest(V21, R.raw.v21_android_custom_prop);
1317        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1318        elem.addExpected("custom_mime1")
1319                .put("data1", "1").put("data2", "2").put("data3", "3").put("data4", "4")
1320                .put("data5", "5").put("data6", "6").put("data7", "7").put("data8", "8")
1321                .put("data9", "9").put("data10", "10").put("data11", "11").put("data12", "12")
1322                .put("data13", "13").put("data14", "14").put("data15", "15");
1323        // 16'th elemnt ('p') should be ignored
1324        elem.addExpected("custom_mime2")
1325                .put("data1", "a").put("data2", "b").put("data3", "c").put("data4", "d")
1326                .put("data5", "e").put("data6", "f").put("data7", "g").put("data8", "h")
1327                .put("data9", "i").put("data10", "j").put("data11", "k").put("data12", "l")
1328                .put("data13", "m").put("data14", "n").put("data15", "o");
1329
1330        // custom_mime3 shouldn't be here, as there's no data
1331
1332        // Smoke test.
1333        elem.addExpected("custom_mime4").put("data1", "z");
1334    }
1335
1336    public void testPauseWaitV30_Parse() {
1337        mVerifier.initForImportTest(V30, R.raw.v30_pause_wait);
1338        mVerifier.addPropertyNodesVerifierElem()
1339                .addExpectedNodeWithOrder("FN", "Pause Wait")
1340                .addExpectedNodeWithOrder("N", "Pause;Wait;;;",
1341                        Arrays.asList("Pause", "Wait", "", "", ""))
1342                .addExpectedNodeWithOrder("TEL", "p1234p5678w9");
1343     }
1344
1345    public void testPauseWaitV30() {
1346        mVerifier.initForImportTest(V30, R.raw.v30_pause_wait);
1347        final ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem();
1348        elem.addExpected(StructuredName.CONTENT_ITEM_TYPE)
1349                .put(StructuredName.FAMILY_NAME, "Pause")
1350                .put(StructuredName.GIVEN_NAME, "Wait")
1351                .put(StructuredName.DISPLAY_NAME, "Pause Wait");
1352        // See PhoneNumberUtils in Android SDK.
1353        elem.addExpected(Phone.CONTENT_ITEM_TYPE)
1354                .put(Phone.TYPE, Phone.TYPE_HOME)
1355                .put(Phone.NUMBER, ",1234,5678;9");
1356    }
1357
1358    // We ran into a case where a 2.1 vcard was sent with a 3.0+ property,
1359    // X-ANDROID-CUSTOM. If that property followed photo data without a blank line,
1360    // getBase64() would append the X-ANDROID-CUSTOM data line to the photo data.
1361    // When Base64.decode() was called with this data, it would throw an exception.
1362    // Besides looking for the normal 2.1 properties, we need to look for
1363    // X-ANDROID-CUSTOM as well. Here's an example of a bad vcard that would cause
1364    // this problem (This vcard was generated by a KLP MR2 Nexus 5 or a KLP Moto X):
1365    // ...
1366    //  LHnTW/l/wB9f+PV2UcFyfGeVis3qVPch7pWjs/s+m/2Zpdp5f8Ayy/df6uPZWNcR9dRzWoZPb
1367    //  /l4/xpotvtH2vj/l39f8/99f8AxFdvKjwD/9k=
1368    // X-ANDROID-CUSTOM:vnd.android.cursor.item/contact_event;1999-07-10;1;;;;;;;;;;;;;
1369    // BDAY:1975-08-20
1370    // END:VCARD
1371    //
1372    // Here's how to build and run the tests in this file:
1373    //   mmm frameworks/opt/vcard
1374    //   adb install -r -d out/target/product/hammerhead/data/app/AndroidVCardTests.apk
1375    //   adb shell am instrument -w com.android.vcard.tests/android.test.InstrumentationTestRunner
1376    //
1377    public void testV21XAndroidCustomAfterPhoto() {
1378        mVerifier.initForImportTest(V21, R.raw.v21_x_android_custom_after_photo);
1379        mVerifier.addPropertyNodesVerifierElem()
1380                .addExpectedNodeWithOrder("N", "Ando;Roid;", Arrays.asList("Ando", "Roid", ""))
1381                .addExpectedNodeWithOrder("PHOTO", null,
1382                        null, sPhotoByteArrayForComplicatedCase, mContentValuesForBase64V21,
1383                        null, null)
1384                .addExpectedNodeWithOrder("X-ANDROID-CUSTOM",
1385                        "vnd.android.cursor.item/contact_event;1999-07-10;1;;;;;;;;;;;;;")
1386                .addExpectedNodeWithOrder("BDAY", "1975-08-20");
1387    }
1388
1389}
1390