Home | History | Annotate | Download | only in provider
      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 
     17 package com.android.emailcommon.provider;
     18 
     19 import android.content.Context;
     20 import android.os.Parcel;
     21 import android.test.ProviderTestCase2;
     22 import android.test.suitebuilder.annotation.SmallTest;
     23 
     24 import com.android.email.provider.ContentCache;
     25 import com.android.email.provider.EmailProvider;
     26 
     27 /**
     28  * Unit tests for the QuickResponse class
     29  */
     30 @SmallTest
     31 public 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