buildframework/helium/tools/common/python/lib/cpythontest/test_comments.py
author wbernard
Wed, 23 Dec 2009 19:29:07 +0200
changeset 179 d8ac696cc51f
permissions -rw-r--r--
helium_7.0-r14027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     1
#============================================================================ 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     2
#Name        : test_comments.py 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     4
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     6
#All rights reserved.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    11
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    12
#Initial Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    14
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    15
#Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    16
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    17
#Description:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    18
#===============================================================================
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    19
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    20
""" Test cases for Comments.py. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    21
import unittest
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    22
import comments
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    23
import logging
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    24
import amara
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    25
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    26
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    27
class CommentParserTest(unittest.TestCase):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    28
    """ Test cases for Comments.py. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    29
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    30
    def setUp(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    31
        # Initialize the sample files into two Comment Parsers.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    32
        self.parser1 = comments.CommentParser( [r'tests/data/comments_test.txt'], 'branchInfo' )
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    33
        self.parser2 = comments.CommentParser( [r'tests/data/comments_test.cpp', r'tests/data/comments_test.bat',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    34
                                                r'tests/data/comments_test.h', r'tests/data/comments_test.hrh',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    35
                                                r'tests/data/comments_test.iby', r'tests/data/comments_test.inf',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    36
                                                r'tests/data/comments_test.mk', r'tests/data/comments_test.mmp',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    37
                                                r'tests/data/comments_test.pl', r'tests/data/comments_test.xml',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    38
                                                r'tests/data/comments_test.py', r'tests/data/comments_test.java',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    39
                                                r'tests/data/comments_test1.cmd', r'tests/data/comments_test2.cmd'], 'branchInfo' )
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    40
     #   self.parser3 = comments.CommentParser( [r'tests/data/comments_test2.cmd'], 'branchInfo' )
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    41
     
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    42
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    43
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    44
    """ Unit test for method scan() in comments.py. It also tested scan_content by using scan()
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    45
    """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    46
    def test_scan(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    47
        #doc1 for only one txt file. 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    48
        doc1 = amara.parse(self.parser1.scan().xml())
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    49
        #doc2 for all other 14 types of files. It also included two types of cmd files.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    50
        doc2 = amara.parse(self.parser2.scan().xml())
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    51
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    52
        # doc1's test verifies all the information the xml comment provides.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    53
        self.assertEquals(doc1.commentLog.branchInfo.originator, "sanummel")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    54
        self.assertEquals(doc1.commentLog.branchInfo.category, "")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    55
        self.assertEquals(doc1.commentLog.branchInfo.since, "07-03-22")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    56
        self.assertEquals(doc1.commentLog.branchInfo.file, r'tests/data/comments_test.txt')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    57
        self.assertEquals(doc1.commentLog.branchInfo.error, "kkk")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    58
        self.assertEquals(str(doc1.commentLog.branchInfo).strip(),"Add rofsfiles for usage in paged images")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    59
        # s = (str(doc1.commentLog.xml()))
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    60
        # print s
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    61
        # doc2's test only verifies the main comment content.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    62
        self.assertEquals(str(doc2.commentLog.branchInfo[0]).strip(), "We need TwistOpen and TwistClose to cause display to change between\n landscape and portrait, but SysAp is consuming the key events.  Try\n treating them as Flip events are handled already by SysAp.")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    63
        self.assertEquals(str(doc2.commentLog.branchInfo[1]).strip(), "Testing if it's good~~~")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    64
        self.assertEquals(str(doc2.commentLog.branchInfo[2]).strip(), "We need TwistOpen and TwistClose to cause display to change between\n landscape and portrait, but SysAp is consuming the key events.  Try\n treating them as Flip events are handled already by SysAp.")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    65
        self.assertEquals(str(doc2.commentLog.branchInfo[3]).strip(), "puikko ME SCD DeSW: wk21 Flag fix")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    66
        self.assertEquals(str(doc2.commentLog.branchInfo[4]).strip(), "Since Catalogs is not compiling at this point, and we are not building it, don't try to\n pull it into the rom.  Also, tfxserver is crashing, so don't build or pull it in either.")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    67
        self.assertEquals(str(doc2.commentLog.branchInfo[5]).strip(), "Fix target export, which cause issue when cleanexport.")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    68
        self.assertEquals(str(doc2.commentLog.branchInfo[6]).strip(), "Move command to makmake as EBS does not call abld build")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    69
        self.assertEquals(str(doc2.commentLog.branchInfo[7]).strip(), "Activate PCFW for Screensaver")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    70
        self.assertEquals(str(doc2.commentLog.branchInfo[8]).strip(), "Support SPP mechanism for flags support.")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    71
        self.assertEquals(str(doc2.commentLog.branchInfo[9]).strip(), "Enabling all the HWRM light zones target for product")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    72
        self.assertEquals(str(doc2.commentLog.branchInfo[10]).strip(), "Again, it is just a test")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    73
        self.assertEquals(str(doc2.commentLog.branchInfo[11]).strip(), "Test info, so whatever~")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    74
        self.assertEquals(str(doc2.commentLog.branchInfo[12]).strip(), "k")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    75
        self.assertEquals(str(doc2.commentLog.branchInfo[13]).strip(), "")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    76
          
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    77
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    78