1 /* 2 * Copyright (C) 2015 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.cts.devicepolicy; 18 19 import com.android.ddmlib.Log.LogLevel; 20 import com.android.tradefed.log.LogUtil.CLog; 21 22 /** 23 * Common code for the various LauncherApps tests. 24 */ 25 public class BaseLauncherAppsTest extends BaseDevicePolicyTest { 26 27 protected static final String SIMPLE_APP_PKG = "com.android.cts.launcherapps.simpleapp"; 28 protected static final String SIMPLE_APP_APK = "CtsSimpleApp.apk"; 29 protected static final String LAUNCHER_TESTS_PKG = "com.android.cts.launchertests"; 30 protected static final String LAUNCHER_TESTS_CLASS = LAUNCHER_TESTS_PKG + ".LauncherAppsTests"; 31 protected static final String PARAM_TEST_USER = "testUser"; 32 33 protected static final String LAUNCHER_TESTS_APK = "CtsLauncherAppsTests.apk"; 34 protected static final String LAUNCHER_TESTS_SUPPORT_PKG = 35 "com.android.cts.launchertests.support"; 36 protected static final String LAUNCHER_TESTS_SUPPORT_APK = "CtsLauncherAppsTestsSupport.apk"; 37 38 protected void installTestApps(int userId) throws Exception { 39 installAppAsUser(LAUNCHER_TESTS_APK, userId); 40 installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, userId); 41 } 42 43 protected void uninstallTestApps() throws Exception { 44 getDevice().uninstallPackage(LAUNCHER_TESTS_PKG); 45 getDevice().uninstallPackage(LAUNCHER_TESTS_SUPPORT_PKG); 46 getDevice().uninstallPackage(SIMPLE_APP_PKG); 47 } 48 49 protected void startCallbackService(int userId) throws Exception { 50 String command = "am startservice --user " + userId 51 + " -a " + LAUNCHER_TESTS_SUPPORT_PKG + ".REGISTER_CALLBACK " 52 + LAUNCHER_TESTS_SUPPORT_PKG + "/.LauncherCallbackTestsService"; 53 CLog.d("Output for command " + command + ": " + getDevice().executeShellCommand(command)); 54 } 55 } 56