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