1# Copyright 2014 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
6from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
7from autotest_lib.client.cros.cellular.mbim_compliance \
8        import mbim_test_base
9from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
10        import connect_sequence
11from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
12        import get_descriptors_sequence
13from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
14        import mbim_open_generic_sequence
15
16
17class cellular_MbimComplianceCM09(mbim_test_base.MbimTestBase):
18    """
19    CM_09 Validation of TransactionId for notifications received after connect
20    sequence.
21
22    This test verifies that TransactionId for notifications is zero.
23
24    Reference:
25        [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 41
26        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
27
28    """
29    version = 1
30
31    def run_internal(self):
32        """ Run CM_09 test. """
33        # Precondition
34        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
35                self.device_context).run()
36        self.device_context.update_descriptor_cache(descriptors)
37        mbim_open_generic_sequence.MBIMOpenGenericSequence(
38                self.device_context).run()
39
40        # Step 1
41        _, _, notifications = (
42                connect_sequence.ConnectSequence(self.device_context).run())
43
44        # Step 2
45        for notification in notifications:
46            if notification.transaction_id != 0:
47                mbim_errors.log_and_raise(
48                        mbim_errors.MBIMComplianceAssertionError,
49                        'mbim1.0:9.1#1')
50