Home | History | Annotate | Download | only in devicepolicy
      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() throws Exception {
     39         uninstallTestApps();
     40         installAppAsUser(LAUNCHER_TESTS_APK, mPrimaryUserId);
     41         installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, mPrimaryUserId);
     42     }
     43 
     44     protected void uninstallTestApps() throws Exception {
     45         getDevice().uninstallPackage(LAUNCHER_TESTS_PKG);
     46         getDevice().uninstallPackage(LAUNCHER_TESTS_SUPPORT_PKG);
     47         getDevice().uninstallPackage(SIMPLE_APP_PKG);
     48     }
     49 
     50     protected void startCallbackService() throws Exception {
     51         String command = "am startservice --user " + mPrimaryUserId
     52                 + " -a " + LAUNCHER_TESTS_SUPPORT_PKG + ".REGISTER_CALLBACK "
     53                 + LAUNCHER_TESTS_SUPPORT_PKG + "/.LauncherCallbackTestsService";
     54         CLog.d("Output for command " + command + ": " + getDevice().executeShellCommand(command));
     55     }
     56 }
     57