1 /* 2 * Copyright (C) 2018 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 android.content.res.AssetManager; 19 20 import androidx.test.InstrumentationRegistry; 21 import androidx.test.filters.SmallTest; 22 23 import org.junit.Test; 24 import org.junit.runner.RunWith; 25 import org.junit.runners.Parameterized; 26 import org.junit.runners.Parameterized.Parameters; 27 28 import java.util.Arrays; 29 30 @SmallTest 31 @RunWith(Parameterized.class) 32 public class BasicVulkanGpuTest { 33 34 static { 35 System.loadLibrary("ctsgraphics_jni"); 36 } 37 38 @Parameters(name = "{0}") data()39 public static Iterable<Object[]> data() { 40 return Arrays.asList(new Object[][] { 41 {"AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM", 1}, 42 {"AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM", 2}, 43 {"AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM", 3}, 44 {"AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM", 4}, 45 {"AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM", 43}, 46 // TODO(ericrk): Test float and non-renderable formats. 47 }); 48 } 49 50 private int mFormat; 51 BasicVulkanGpuTest(String name, int format)52 public BasicVulkanGpuTest(String name, int format) { 53 mFormat = format; 54 } 55 56 @Test testBasicBufferImportAndRenderingExplicitFormat()57 public void testBasicBufferImportAndRenderingExplicitFormat() throws Exception { 58 verifyBasicBufferImport(InstrumentationRegistry.getContext().getAssets(), mFormat, false); 59 } 60 61 @Test testBasicBufferImportAndRenderingExternalFormat()62 public void testBasicBufferImportAndRenderingExternalFormat() throws Exception { 63 verifyBasicBufferImport(InstrumentationRegistry.getContext().getAssets(), mFormat, true); 64 } 65 verifyBasicBufferImport(AssetManager assetManager, int format, boolean useExternalFormat)66 private static native void verifyBasicBufferImport(AssetManager assetManager, int format, 67 boolean useExternalFormat); 68 } 69