1/* 2 * Copyright (C) 2017 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 */ 16package com.android.settingslib; 17 18import org.junit.runners.model.InitializationError; 19import org.robolectric.RobolectricTestRunner; 20import org.robolectric.annotation.Config; 21import org.robolectric.manifest.AndroidManifest; 22import org.robolectric.res.Fs; 23 24public class SettingLibRobolectricTestRunner extends RobolectricTestRunner { 25 26 public SettingLibRobolectricTestRunner(Class<?> testClass) throws InitializationError { 27 super(testClass); 28 } 29 30 @Override 31 protected AndroidManifest getAppManifest(Config config) { 32 // Using the manifest file's relative path, we can figure out the application directory. 33 final String appRoot = "frameworks/base/packages/SettingsLib"; 34 final String manifestPath = appRoot + "/AndroidManifest.xml"; 35 final String resDir = appRoot + "/tests/robotests/res"; 36 final String assetsDir = appRoot + config.assetDir(); 37 38 final AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(manifestPath), 39 Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)); 40 41 manifest.setPackageName("com.android.settingslib"); 42 return manifest; 43 } 44 45} 46