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