From d9cf94632f53bbde14596ac48f0fb8818808a0b4 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Sat, 23 Apr 2011 00:07:46 -0400 Subject: [PATCH] Fix some unit tests - some proguard flags were stale - some deprecated methods were legitimately stripped - kill the tests for them Bug: 4330508 Change-Id: I6d5c46c99d002895377f32b203844e9a6dcf0074 --- proguard.flags | 4 ++ src/com/android/email/mail/Transport.java | 10 ---- .../email/mail/transport/MailTransport.java | 15 ----- .../com/android/email/mail/StoreTests.java | 6 ++ .../email/mail/store/ImapStoreUnitTests.java | 3 +- .../transport/MailTransportUnitTests.java | 57 ------------------- 6 files changed, 12 insertions(+), 83 deletions(-) delete mode 100644 tests/src/com/android/email/mail/transport/MailTransportUnitTests.java diff --git a/proguard.flags b/proguard.flags index 0f6c90aaf..b39a18242 100644 --- a/proguard.flags +++ b/proguard.flags @@ -192,6 +192,10 @@ *** getBody(); } +-keepclasseswithmembers class com.android.email.mail.FolderProperties { + *** getDisplayName(int); +} + # The following classes are used only by unit tests. # We should move them into tests/ if possible. diff --git a/src/com/android/email/mail/Transport.java b/src/com/android/email/mail/Transport.java index 3de50f5ac..2a30d021d 100644 --- a/src/com/android/email/mail/Transport.java +++ b/src/com/android/email/mail/Transport.java @@ -55,16 +55,6 @@ public interface Transport { */ public Transport newInstanceWithConfiguration(); - /** - * Set the Uri for the connection. - * - * @param uri The Uri for the connection - * @param defaultPort If the Uri does not include an explicit port, this value will be used. - * @deprecated use the individual methods {@link #setHost(String)} and {@link #setPort(int)} - */ - @Deprecated - public void setUri(URI uri, int defaultPort); - /** * Sets the host */ diff --git a/src/com/android/email/mail/transport/MailTransport.java b/src/com/android/email/mail/transport/MailTransport.java index 6ae40b70e..09541f4a6 100644 --- a/src/com/android/email/mail/transport/MailTransport.java +++ b/src/com/android/email/mail/transport/MailTransport.java @@ -98,21 +98,6 @@ public class MailTransport implements Transport { return newObject; } - @Override - @Deprecated - public void setUri(URI uri, int defaultPort) { - mHost = uri.getHost(); - - mPort = defaultPort; - if (uri.getPort() != -1) { - mPort = uri.getPort(); - } - - if (uri.getUserInfo() != null) { - mUserInfoParts = uri.getUserInfo().split(":", 2); - } - } - @Override @Deprecated public String[] getUserInfoParts() { diff --git a/tests/src/com/android/email/mail/StoreTests.java b/tests/src/com/android/email/mail/StoreTests.java index 91db0f21f..8ce70023b 100644 --- a/tests/src/com/android/email/mail/StoreTests.java +++ b/tests/src/com/android/email/mail/StoreTests.java @@ -30,6 +30,12 @@ import android.test.suitebuilder.annotation.MediumTest; */ @MediumTest public class StoreTests extends AndroidTestCase { + + @Override + public void setUp() { + Store.sStores.clear(); + } + public void testGetStoreKey() throws MessagingException { HostAuth testAuth = new HostAuth(); Account testAccount = new Account(); diff --git a/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java b/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java index f3afbdc58..d6b6aa066 100644 --- a/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java +++ b/tests/src/com/android/email/mail/store/ImapStoreUnitTests.java @@ -102,7 +102,8 @@ public class ImapStoreUnitTests extends InstrumentationTestCase { @Override protected void setUp() throws Exception { super.setUp(); - mTestContext = getInstrumentation().getContext(); + // TODO: this should really use a mock context. + mTestContext = getInstrumentation().getTargetContext(); // Use the target's (i.e. the Email application) context TempDirectory.setTempDirectory(getInstrumentation().getTargetContext()); diff --git a/tests/src/com/android/email/mail/transport/MailTransportUnitTests.java b/tests/src/com/android/email/mail/transport/MailTransportUnitTests.java deleted file mode 100644 index 8c3298625..000000000 --- a/tests/src/com/android/email/mail/transport/MailTransportUnitTests.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2008 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.mail.transport; - -import com.android.email.mail.transport.MailTransport; - -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; - -import java.net.URI; -import java.net.URISyntaxException; - -/** - * Simple unit tests for MailSender. Tests here should not attempt any actual connections. - */ -@SmallTest -public class MailTransportUnitTests extends AndroidTestCase { - - /** - * Tests of the Uri parsing logic - */ - public void testUriParsing() throws URISyntaxException { - - // Parse with everything in the Uri - URI uri = new URI("smtp://user:password@server.com:999"); - MailTransport transport = new MailTransport("SMTP"); - transport.setUri(uri, 888); - assertEquals("server.com", transport.getHost()); - assertEquals(999, transport.getPort()); - String[] userInfoParts = transport.getUserInfoParts(); - assertNotNull(userInfoParts); - assertEquals("user", userInfoParts[0]); - assertEquals("password", userInfoParts[1]); - - // Parse with no user/password (e.g. anonymous SMTP) - uri = new URI("smtp://server.com:999"); - transport = new MailTransport("SMTP"); - transport.setUri(uri, 888); - assertEquals("server.com", transport.getHost()); - assertEquals(999, transport.getPort()); - assertNull(transport.getUserInfoParts()); - } -}