OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / core / tests / coretests / src / android / pim / vcard / test_utils / VCardTestsBase.java
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  */
16 package android.pim.vcard.test_utils;
17
18 import android.content.ContentValues;
19 import android.pim.vcard.VCardConfig;
20 import android.test.AndroidTestCase;
21
22 /**
23  * BaseClass for vCard unit tests with utility classes.
24  * Please do not add each unit test here.
25  */
26 public class VCardTestsBase extends AndroidTestCase {
27     public static final int V21 = VCardConfig.VCARD_TYPE_V21_GENERIC;
28     public static final int V30 = VCardConfig.VCARD_TYPE_V30_GENERIC;
29     public static final int V40 = VCardConfig.VCARD_TYPE_V40_GENERIC;
30
31     // Do not modify these during tests.
32     protected final ContentValues mContentValuesForQP;
33     protected final ContentValues mContentValuesForSJis;
34     protected final ContentValues mContentValuesForUtf8;
35     protected final ContentValues mContentValuesForQPAndSJis;
36     protected final ContentValues mContentValuesForQPAndUtf8;
37     protected final ContentValues mContentValuesForBase64V21;
38     protected final ContentValues mContentValuesForBase64V30;
39
40     protected VCardVerifier mVerifier;
41     private boolean mSkipVerification;
42
43     public VCardTestsBase() {
44         super();
45         // Not using constants in vCard code since it may be wrong.
46         mContentValuesForQP = new ContentValues();
47         mContentValuesForQP.put("ENCODING", "QUOTED-PRINTABLE");
48         mContentValuesForSJis = new ContentValues();
49         mContentValuesForSJis.put("CHARSET", "SHIFT_JIS");
50         mContentValuesForUtf8 = new ContentValues();
51         mContentValuesForUtf8.put("CHARSET", "UTF-8");
52         mContentValuesForQPAndSJis = new ContentValues();
53         mContentValuesForQPAndSJis.put("ENCODING", "QUOTED-PRINTABLE");
54         mContentValuesForQPAndSJis.put("CHARSET", "SHIFT_JIS");
55         mContentValuesForQPAndUtf8 = new ContentValues();
56         mContentValuesForQPAndUtf8.put("ENCODING", "QUOTED-PRINTABLE");
57         mContentValuesForQPAndUtf8.put("CHARSET", "UTF-8");
58         mContentValuesForBase64V21 = new ContentValues();
59         mContentValuesForBase64V21.put("ENCODING", "BASE64");
60         mContentValuesForBase64V30 = new ContentValues();
61         mContentValuesForBase64V30.put("ENCODING", "b");
62     }
63
64     @Override
65     public void testAndroidTestCaseSetupProperly() {
66         super.testAndroidTestCaseSetupProperly();
67         mSkipVerification = true;
68     }
69
70     @Override
71     public void setUp() throws Exception{
72         super.setUp();
73         mVerifier = new VCardVerifier(this);
74         mSkipVerification = false;
75     }
76
77     @Override
78     public void tearDown() throws Exception {
79         super.tearDown();
80         if (!mSkipVerification) {
81             mVerifier.verify();
82         }
83     }
84 }