summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Westbrook <pwestbro@google.com>2014-09-07 13:36:33 -0700
committerPaul Westbrook <pwestbro@google.com>2014-09-16 13:59:07 -0700
commitbb68c13afa630cae058eb40d3ce68644f3f3c8b9 (patch)
tree9a4d9d57f4d419a28b9f2576ef9c3783aa6e1f3a /tests
parent88929fd2bce947475d7a494961b017b98c5e9b82 (diff)
downloadandroid_packages_apps_Email-bb68c13afa630cae058eb40d3ce68644f3f3c8b9.tar.gz
android_packages_apps_Email-bb68c13afa630cae058eb40d3ce68644f3f3c8b9.tar.bz2
android_packages_apps_Email-bb68c13afa630cae058eb40d3ce68644f3f3c8b9.zip
Changes to support smaller email tombstone apk size
This reduces the tombstone down by 100K A follow-on cl will remove the unused resources from the tombstone build Bug: 17414014 Change-Id: I5d38811b17a5273ec726e750ab123e10e36cee04
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/email/NotificationControllerTest.java55
-rw-r--r--tests/src/com/android/email/activity/ContactStatusLoaderTest.java210
-rw-r--r--tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java3
-rw-r--r--tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java3
-rw-r--r--tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java3
5 files changed, 6 insertions, 268 deletions
diff --git a/tests/src/com/android/email/NotificationControllerTest.java b/tests/src/com/android/email/NotificationControllerTest.java
deleted file mode 100644
index 9e7f149c5..000000000
--- a/tests/src/com/android/email/NotificationControllerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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 android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.Suppress;
-
-/**
- * Test for {@link NotificationController}.
- *
- * TODO Add tests for all methods.
- */
-@Suppress
-public class NotificationControllerTest extends AndroidTestCase {
- private Context mProviderContext;
- private NotificationController mTarget;
-
- private final MockClock mMockClock = new MockClock();
- private int mRingerMode;
-
- /**
- * Subclass {@link NotificationController} to override un-mockable operations.
- */
- protected class NotificationControllerForTest extends NotificationController {
- NotificationControllerForTest(Context context) {
- super(context, mMockClock);
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProviderContext = DBTestHelper.ProviderContextSetupHelper.getProviderContext(mContext);
- mTarget = new NotificationControllerForTest(mProviderContext);
- }
-
- // the ringtone and vibration flags are depracated and the method that we use
- // to test notification has been removed in
- // https://googleplex-android-review.googlesource.com/#/c/271237/
-}
diff --git a/tests/src/com/android/email/activity/ContactStatusLoaderTest.java b/tests/src/com/android/email/activity/ContactStatusLoaderTest.java
deleted file mode 100644
index ebc946253..000000000
--- a/tests/src/com/android/email/activity/ContactStatusLoaderTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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.activity;
-
-import com.android.email.activity.ContactStatusLoader.Result;
-import com.android.mail.utils.MatrixCursorWithCachedColumns;
-
-import android.content.Context;
-import android.content.pm.ProviderInfo;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.graphics.Bitmap;
-import android.net.Uri;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.StatusUpdates;
-import android.test.ProviderTestCase2;
-import android.test.mock.MockContentProvider;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Queue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import junit.framework.Assert;
-
-/**
- * Test for {@link ContactStatusLoader}
- *
- * Unfortunately this doesn't check {@link ContactStatusLoader.Result#mLookupUri}, because we don't
- * (shouldn't) know how {@link android.provider.ContactsContract.Data#getContactLookupUri} is
- * implemented.
- */
-@SmallTest
-public class ContactStatusLoaderTest
- extends ProviderTestCase2<ContactStatusLoaderTest.MockContactProvider> {
- private static final String EMAIL = "a@b.c";
-
- private MockContactProvider mProvider;
-
- public ContactStatusLoaderTest() {
- super(MockContactProvider.class, ContactsContract.AUTHORITY);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProvider = getProvider();
- }
-
- // Contact doesn't exist
- public void brokentestContactNotFound() {
- // Insert empty cursor
- mProvider.mCursors.offer(new MatrixCursorWithCachedColumns(
- ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE));
-
- // Load!
- ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL);
- Result r = l.loadInBackground();
-
- // Check input to the provider
- assertEquals(1, mProvider.mUris.size());
- assertEquals("content://com.android.contacts/data/emails/lookup/a%40b.c",
- mProvider.mUris.get(0));
-
- // Check result
- assertNull(r.mPhoto);
- assertEquals(ContactStatusLoader.PRESENCE_UNKNOWN_RESOURCE_ID, r.mPresenceResId);
- }
-
- // Contact doesn't exist -- provider returns null for the first query
- public void brokentestNull() {
- // No cursor prepared. (Mock provider will return null)
-
- // Load!
- ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL);
- Result r = l.loadInBackground();
-
- // Check result
- assertNull(r.mPhoto);
- assertEquals(ContactStatusLoader.PRESENCE_UNKNOWN_RESOURCE_ID, r.mPresenceResId);
- }
-
- // Contact exists, but no photo
- public void brokentestNoPhoto() {
- // Result for the first query (the one for photo-id)
- MatrixCursor cursor1 =
- new MatrixCursorWithCachedColumns(ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE);
- cursor1.addRow(new Object[]{12345, StatusUpdates.AWAY});
- mProvider.mCursors.offer(cursor1);
-
- // Empty cursor for the second query
- mProvider.mCursors.offer(
- new MatrixCursorWithCachedColumns(ContactStatusLoader.PHOTO_PROJECTION));
-
- // Load!
- ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL);
- Result r = l.loadInBackground();
-
- // Check input to the provider
- // We should have had at least two queries from loadInBackground.
- // There can be extra queries from getContactLookupUri(), but this test shouldn't know
- // the details, so use ">= 2".
- assertTrue(mProvider.mUris.size() >= 2);
- assertEquals("content://com.android.contacts/data/emails/lookup/a%40b.c",
- mProvider.mUris.get(0));
- assertEquals("content://com.android.contacts/data/12345",
- mProvider.mUris.get(1));
-
- // Check result
- assertNull(r.mPhoto); // no photo
- assertEquals(android.R.drawable.presence_away, r.mPresenceResId);
- }
-
- // Contact exists, but no photo (provider returns null for the second query)
- public void brokentestNull2() {
- // Result for the first query (the one for photo-id)
- MatrixCursor cursor1 =
- new MatrixCursorWithCachedColumns(ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE);
- cursor1.addRow(new Object[]{12345, StatusUpdates.AWAY});
- mProvider.mCursors.offer(cursor1);
-
- // No cursor for the second query
-
- // Load!
- ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL);
- Result r = l.loadInBackground();
-
- // Check result
- assertNull(r.mPhoto); // no photo
- assertEquals(android.R.drawable.presence_away, r.mPresenceResId);
- }
-
- // Contact exists, with a photo
- public void brokentestWithPhoto() {
- // Result for the first query (the one for photo-id)
- MatrixCursor cursor1 =
- new MatrixCursorWithCachedColumns(ContactStatusLoader.PROJECTION_PHOTO_ID_PRESENCE);
- cursor1.addRow(new Object[]{12345, StatusUpdates.AWAY});
- mProvider.mCursors.offer(cursor1);
-
- // Prepare for the second query.
- MatrixCursor cursor2 = new PhotoCursor(createJpegData(10, 20));
- mProvider.mCursors.offer(cursor2);
-
- // Load!
- ContactStatusLoader l = new ContactStatusLoader(getMockContext(), EMAIL);
- Result r = l.loadInBackground();
-
- // Check result
- assertNotNull(r.mPhoto);
- assertEquals(10, r.mPhoto.getWidth());
- assertEquals(android.R.drawable.presence_away, r.mPresenceResId);
- }
-
- private static byte[] createJpegData(int width, int height) {
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
- return out.toByteArray();
- }
-
- // MatrixCursor doesn't support getBlob, so use this...
- private static class PhotoCursor extends MatrixCursorWithCachedColumns {
- private final byte[] mBlob;
-
- public PhotoCursor(byte[] blob) {
- super(ContactStatusLoader.PHOTO_PROJECTION);
- mBlob = blob;
- addRow(new Object[] {null}); // Add dummy row
- }
-
- @Override
- public byte[] getBlob(int column) {
- Assert.assertEquals(0, column);
- return mBlob;
- }
- }
-
- public static class MockContactProvider extends MockContentProvider {
- public ArrayList<String> mUris = new ArrayList<String>();
-
- public final Queue<Cursor> mCursors = new LinkedBlockingQueue<Cursor>();
-
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
- mUris.add(uri.toString());
- return mCursors.poll();
- }
-
- @Override
- public void attachInfo(Context context, ProviderInfo info) {
- }
- }
-}
diff --git a/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java b/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java
index bac1e68de..2e1566546 100644
--- a/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java
+++ b/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java
@@ -26,6 +26,7 @@ import android.view.View;
import android.widget.EditText;
import com.android.email.R;
+import com.android.email.setup.AuthenticatorSetupIntentHelper;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.HostAuth;
@@ -198,7 +199,7 @@ public class AccountSetupIncomingTests extends
auth.setHostAuthFromString(storeUriString);
final SetupDataFragment setupDataFragment =
new SetupDataFragment();
- setupDataFragment.setFlowMode(SetupDataFragment.FLOW_MODE_NORMAL);
+ setupDataFragment.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL);
setupDataFragment.setAccount(account);
final Intent i = new Intent(AccountSetupFinal.ACTION_JUMP_TO_INCOMING);
i.putExtra(SetupDataFragment.EXTRA_SETUP_DATA, setupDataFragment);
diff --git a/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java b/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java
index f1f9ae043..1e9ad8c1a 100644
--- a/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java
+++ b/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java
@@ -27,6 +27,7 @@ import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import com.android.email.R;
+import com.android.email.setup.AuthenticatorSetupIntentHelper;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.HostAuth;
@@ -173,7 +174,7 @@ public class AccountSetupOptionsTests
auth.setHostAuthFromString(storeUri);
final SetupDataFragment setupDataFragment =
new SetupDataFragment();
- setupDataFragment.setFlowMode(SetupDataFragment.FLOW_MODE_NORMAL);
+ setupDataFragment.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL);
setupDataFragment.setAccount(account);
final Intent i = new Intent(AccountSetupFinal.ACTION_JUMP_TO_OPTIONS);
i.putExtra(SetupDataFragment.EXTRA_SETUP_DATA, setupDataFragment);
diff --git a/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java b/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java
index 5cb6a949c..54b1e906c 100644
--- a/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java
+++ b/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java
@@ -26,6 +26,7 @@ import android.widget.CheckBox;
import android.widget.EditText;
import com.android.email.R;
+import com.android.email.setup.AuthenticatorSetupIntentHelper;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.HostAuth;
@@ -203,7 +204,7 @@ public class AccountSetupOutgoingTests extends
auth.setHostAuthFromString(senderUriString);
final SetupDataFragment setupDataFragment =
new SetupDataFragment();
- setupDataFragment.setFlowMode(SetupDataFragment.FLOW_MODE_NORMAL);
+ setupDataFragment.setFlowMode(AuthenticatorSetupIntentHelper.FLOW_MODE_NORMAL);
setupDataFragment.setAccount(account);
final Intent i = new Intent(AccountSetupFinal.ACTION_JUMP_TO_OUTGOING);
i.putExtra(SetupDataFragment.EXTRA_SETUP_DATA, setupDataFragment);