• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.rs.minimaltest;
18 
19 import android.content.Context;
20 
21 import androidx.test.InstrumentationRegistry;
22 import androidx.test.filters.MediumTest;
23 
24 import org.junit.Assert;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.junit.runners.Parameterized;
28 import org.junit.runners.Parameterized.Parameter;
29 import org.junit.runners.Parameterized.Parameters;
30 
31 import java.util.ArrayList;
32 import java.util.List;
33 
34 /**
35  * RsMinimalTest, minimal test for platform RenderScript APIs.
36  * To run the test, please use command
37  *
38  * adb shell am instrument -w com.android.rs.minimaltest/androidx.test.runner.AndroidJUnitRunner
39  */
40 @RunWith(Parameterized.class)
41 public class RsMinimalTest {
42     private static final String TAG = RsMinimalTest.class.getSimpleName();
43 
44     /**
45      * Returns the list of subclasses of UnitTest to run.
46      */
47     @Parameters(name = "{0}")
getParams()48     public static Iterable<?> getParams() throws Exception {
49         Context ctx = InstrumentationRegistry.getTargetContext();
50 
51         List<UnitTest> validUnitTests = new ArrayList<>();
52 
53         Iterable<Class<? extends UnitTest>> testClasses =
54             UnitTest.getProperSubclasses(ctx);
55         for (Class<? extends UnitTest> testClass : testClasses) {
56             UnitTest test = testClass.getDeclaredConstructor(Context.class).newInstance(ctx);
57             validUnitTests.add(test);
58         }
59 
60         UnitTest.checkDuplicateNames(validUnitTests);
61 
62         return validUnitTests;
63     }
64 
65     @Parameter(0)
66     public UnitTest mTest;
67 
68     @Test
69     @MediumTest
testRSUnitTest()70     public void testRSUnitTest() throws Exception {
71         mTest.logStart(TAG, "RenderScript Testing");
72         mTest.runTest();
73         mTest.logEnd(TAG);
74         Assert.assertTrue(mTest.getSuccess());
75     }
76 }
77