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.exchange; 18 19 import com.android.emailcommon.provider.EmailContent.Attachment; 20 import com.android.emailsync.PartRequest; 21 22 import android.test.AndroidTestCase; 23 24 /** 25 * You can run this entire test case with: 26 * runtest -c com.android.exchange.RequestTests exchange 27 */ 28 public class RequestTests extends AndroidTestCase { 29 30 public void testPartRequestEquals() { 31 Attachment att1 = new Attachment(); 32 att1.mId = 1; 33 Attachment att2 = new Attachment(); 34 att2.mId = 2; 35 // For part requests, the attachment id's must be == 36 PartRequest req1 = new PartRequest(att1, "dest1", "content1"); 37 PartRequest req2 = new PartRequest(att2, "dest2", "content2"); 38 assertFalse(req1.equals(req2)); 39 Attachment att3 = new Attachment(); 40 att3.mId = 1; 41 PartRequest req3 = new PartRequest(att3, "dest3", "content3"); 42 assertTrue(req1.equals(req3)); 43 MessageMoveRequest req4 = new MessageMoveRequest(10L, 12L); 44 assertFalse(req1.equals(req4)); 45 } 46 47 public void testRequestEquals() { 48 // Only the messageId needs to be == 49 MessageMoveRequest req1 = new MessageMoveRequest(1L, 10L); 50 MessageMoveRequest req2 = new MessageMoveRequest(1L, 11L); 51 assertTrue(req1.equals(req2)); 52 MessageMoveRequest req3 = new MessageMoveRequest(2L, 11L); 53 assertFalse(req3.equals(req2)); 54 MeetingResponseRequest req4 = new MeetingResponseRequest(1L, 3); 55 assertFalse(req4.equals(req1)); 56 MeetingResponseRequest req5 = new MeetingResponseRequest(1L, 4); 57 assertTrue(req5.equals(req4)); 58 } 59 }