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 static org.junit.Assert.*;
     20 
     21 import com.android.ddmlib.Log;
     22 import com.android.tradefed.build.DeviceBuildInfo;
     23 import com.android.tradefed.build.IBuildInfo;
     24 import com.android.tradefed.build.IDeviceBuildInfo;
     25 import com.android.tradefed.device.ITestDevice;
     26 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
     27 import com.android.tradefed.testtype.IDeviceTest;
     28 
     29 import org.junit.Before;
     30 import org.junit.Test;
     31 import org.junit.runner.RunWith;
     32 
     33 /** Functional tests for {@link DeviceSetup}. */
     34 @RunWith(DeviceJUnit4ClassRunner.class)
     35 public class DeviceSetupFuncTest implements IDeviceTest {
     36 
     37     private static final String LOG_TAG = "DeviceSetupFuncTest";
     38     private DeviceSetup mDeviceSetup;
     39     private ITestDevice mDevice;
     40     private IDeviceBuildInfo mMockBuildInfo;
     41 
     42     @Override
     43     public void setDevice(ITestDevice device) {
     44         mDevice = device;
     45     }
     46 
     47     @Override
     48     public ITestDevice getDevice() {
     49         return mDevice;
     50     }
     51 
     52     @Before
     53     public void setUp() throws Exception {
     54         mMockBuildInfo = new DeviceBuildInfo("0", "");
     55         mDeviceSetup = new DeviceSetup();
     56     }
     57 
     58     /**
     59      * Simple normal case test for {@link DeviceSetup#setUp(ITestDevice, IBuildInfo)}.
     60      *
     61      * <p>Do setup and verify a few expected properties
     62      */
     63     @Test
     64     public void testSetup() throws Exception {
     65         Log.i(LOG_TAG, "testSetup()");
     66 
     67         // reset expected property
     68         getDevice().executeShellCommand("setprop ro.audio.silent 0");
     69         mDeviceSetup.setUp(getDevice(), mMockBuildInfo);
     70         assertTrue(getDevice().executeShellCommand("getprop ro.audio.silent").contains("1"));
     71         assertTrue(getDevice().executeShellCommand("getprop ro.monkey").contains("1"));
     72         assertTrue(getDevice().executeShellCommand("getprop ro.test_harness").contains("1"));
     73         // verify root
     74         assertTrue(getDevice().executeShellCommand("id").contains("root"));
     75     }
     76 }
     77