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 package android.graphics.cts; 17 18 import static org.junit.Assert.assertEquals; 19 20 import android.graphics.Bitmap; 21 import android.graphics.Bitmap.Config; 22 import android.graphics.Canvas; 23 import android.graphics.Canvas.VertexMode; 24 import android.graphics.Paint; 25 import android.support.test.filters.SmallTest; 26 import android.support.test.runner.AndroidJUnit4; 27 28 import org.junit.Test; 29 import org.junit.runner.RunWith; 30 31 @SmallTest 32 @RunWith(AndroidJUnit4.class) 33 public class Canvas_VertexModeTest { 34 @Test 35 public void testValueOf(){ 36 assertEquals(VertexMode.TRIANGLES, VertexMode.valueOf("TRIANGLES")); 37 assertEquals(VertexMode.TRIANGLE_STRIP, VertexMode.valueOf("TRIANGLE_STRIP")); 38 assertEquals(VertexMode.TRIANGLE_FAN, VertexMode.valueOf("TRIANGLE_FAN")); 39 } 40 41 @Test 42 public void testValues(){ 43 VertexMode[] verMode = VertexMode.values(); 44 45 assertEquals(3, verMode.length); 46 assertEquals(VertexMode.TRIANGLES, verMode[0]); 47 assertEquals(VertexMode.TRIANGLE_STRIP, verMode[1]); 48 assertEquals(VertexMode.TRIANGLE_FAN, verMode[2]); 49 50 float[] verts = new float[10]; 51 float[] texs = new float[10]; 52 short[] indices = { 0, 1, 2, 3, 4, 1 }; 53 54 Bitmap bitmap = Bitmap.createBitmap(10, 27, Config.RGB_565); 55 Canvas c = new Canvas(bitmap); 56 57 //VertexMode is used as a argument here for all the methods that use it 58 c.drawVertices( VertexMode.TRIANGLES, 59 2, 60 verts, 61 0, 62 texs, 63 0, 64 new int[]{10, 24}, 65 0, 66 indices, 67 0, 68 4, 69 new Paint()); 70 71 c.drawVertices( VertexMode.TRIANGLE_STRIP, 72 2, 73 verts, 74 0, 75 texs, 76 0, 77 new int[]{10, 24}, 78 0, 79 indices, 80 0, 81 4, 82 new Paint()); 83 84 c.drawVertices( VertexMode.TRIANGLE_FAN, 85 10, 86 verts, 87 0, 88 texs, 89 0, 90 null, 91 0, 92 null, 93 0, 94 0, 95 new Paint()); 96 } 97 } 98