1/*
2 * Copyright (C) 2011 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
17package com.android.emailcommon.provider;
18
19import android.content.Context;
20import android.os.Parcel;
21import android.test.ProviderTestCase2;
22import android.test.suitebuilder.annotation.SmallTest;
23
24import com.android.email.provider.ContentCache;
25import com.android.email.provider.EmailProvider;
26
27/**
28 * Unit tests for the QuickResponse class
29 */
30@SmallTest
31public class QuickResponseTests extends ProviderTestCase2<EmailProvider> {
32    private Context mMockContext;
33    private EmailProvider mProvider;
34
35    public QuickResponseTests() {
36        super(EmailProvider.class, EmailContent.AUTHORITY);
37    }
38
39    @Override
40    public void setUp() throws Exception {
41        super.setUp();
42        mMockContext = getMockContext();
43        mProvider = getProvider();
44        // Invalidate all caches, since we reset the database for each test
45        ContentCache.invalidateAllCaches();
46    }
47
48    public void testParcelling() {
49        QuickResponse original = new QuickResponse(7, "quick response text");
50
51        Parcel p = Parcel.obtain();
52        original.writeToParcel(p, 0);
53
54        // Reset.
55        p.setDataPosition(0);
56
57        QuickResponse unparcelled = QuickResponse.CREATOR.createFromParcel(p);
58        assert(original.equals(unparcelled));
59
60        QuickResponse phony = new QuickResponse(17, "quick response text");
61        assert(!(phony.equals(unparcelled)));
62
63        QuickResponse phony2 = new QuickResponse(7, "different text");
64        assert(!(phony2.equals(unparcelled)));
65
66        p.recycle();
67    }
68}
69
70