1#!/usr/bin/env python3
2#
3#   Copyright 2021 - The Android Open Source Project
4#
5##   Licensed under the Apache License, Version 2.0 (the 'License');
6##   you may not use this file except in compliance with the License.
7##   You may obtain a copy of 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,
13##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14##   See the License for the specific language governing permissions and
15##   limitations under the License.
16
17from acts_contrib.test_utils.gnss import LabTtffTestBase as lttb
18from acts_contrib.test_utils.gnss.gnss_test_utils import launch_eecoexer
19from acts_contrib.test_utils.gnss.gnss_test_utils import execute_eecoexer_function
20
21
22
23class LabTtffGeneralCoexTest(lttb.LabTtffTestBase):
24    """Lab stand alone GNSS general coex TTFF/FFPE test"""
25
26    def setup_class(self):
27        super().setup_class()
28        req_params = ['coex_testcase_ls']
29        self.unpack_userparams(req_param_names=req_params)
30        self.test_cmd = ''
31        self.stop_cmd = ''
32
33    def setup_test(self):
34        super().setup_test()
35        launch_eecoexer(self.dut)
36        # Set DUT temperature the limit to 60 degree
37        self.dut.adb.shell(
38            'setprop persist.com.google.eecoexer.cellular.temperature_limit 60')
39
40    def teardown_test(self):
41        super().teardown_test()
42        self.exe_eecoexer_loop_cmd(self.stop_cmd)
43
44    def gnss_ttff_ffpe_coex_base(self, mode):
45        """
46        TTFF and FFPE general coex base test function
47
48            Args:
49                mode: Set the TTFF mode for testing. Definitions are as below.
50                cs(cold start), ws(warm start), hs(hot start)
51        """
52        # Loop all test case in coex_testcase_ls
53        for i, test_item in enumerate(self.coex_testcase_ls):
54
55            if i > 0:
56                self.setup_test()
57
58            # get test_log_path from coex_testcase_ls['test_name']
59            test_log_path = test_item['test_name']
60
61            # get test_cmd from coex_testcase_ls['test_cmd']
62            self.test_cmd = test_item['test_cmd']
63
64            # get stop_cmd from coex_testcase_ls['stop_cmd']
65            self.stop_cmd = test_item['stop_cmd']
66
67            # Start aggressor Tx by EEcoexer
68            # self.exe_eecoexer_loop_cmd(test_cmd)
69
70            # Start GNSS TTFF FFPE testing
71            self.gnss_ttff_ffpe(mode, test_log_path, self.test_cmd, self.stop_cmd)
72
73            # Stop aggressor Tx by EEcoexer
74            # self.exe_eecoexer_loop_cmd(stop_cmd)
75
76            # Clear GTW GPSTool log. Need to clean the log every round of the test.
77            self.clear_gps_log()
78
79            if i < len(self.coex_testcase_ls) - 1:
80                self.teardown_test()
81
82    def test_gnss_cold_ttff_ffpe_coex(self):
83        """
84        Cold start TTFF and FFPE GNSS general coex testing
85        """
86        self.gnss_ttff_ffpe_coex_base('cs')
87
88    def test_gnss_warm_ttff_ffpe_coex(self):
89        """
90        Warm start TTFF and FFPE GNSS general coex testing
91        """
92        self.gnss_ttff_ffpe_coex_base('ws')
93
94    def test_gnss_hot_ttff_ffpe_coex(self):
95        """
96        Hot start TTFF and FFPE GNSS general coex testing
97        """
98        self.gnss_ttff_ffpe_coex_base('hs')
99