Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2008 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 android.graphics.cts;
     18 
     19 import junit.framework.TestCase;
     20 import android.graphics.Bitmap;
     21 import android.graphics.Canvas;
     22 import android.graphics.LayerRasterizer;
     23 import android.graphics.Paint;
     24 import android.graphics.Rasterizer;
     25 
     26 public class LayerRasterizerTest extends TestCase {
     27     private final static int BITMAP_WIDTH = 16;
     28     private final static int BITMAP_HEIGHT = 16;
     29 
     30     private void exerciseRasterizer(Rasterizer rasterizer) {
     31         Bitmap bm = Bitmap.createBitmap(BITMAP_WIDTH, BITMAP_HEIGHT, Bitmap.Config.ARGB_8888);
     32         Canvas canvas = new Canvas(bm);
     33         Paint paint = new Paint();
     34 
     35         // just want to confirm that we don't crash or throw an exception
     36         paint.setRasterizer(rasterizer);
     37         canvas.drawCircle(BITMAP_WIDTH/2, BITMAP_WIDTH/2, BITMAP_WIDTH/2, paint);
     38     }
     39 
     40     public void testConstructor() {
     41         exerciseRasterizer(new LayerRasterizer());
     42     }
     43 
     44     public void testAddLayer1() {
     45         LayerRasterizer layerRasterizer = new LayerRasterizer();
     46         Paint p = new Paint();
     47         layerRasterizer.addLayer(p);
     48         exerciseRasterizer(layerRasterizer);
     49     }
     50 
     51     public void testAddLayer2() {
     52         LayerRasterizer layerRasterizer = new LayerRasterizer();
     53         layerRasterizer.addLayer(new Paint(), 1.0f, 1.0f);
     54         exerciseRasterizer(layerRasterizer);
     55         // explicitly add another layer and draw again
     56         layerRasterizer.addLayer(new Paint(), 2.0f, 2.0f);
     57         exerciseRasterizer(layerRasterizer);
     58     }
     59 
     60 }
     61