• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# /usr/bin/env python3
2#
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy of
7# the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17import os
18
19from acts.metrics.core import ProtoMetric
20from acts.metrics.logger import MetricLogger
21from acts_contrib.test_utils.tel.loggers.protos.telephony_metric_pb2 import TelephonyVoiceTestResult
22
23# Initializes the path to the protobuf
24PROTO_PATH = os.path.join(os.path.dirname(__file__), 'protos',
25                          'telephony_metric.proto')
26
27
28class TelephonyMetricLogger(MetricLogger):
29    """A logger for gathering Telephony test metrics
30
31    Attributes:
32        proto: Module used to store Telephony metrics in a proto
33    """
34
35    def __init__(self, event):
36        super().__init__(event=event)
37        self.proto = TelephonyVoiceTestResult()
38
39    def set_result(self, result_type):
40        self.proto.result = result_type
41
42    def end(self, event):
43        metric = ProtoMetric(name='telephony_voice_test_result',
44                             data=self.proto)
45        return self.publisher.publish(metric)
46