156ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad/* 256ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * Copyright (C) 2017 The Android Open Source Project 356ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * 456ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * Licensed under the Apache License, Version 2.0 (the "License"); 556ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * you may not use this file except in compliance with the License. 656ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * You may obtain a copy of the License at 756ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * 856ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * http://www.apache.org/licenses/LICENSE-2.0 956ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * 1056ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * Unless required by applicable law or agreed to in writing, software 1156ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * distributed under the License is distributed on an "AS IS" BASIS, 1256ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1356ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * See the License for the specific language governing permissions and 1456ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad * limitations under the License. 1556ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad */ 1656ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadpackage com.android.settingslib; 1756ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 1856ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadimport org.junit.runners.model.InitializationError; 1956ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadimport org.robolectric.RobolectricTestRunner; 2056ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadimport org.robolectric.annotation.Config; 2156ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadimport org.robolectric.manifest.AndroidManifest; 2256ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadimport org.robolectric.res.Fs; 2356ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 2456ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryadpublic class SettingLibRobolectricTestRunner extends RobolectricTestRunner { 2556ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 2656ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad public SettingLibRobolectricTestRunner(Class<?> testClass) throws InitializationError { 2756ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad super(testClass); 2856ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad } 2956ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 3056ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad @Override 3156ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad protected AndroidManifest getAppManifest(Config config) { 3256ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad // Using the manifest file's relative path, we can figure out the application directory. 3356ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad final String appRoot = "frameworks/base/packages/SettingsLib"; 3456ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad final String manifestPath = appRoot + "/AndroidManifest.xml"; 3556ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad final String resDir = appRoot + "/tests/robotests/res"; 3656ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad final String assetsDir = appRoot + config.assetDir(); 3756ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 3856ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad final AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(manifestPath), 3956ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)); 4056ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 4156ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad manifest.setPackageName("com.android.settingslib"); 4256ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad return manifest; 4356ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad } 4456ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad 4556ce766e92ac39ae2bb05e2a0040f80b860364c9Soroosh Mariooryad} 46