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 17package com.android.email; 18 19import com.android.emailcommon.mail.MockFolder; 20import com.android.emailcommon.provider.Account; 21 22import android.content.ContentUris; 23import android.net.Uri; 24import android.test.AndroidTestCase; 25import android.test.suitebuilder.annotation.SmallTest; 26 27/** 28 * This is a series of unit tests for the MessagingController class. 29 * 30 * Technically these are functional because they use the underlying provider framework. 31 */ 32@SmallTest 33public class MessagingControllerUnitTests extends AndroidTestCase { 34 35 private long mAccountId; 36 private Account mAccount; 37 38 /** 39 * Delete any dummy accounts we set up for this test 40 */ 41 @Override 42 protected void tearDown() throws Exception { 43 super.tearDown(); 44 45 if (mAccount != null) { 46 Uri uri = ContentUris.withAppendedId( 47 Account.CONTENT_URI, mAccountId); 48 getContext().getContentResolver().delete(uri, null, null); 49 } 50 } 51 52 /** 53 * MockFolder allows setting and retrieving role & name 54 */ 55 private static class MyMockFolder extends MockFolder { 56 private FolderRole mRole; 57 private String mName; 58 59 public MyMockFolder(FolderRole role, String name) { 60 mRole = role; 61 mName = name; 62 } 63 64 @Override 65 public String getName() { 66 return mName; 67 } 68 69 @Override 70 public FolderRole getRole() { 71 return mRole; 72 } 73 } 74 75 /** 76 * Create a dummy account with minimal fields 77 */ 78 private void createTestAccount() { 79 mAccount = new Account(); 80 mAccount.save(getContext()); 81 82 mAccountId = mAccount.mId; 83 } 84 85} 86