Home | History | Annotate | Download | only in targetprep
      1 /*
      2  * Copyright (C) 2010 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.tradefed.targetprep;
     18 
     19 import com.android.ddmlib.Log;
     20 import com.android.tradefed.build.DeviceBuildInfo;
     21 import com.android.tradefed.build.IBuildInfo;
     22 import com.android.tradefed.build.IDeviceBuildInfo;
     23 import com.android.tradefed.device.ITestDevice;
     24 import com.android.tradefed.testtype.DeviceTestCase;
     25 
     26 /**
     27  * Functional tests for {@link DeviceSetup}.
     28  */
     29 public class DeviceSetupFuncTest extends DeviceTestCase {
     30 
     31     private static final String LOG_TAG = "DeviceSetupFuncTest";
     32     private DeviceSetup mDeviceSetup;
     33     private IDeviceBuildInfo mMockBuildInfo;
     34 
     35     /**
     36      * {@inheritDoc}
     37      */
     38     @Override
     39     protected void setUp() throws Exception {
     40         super.setUp();
     41 
     42         mMockBuildInfo = new DeviceBuildInfo("0", "");
     43         mDeviceSetup = new DeviceSetup();
     44     }
     45 
     46     /**
     47      * Simple normal case test for {@link DeviceSetup#setUp(ITestDevice, IBuildInfo)}.
     48      * <p/>
     49      * Do setup and verify a few expected properties
     50      */
     51     public void testSetup() throws Exception {
     52         Log.i(LOG_TAG, "testSetup()");
     53 
     54         // reset expected property
     55         getDevice().executeShellCommand("setprop ro.audio.silent 0");
     56         mDeviceSetup.setUp(getDevice(), mMockBuildInfo);
     57         assertTrue(getDevice().executeShellCommand("getprop ro.audio.silent").contains("1"));
     58         assertTrue(getDevice().executeShellCommand("getprop ro.monkey").contains("1"));
     59         assertTrue(getDevice().executeShellCommand("getprop ro.test_harness").contains("1"));
     60         // verify root
     61         assertTrue(getDevice().executeShellCommand("id").contains("root"));
     62     }
     63 }
     64