Home | History | Annotate | Download | only in device
      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 package com.android.cts.tradefed.device;
     17 
     18 import com.android.cts.tradefed.UnitTests;
     19 import com.android.tradefed.build.BuildInfo;
     20 import com.android.tradefed.device.DeviceNotAvailableException;
     21 import com.android.tradefed.result.CollectingTestListener;
     22 import com.android.tradefed.testtype.DeviceTestCase;
     23 
     24 import java.io.File;
     25 import java.util.Map;
     26 
     27 /**
     28  * Functional test for {@link DeviceInfoCollector}.
     29  * <p/>
     30  * TODO: this test assumes the TestDeviceSetup apk is located in the "java.io.tmpdir"
     31  */
     32 public class DeviceInfoCollectorFuncTest extends DeviceTestCase {
     33 
     34     public void testCollectDeviceInfo() throws DeviceNotAvailableException {
     35         CollectingTestListener testListener = new CollectingTestListener();
     36 
     37         testListener.invocationStarted(new BuildInfo());
     38         DeviceInfoCollector.collectDeviceInfo(getDevice(), UnitTests.ABI.getName(), new File(
     39                 System.getProperty("java.io.tmpdir")), testListener);
     40         assertNotNull(testListener.getCurrentRunResults());
     41         assertTrue(testListener.getCurrentRunResults().getRunMetrics().size() > 0);
     42         for (Map.Entry<String, String> metricEntry : testListener.getCurrentRunResults().getRunMetrics().entrySet()) {
     43             System.out.println(String.format("%s=%s", metricEntry.getKey(), metricEntry.getValue()));
     44         }
     45         testListener.invocationEnded(0);
     46     }
     47 }
     48