1 /* 2 * Copyright (C) 2018 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 android.cts.statsd.metadata; 18 19 import android.cts.statsd.atom.AtomTestCase; 20 import com.android.internal.os.StatsdConfigProto; 21 import com.android.internal.os.StatsdConfigProto.StatsdConfig; 22 import com.android.os.AtomsProto.Atom; 23 import com.android.os.StatsLog.StatsdStatsReport; 24 import com.android.tradefed.log.LogUtil; 25 26 public class MetadataTestCase extends AtomTestCase { 27 public static final String DUMP_METADATA_CMD = "cmd stats print-stats"; 28 getStatsdStatsReport()29 protected StatsdStatsReport getStatsdStatsReport() throws Exception { 30 try { 31 StatsdStatsReport report = getDump(StatsdStatsReport.parser(), 32 String.join(" ", DUMP_METADATA_CMD, "--proto")); 33 return report; 34 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 35 LogUtil.CLog.e("Failed to fetch and parse the statsdstats output report."); 36 throw (e); 37 } 38 } 39 getBaseConfig()40 protected final StatsdConfig.Builder getBaseConfig() throws Exception { 41 StatsdConfig.Builder builder = createConfigBuilder(); 42 addAtomEvent(builder, Atom.APP_BREADCRUMB_REPORTED_FIELD_NUMBER); 43 return builder; 44 } 45 } 46