Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2009 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;
     18 
     19 import java.io.IOException;
     20 
     21 /**
     22  * The host side only package.
     23  */
     24 public class HostSideOnlyPackage extends TestPackage {
     25 
     26     /**
     27      * Construct a host side only package with given necessary information.
     28      *
     29      * @param testPkgBinaryName The binary name of the TestPackage.
     30      * @param version The version of the CTS Host allowed.
     31      * @param androidVersion The version of the Android platform allowed.
     32      * @param jarPath The host controller's jar path and file.
     33      * @param appPackageName The Java package name of the test package.
     34      */
     35     public HostSideOnlyPackage(final String testPkgBinaryName, final String version,
     36             final String androidVersion, final String jarPath,
     37             final String appPackageName) {
     38         super(null, testPkgBinaryName, null, null, version,
     39                 androidVersion, jarPath, null, appPackageName, null);
     40     }
     41 
     42     /** {@inheritDoc} */
     43     @Override
     44     public boolean isHostSideOnly() {
     45         return true;
     46     }
     47 
     48     /** {@inheritDoc} */
     49     @Override
     50     protected void runImpl(final String javaPkgName)
     51             throws IOException, DeviceDisconnectedException, ADBServerNeedRestartException {
     52         try {
     53             if (!mTestStop) {
     54                 Log.d("run in individual mode...");
     55                 runInIndividualMode(javaPkgName);
     56             }
     57         } catch (DeviceDisconnectedException e) {
     58             cleanUp();
     59             throw e;
     60         }
     61     }
     62 
     63     /** {@inheritDoc} */
     64     @Override
     65     protected void runTestImpl(final Test test) throws DeviceDisconnectedException,
     66                 ADBServerNeedRestartException {
     67         try {
     68             if (!mTestStop) {
     69                 mCurrentTestSuite = test.getTestSuite();
     70                 mCurrentTestSuite.run(mDevice, test);
     71             }
     72         } catch (DeviceDisconnectedException e) {
     73             cleanUp();
     74             throw e;
     75         }
     76     }
     77 }
     78