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.angleIntegrationTest.driverTest; 18 19 import static org.junit.Assert.fail; 20 21 import androidx.test.rule.ActivityTestRule; 22 import androidx.test.runner.AndroidJUnit4; 23 24 import com.android.angleIntegrationTest.common.AngleIntegrationTestActivity; 25 import com.android.angleIntegrationTest.common.GlesView; 26 27 import org.junit.Rule; 28 import org.junit.Test; 29 import org.junit.runner.RunWith; 30 31 @RunWith(AndroidJUnit4.class) 32 public class AngleDriverTestActivity { 33 34 private final String TAG = this.getClass().getSimpleName(); 35 36 @Rule 37 public ActivityTestRule<AngleIntegrationTestActivity> rule = 38 new ActivityTestRule<>(AngleIntegrationTestActivity.class); 39 validateDeveloperOption(boolean angleEnabled)40 private void validateDeveloperOption(boolean angleEnabled) throws Exception { 41 AngleIntegrationTestActivity activity = rule.getActivity(); 42 GlesView glesView = activity.getGlesView(); 43 String renderer = glesView.getRenderer(); 44 45 while(renderer.length() == 0) { 46 renderer = glesView.getRenderer(); 47 } 48 49 if (angleEnabled) { 50 if (!renderer.toLowerCase().contains("ANGLE".toLowerCase())) { 51 fail("Failure - ANGLE was not loaded: '" + renderer + "'"); 52 } 53 } else { 54 if (renderer.toLowerCase().contains("ANGLE".toLowerCase())) { 55 fail("Failure - ANGLE was loaded: '" + renderer + "'"); 56 } 57 } 58 59 } 60 61 @Test testUseDefaultDriver()62 public void testUseDefaultDriver() throws Exception { 63 // The rules file does not enable ANGLE for this app 64 validateDeveloperOption(false); 65 } 66 67 @Test testUseAngleDriver()68 public void testUseAngleDriver() throws Exception { 69 validateDeveloperOption(true); 70 } 71 72 @Test testUseNativeDriver()73 public void testUseNativeDriver() throws Exception { 74 validateDeveloperOption(false); 75 } 76 } 77