blob: bae26f42f530a35931fc4904c9e6d726d3300c99 [file] [log] [blame]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import mock
import unittest
from . import graphyte
from . import testplan
class GraphyteTest(unittest.TestCase):
def setUp(self):
self.graphyte_obj = graphyte.Graphyte()
# Mock DUT and Inst plugin.
self.mock = mock.Mock()
self.mock.dut = mock.MagicMock()
self.mock.inst = mock.MagicMock()
self.graphyte_obj.dut = self.mock.dut
self.graphyte_obj.inst = self.mock.inst
self.mock.dut.active_controller.RxGetResult = mock.MagicMock(
return_value=(True, {'fake_rx_result': 'VALUE'}))
self.mock.inst.active_controller.TxGetResult = mock.MagicMock(
return_value=(True, {'fake_tx_result': 'VALUE'}))
# Make fake port config and test plan.
self.fake_wlan_tx_test = testplan.TestCase(
'WLAN TX',
{'rf_type': 'WLAN', 'test_type': 'TX'},
{})
self.fake_wlan_rx_test = testplan.TestCase(
'WLAN RX',
{'rf_type': 'WLAN', 'test_type': 'RX'},
{})
self.fake_bt_tx_test = testplan.TestCase(
'BLUETOOTH TX',
{'rf_type': 'BLUETOOTH', 'test_type': 'TX'},
{})
self.fake_bt_rx_test = testplan.TestCase(
'BLUETOOTH RX',
{'rf_type': 'BLUETOOTH', 'test_type': 'RX'},
{})
self.graphyte_obj.testplan = [
self.fake_wlan_tx_test,
self.fake_wlan_rx_test,
self.fake_bt_tx_test,
self.fake_bt_rx_test]
self.graphyte_obj.port_config = 'FAKE_PORT_CONFIG'
def testE2E(self):
self.graphyte_obj.Run()
self.mock.assert_has_calls([
# Initialization.
mock.call.inst.Initialize(),
mock.call.inst.LockInstrument(),
mock.call.inst.InitPortConfig(self.graphyte_obj.port_config),
mock.call.dut.Initialize(),
# Run WLAN Tx Test case.
mock.call.dut.SetRF('WLAN'),
mock.call.inst.SetRF('WLAN'),
mock.call.inst.SetPortConfig(self.fake_wlan_tx_test),
mock.call.dut.active_controller.TxStart(self.fake_wlan_tx_test),
mock.call.inst.active_controller.TxMeasure(self.fake_wlan_tx_test),
mock.call.inst.active_controller.TxGetResult(self.fake_wlan_tx_test),
mock.call.dut.active_controller.TxStop(self.fake_wlan_tx_test),
# Run WLAN Rx Test case.
mock.call.dut.SetRF('WLAN'),
mock.call.inst.SetRF('WLAN'),
mock.call.inst.SetPortConfig(self.fake_wlan_rx_test),
mock.call.dut.active_controller.RxClearResult(self.fake_wlan_rx_test),
mock.call.inst.active_controller.RxGenerate(self.fake_wlan_rx_test),
mock.call.dut.active_controller.RxGetResult(self.fake_wlan_rx_test),
mock.call.inst.active_controller.RxStop(self.fake_wlan_rx_test),
# Run Bluetooth Tx Test case.
mock.call.dut.SetRF('BLUETOOTH'),
mock.call.inst.SetRF('BLUETOOTH'),
mock.call.inst.SetPortConfig(self.fake_bt_tx_test),
mock.call.dut.active_controller.TxStart(self.fake_bt_tx_test),
mock.call.inst.active_controller.TxMeasure(self.fake_bt_tx_test),
mock.call.inst.active_controller.TxGetResult(self.fake_bt_tx_test),
mock.call.dut.active_controller.TxStop(self.fake_bt_tx_test),
# Run Bluetooth Rx Test case.
mock.call.dut.SetRF('BLUETOOTH'),
mock.call.inst.SetRF('BLUETOOTH'),
mock.call.inst.SetPortConfig(self.fake_bt_rx_test),
mock.call.dut.active_controller.RxClearResult(self.fake_bt_rx_test),
mock.call.inst.active_controller.RxGenerate(self.fake_bt_rx_test),
mock.call.dut.active_controller.RxGetResult(self.fake_bt_rx_test),
mock.call.inst.active_controller.RxStop(self.fake_bt_rx_test),
# Termination.
mock.call.inst.UnlockInstrument(),
mock.call.inst.Terminate(),
mock.call.dut.Terminate()])