• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import common
6import unittest
7import cell_tools
8import cellular_logging
9
10
11import dbus
12
13from autotest_lib.client.cros.cellular import labconfig
14# Mock out routing in the network file
15import mock
16import sys
17sys.modules['routing'] = mock.MagicMock()
18from autotest_lib.client.cros import network
19import flimflam
20import base_station_pxt
21import prologix_scpi_driver
22import scpi
23import environment
24
25config = labconfig.Configuration(['--cell', 'mtv', '--technology', 'LTE'])
26import time
27
28logger = cellular_logging.SetupCellularLogging('cell_tools_test')
29
30technology_lte = 'Technology:LTE'
31
32
33class test_cell_tools(unittest.TestCase):
34
35    def test_CellularSmokeNoCallBoxSetup(self):
36        self._reset_everything()
37        logger.debug('making flimflam object..')
38        self.flim = flimflam.FlimFlam()
39        logger.debug('Find Cellular Device ...')
40        self.device = self.flim.FindCellularDevice()
41        logger.debug('Find Celluar Service..')
42        self.service = self.flim.FindCellularService()
43        logger.debug('Set Auto Connect to False ..')
44        self.service.SetProperty('AutoConnect', dbus.Boolean(False))
45
46        logger.debug('Reset all modems ..')
47        network.ResetAllModems(self.flim)
48        logger.debug('Prepare Modem for LTE..')
49        cell_tools.PrepareModemForTechnology('', 'Technology:LTE')
50
51        logger.debug('Make another flimflam..')
52        self.flim = flimflam.FlimFlam()
53        logger.debug('Sleep for 5...')
54        time.sleep(5)
55        logger.debug('Connect to Cellular...')
56        cell_tools.ConnectToCellular(self.flim, timeout=60)
57        logger.debug('Clearing errors...')
58        env.emulator.ClearErrors()
59        logger.debug('Check connect to cellular ...')
60        service = env.CheckedConnectToCellular()
61
62    def test_TurnOnPxtAndConnectToCellularWorks(self):
63        self._reset_everything()
64        self.flim = flimflam.FlimFlam()
65        #self.device = self.flim.FindCellularDevice()
66        self.service = self.flim.FindCellularService()
67        self.service.SetProperty('AutoConnect', dbus.Boolean(False))
68        with environment.DefaultCellularTestContext(config) as c:
69            env = c.env
70            env.StartDefault(technology_lte)
71            self.flim = flimflam.FlimFlam()  # because the manger destroys it?
72            cell_tools.ConnectToCellular(self.flim, timeout=60)
73
74    def test_TurnOnPxtAndConnectToCellularWorksAddSmoke(self):
75        self._reset_everything()
76        self.flim = flimflam.FlimFlam()
77        #self.device = self.flim.FindCellularDevice()
78        self.service = self.flim.FindCellularService()
79        self.service.SetProperty('AutoConnect', dbus.Boolean(False))
80        with environment.DefaultCellularTestContext(config) as c:
81            env = c.env
82            env.StartDefault(technology_lte)
83            cell_tools.PrepareModemForTechnology('', technology_lte)
84            self.flim = flimflam.FlimFlam()  # because the manger destroys it?
85            #network.ResetAllModems(self.flim)
86            self.flim = flimflam.FlimFlam()  # because the manger destroys it?
87            cell_tools.ConnectToCellular(self.flim, timeout=60)
88            env.emulator.ClearErrors()
89            service = env.CheckedConnectToCellular()
90            #env.CheckHttpConnectivity()
91            env.CheckedDisconnectFromCellular(service)
92
93    def _reset_everything(self):
94        """Rest the modem, ModemManger, and Shill"""
95        import os
96        logger.debug('Resetting Modem...')
97        os.system('modem reset')
98        logger.debug('Resetting shill...')
99        os.system('restart shill')
100        logger.debug('Resetting modemmanager...')
101        os.system('restart modemmanager')
102
103if __name__ == '__main__':
104    unittest.main()
105