Home | History | Annotate | Download | only in Types
      1 # -*-coding:utf-8 -*
      2 
      3 # Copyright (c) 2011-2015, Intel Corporation
      4 # All rights reserved.
      5 #
      6 # Redistribution and use in source and binary forms, with or without modification,
      7 # are permitted provided that the following conditions are met:
      8 #
      9 # 1. Redistributions of source code must retain the above copyright notice, this
     10 # list of conditions and the following disclaimer.
     11 #
     12 # 2. Redistributions in binary form must reproduce the above copyright notice,
     13 # this list of conditions and the following disclaimer in the documentation and/or
     14 # other materials provided with the distribution.
     15 #
     16 # 3. Neither the name of the copyright holder nor the names of its contributors
     17 # may be used to endorse or promote products derived from this software without
     18 # specific prior written permission.
     19 #
     20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     22 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     23 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
     24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     25 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     26 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     27 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     29 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30 
     31 """
     32 Boolean parameter type testcases.
     33 
     34 List of tested functions :
     35 --------------------------
     36     - [setParameter]  function
     37     - [getParameter] function
     38 
     39 
     40 Test cases :
     41 ------------
     42     - Testing minimum
     43     - Testing maximum
     44     - Testing negative value
     45     - Testing overflow
     46 """
     47 
     48 from Util.PfwUnitTestLib import PfwTestCase
     49 from Util import ACTLogging
     50 log=ACTLogging.Logger()
     51 
     52 # Class containing SET/GET tests on a Boolean parameter
     53 class TestCases(PfwTestCase):
     54     def setUp(self):
     55         self.param_name = "/Test/Test/TEST_DIR/BOOL"
     56         self.pfw.sendCmd("setTuningMode", "on")
     57 
     58     def tearDown(self):
     59         self.pfw.sendCmd("setTuningMode", "off")
     60 
     61     def testBooleanMaximum(self):
     62         """
     63         Testing maximum value for boolean parameter
     64         -------------------------------------------
     65             Test case description :
     66             ~~~~~~~~~~~~~~~~~~~~~~~
     67                 - Set a boolean parameter to the max value 1
     68             Tested commands :
     69             ~~~~~~~~~~~~~~~~~
     70                 - [setParameter] function
     71             Used commands :
     72             ~~~~~~~~~~~~~~~
     73                 - [getParameter] function
     74             Expected result :
     75             ~~~~~~~~~~~~~~~~~
     76                 - Boolean set to 1
     77         """
     78         log.D(self.testBooleanMaximum.__doc__)
     79         value = "1"
     80         out, err = self.pfw.sendCmd("setParameter", self.param_name, value)
     81         assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err))
     82         assert out == "Done", log.F("When setting parameter %s : %s" % (self.param_name, out))
     83         out, err = self.pfw.sendCmd("getParameter", self.param_name, "")
     84         assert out == value, log.F("incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out))
     85 
     86     def testBooleanMinimum(self):
     87         """
     88         Testing minimum value for boolean parameter
     89         -------------------------------------------
     90             Test case description :
     91             ~~~~~~~~~~~~~~~~~~~~~~~
     92                 - Set a boolean parameter to the min value 0
     93             Tested commands :
     94             ~~~~~~~~~~~~~~~~~
     95                 - [setParameter] function
     96             Used commands :
     97             ~~~~~~~~~~~~~~~
     98                 - [getParameter] function
     99             Expected result :
    100             ~~~~~~~~~~~~~~~~~
    101                 - Boolean set to 0
    102         """
    103         log.D(self.testBooleanMinimum.__doc__)
    104         value = "0"
    105         out, err = self.pfw.sendCmd("setParameter", self.param_name, value)
    106         assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err))
    107         assert out == "Done", log.F("When setting parameter %s : %s" % (self.param_name, out))
    108         out, err = self.pfw.sendCmd("getParameter", self.param_name, "")
    109         assert err == None, log.E("Error when setting parameter %s : %s" % (self.param_name, err))
    110         assert out == value, log.F("Incorrect value for %s, expected: %s, found: %s" % (self.param_name, value, out))
    111 
    112     def testBooleanNegative(self):
    113         """
    114         Testing negative value for boolean parameter
    115         --------------------------------------------
    116             Test case description :
    117             ~~~~~~~~~~~~~~~~~~~~~~~
    118                 - Set a boolean parameter to -1
    119             Tested commands :
    120             ~~~~~~~~~~~~~~~~~
    121                 - [setParameter] function
    122             Used commands :
    123             ~~~~~~~~~~~~~~~
    124                 - [getParameter] function
    125             Expected result :
    126             ~~~~~~~~~~~~~~~~~
    127                 - Error detected, boolean not updated
    128         """
    129         print self.testBooleanNegative.__doc__
    130         value = "-1"
    131         out, err = self.pfw.sendCmd("setParameter", self.param_name, value, expectSuccess=False)
    132         assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err))
    133         assert out != "Done", log.F("When setting parameter %s : %s" % (self.param_name, out))
    134         out, err = self.pfw.sendCmd("getParameter", self.param_name, "")
    135         assert out != value, log.F("incorrect value for %s, expected: %s, found: %s") % (self.param_name, value, out)
    136 
    137 
    138     def testBooleanOverflow(self):
    139         """
    140         Testing overflowed value for boolean parameter
    141         ----------------------------------------------
    142             Test case description :
    143             ~~~~~~~~~~~~~~~~~~~~~~~
    144                 - Set a boolean parameter to 2
    145             Tested commands :
    146             ~~~~~~~~~~~~~~~~~
    147                 - [setParameter] function
    148             Used commands :
    149             ~~~~~~~~~~~~~~~
    150                 - [getParameter] function
    151             Expected result :
    152             ~~~~~~~~~~~~~~~~~
    153                 - Error detected, boolean not updated
    154         """
    155         print self.testBooleanOverflow.__doc__
    156         value = "2"
    157         out, err = self.pfw.sendCmd("setParameter", self.param_name, value, expectSuccess=False)
    158         assert err == None, log.E("When setting parameter %s : %s" % (self.param_name, err))
    159         assert out != "Done", log.F("When setting parameter %s : %s" % (self.param_name, out))
    160         out, err = self.pfw.sendCmd("getParameter", self.param_name, "")
    161         assert out != value, log.F("incorrect value for %s, expected: %s, found: %s") % (self.param_name, value, out)
    162