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.email; 18 19 import android.os.Parcel; 20 import android.test.AndroidTestCase; 21 22 import com.android.emailcommon.service.SearchParams; 23 24 public class MessageListContextTests extends AndroidTestCase { 25 26 public void testParcellingMailboxes() { 27 long accountId = 123; 28 long mailboxId = 456; 29 MessageListContext original = MessageListContext.forMailbox(accountId, mailboxId); 30 Parcel parcel = Parcel.obtain(); 31 32 original.writeToParcel(parcel, 0); 33 parcel.setDataPosition(0); 34 35 MessageListContext read = MessageListContext.CREATOR.createFromParcel(parcel); 36 assertEquals(original, read); 37 parcel.recycle(); 38 } 39 40 public void testParcellingSearches() { 41 long accountId = 123; 42 long mailboxId = 456; 43 SearchParams params = new SearchParams(mailboxId, "search terms"); 44 MessageListContext original = MessageListContext.forSearch(accountId, mailboxId, params); 45 Parcel parcel = Parcel.obtain(); 46 47 original.writeToParcel(parcel, 0); 48 parcel.setDataPosition(0); 49 50 MessageListContext read = MessageListContext.CREATOR.createFromParcel(parcel); 51 assertEquals(original, read); 52 parcel.recycle(); 53 } 54 } 55