From 654cc1f68f81e1f64a8f6242961d0ba507912371 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 28 May 2010 12:53:46 -0700 Subject: [PATCH] Split UtilityUnitTests into medium and small test classes Change-Id: I382bb2bd94ba4d800e907f9c439b4e03f1f20ea4 --- .../com/android/email/UtilityMediumTests.java | 74 +++++++++++++++++++ .../com/android/email/UtilityUnitTests.java | 45 +---------- 2 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 tests/src/com/android/email/UtilityMediumTests.java diff --git a/tests/src/com/android/email/UtilityMediumTests.java b/tests/src/com/android/email/UtilityMediumTests.java new file mode 100644 index 000000000..3293da653 --- /dev/null +++ b/tests/src/com/android/email/UtilityMediumTests.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email; + +import com.android.email.provider.EmailProvider; +import com.android.email.provider.ProviderTestUtils; +import com.android.email.provider.EmailContent.Account; + +import android.content.Context; +import android.test.ProviderTestCase2; +import android.test.suitebuilder.annotation.MediumTest; + +/** + * This is a series of medium tests for the Utility class. These tests must be locally + * complete - no server(s) required. + * + * You can run this entire test case with: + * runtest -c com.android.email.UtilityMediumTests email + */ +@MediumTest +public class UtilityMediumTests extends ProviderTestCase2 { + + EmailProvider mProvider; + Context mMockContext; + + public UtilityMediumTests() { + super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + mMockContext = getMockContext(); + } + + public void testFindExistingAccount() { + // Create two accounts + Account account1 = ProviderTestUtils.setupAccount("account1", false, mMockContext); + account1.mHostAuthRecv = ProviderTestUtils.setupHostAuth("ha1", -1, false, mMockContext); + account1.mHostAuthSend = ProviderTestUtils.setupHostAuth("ha1", -1, false, mMockContext); + account1.save(mMockContext); + Account account2 = ProviderTestUtils.setupAccount("account2", false, mMockContext); + account2.mHostAuthRecv = ProviderTestUtils.setupHostAuth("ha2", -1, false, mMockContext); + account2.mHostAuthSend = ProviderTestUtils.setupHostAuth("ha2", -1, false, mMockContext); + account2.save(mMockContext); + // Make sure we can find them + Account acct = Utility.findExistingAccount(mMockContext, -1, "address-ha1", "login-ha1"); + assertNotNull(acct); + assertEquals("account1", acct.mDisplayName); + acct = Utility.findExistingAccount(mMockContext, -1, "address-ha2", "login-ha2"); + assertNotNull(acct); + assertEquals("account2", acct.mDisplayName); + // We shouldn't find account + acct = Utility.findExistingAccount(mMockContext, -1, "address-ha3", "login-ha3"); + assertNull(acct); + // Try to find account1, excluding account1 + acct = Utility.findExistingAccount(mMockContext, account1.mId, "address-ha1", "login-ha1"); + assertNull(acct); + } +} diff --git a/tests/src/com/android/email/UtilityUnitTests.java b/tests/src/com/android/email/UtilityUnitTests.java index a2517d476..5375d859d 100644 --- a/tests/src/com/android/email/UtilityUnitTests.java +++ b/tests/src/com/android/email/UtilityUnitTests.java @@ -16,16 +16,13 @@ package com.android.email; -import com.android.email.provider.EmailProvider; -import com.android.email.provider.ProviderTestUtils; -import com.android.email.provider.EmailContent.Account; import com.android.email.provider.EmailContent.Mailbox; import android.content.Context; import android.graphics.drawable.Drawable; import android.telephony.TelephonyManager; +import android.test.AndroidTestCase; import android.test.MoreAsserts; -import android.test.ProviderTestCase2; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; @@ -40,45 +37,7 @@ import java.util.Set; * runtest -c com.android.email.UtilityUnitTests email */ @SmallTest -public class UtilityUnitTests extends ProviderTestCase2 { - - EmailProvider mProvider; - Context mMockContext; - - public UtilityUnitTests() { - super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - mMockContext = getMockContext(); - } - - public void testFindExistingAccount() { - // Create two accounts - Account account1 = ProviderTestUtils.setupAccount("account1", false, mMockContext); - account1.mHostAuthRecv = ProviderTestUtils.setupHostAuth("ha1", -1, false, mMockContext); - account1.mHostAuthSend = ProviderTestUtils.setupHostAuth("ha1", -1, false, mMockContext); - account1.save(mMockContext); - Account account2 = ProviderTestUtils.setupAccount("account2", false, mMockContext); - account2.mHostAuthRecv = ProviderTestUtils.setupHostAuth("ha2", -1, false, mMockContext); - account2.mHostAuthSend = ProviderTestUtils.setupHostAuth("ha2", -1, false, mMockContext); - account2.save(mMockContext); - // Make sure we can find them - Account acct = Utility.findExistingAccount(mMockContext, -1, "address-ha1", "login-ha1"); - assertNotNull(acct); - assertEquals("account1", acct.mDisplayName); - acct = Utility.findExistingAccount(mMockContext, -1, "address-ha2", "login-ha2"); - assertNotNull(acct); - assertEquals("account2", acct.mDisplayName); - // We shouldn't find accounts that don't exist - acct = Utility.findExistingAccount(mMockContext, -1, "address-ha3", "login-ha3"); - assertNull(acct); - // Try to find account1, excluding account1 - acct = Utility.findExistingAccount(mMockContext, account1.mId, "address-ha1", "login-ha1"); - assertNull(acct); - } +public class UtilityUnitTests extends AndroidTestCase { /** * Tests of the IMAP quoting rules function.