1 /* 2 * Copyright (C) 2012 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.providers.contacts; 18 19 import android.graphics.Bitmap; 20 import android.graphics.Color; 21 import android.graphics.drawable.BitmapDrawable; 22 import android.graphics.drawable.Drawable; 23 import android.test.AndroidTestCase; 24 import android.test.suitebuilder.annotation.SmallTest; 25 26 import com.android.providers.contacts.tests.R; 27 28 29 /** 30 * Tests for {@link PhotoProcessor}. 31 * 32 * Most of tests are covered by {@link PhotoStoreTest}. 33 */ 34 @SmallTest 35 public class PhotoProcessorTest extends AndroidTestCase { 36 37 public void testTransparency() { 38 final Drawable source = getTestContext().getResources().getDrawable( 39 R.drawable.transparent_10x10); 40 final Bitmap sourceBitmap = ((BitmapDrawable) source).getBitmap(); 41 42 final Bitmap normalized = PhotoProcessor.getNormalizedBitmap(sourceBitmap, 50, false); 43 44 // Make sure it's not scaled up. 45 assertEquals(10, normalized.getWidth()); 46 assertEquals(10, normalized.getHeight()); 47 48 // Make sure the transparent pixel is now 100% white. 49 assertEquals(Color.argb(255, 255, 255, 255), normalized.getPixel(0, 0)); 50 } 51 } 52