network_ChromeCellularNetworkPresent.py revision 938725d7a7ee5f5cbaf88ae3b396ed159db4a1a3
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
5from autotest_lib.client.bin import test
6from autotest_lib.client.common_lib import error
7from autotest_lib.client.cros.cellular.pseudomodem import pseudomodem
8from autotest_lib.client.cros.cellular.chrome_testing \
9        import chrome_networking_test_context as cntc
10
11class network_ChromeCellularNetworkPresent(test.test):
12    """
13    This test is meant as a simple example using
14    client/cros/cellular/chrome_testing. It uses telemetry and pseudomodem to
15    setup a fake network and verify that it properly propagates to Chrome.
16
17    """
18    version = 1
19
20    def run_once(self, family):
21        with pseudomodem.TestModemManagerContext(True, family):
22            with cntc.ChromeNetworkingTestContext() as test_context:
23                networks = test_context.find_cellular_networks()
24                if len(networks) != 1:
25                    raise error.TestFail(
26                            'Expected 1 cellular network, found ' +
27                            str(len(networks)))
28
29                network = networks[0]
30                if network["Type"] != test_context.CHROME_NETWORK_TYPE_CELLULAR:
31                    raise error.TestFail(
32                            'Expected network of type "Cellular", found ' +
33                            network["Type"])
34
35                if not network["Name"].startswith(
36                        pseudomodem.DEFAULT_TEST_NETWORK_PREFIX):
37                    raise error.TestFail('Network name is incorrect: ' +
38                                         network["Name"])
39
40
41