configurationengine/source/plugins/symbian/ConeHCRPlugin/hcrplugin/tests/unittest_hcrml_writer.py
author terytkon
Thu, 11 Mar 2010 17:04:37 +0200
changeset 0 2e8eeb919028
child 3 e7e0ae78773e
permissions -rw-r--r--
Adding EPL version of configurationengine.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     1
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     3
# All rights reserved.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     4
# This component and the accompanying materials are made available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     6
# which accompanies this distribution, and is available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     8
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     9
# Initial Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    11
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    12
# Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    13
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    14
# Description:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    15
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    16
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
import os, unittest
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
import __init__
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
from hcrplugin.hcrrepository import HcrRepository, HcrRecord
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from hcrplugin.hcr_writer import HcrWriter
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
from hcrplugin import hcr_exceptions
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
from cone.public import api, plugin
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
from testautomation.base_testcase import BaseTestCase
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
class TestHCRMLWrite(BaseTestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
    def _run_generate_test(self, project_dir, output_dir, expected_dir, hcrml_file):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
        project_dir = os.path.join(ROOT_PATH, project_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
        output_dir = os.path.join(ROOT_PATH, output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        if expected_dir != None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
            expected_dir = os.path.join(ROOT_PATH, expected_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        config = prj.get_configuration('root.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        impls = plugin.ImplFactory.get_impls_from_file(hcrml_file, config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        self.assertEquals(len(impls), 1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        impl = impls[0]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        impl.set_output_root(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        impl.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        if expected_dir != None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
            self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
            self.assertFalse(os.path.exists(output_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
    def test_create_hcr_dat_from_single_hcrml_file(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
            project_dir     = 'project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
            output_dir      = 'output/single_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
            expected_dir    = 'expected/single_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
            hcrml_file      = 'implml/example.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
    def test_create_hcr_dat_from_multiple_hcrml_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
            output_dir      = 'output/multi_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
            expected_dir    = 'expected/multi_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
            hcrml_file      = 'layer1/implml/hcr_dat.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
    def test_create_header_from_single_hcrml_file(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
            output_dir      = 'output/single_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
            expected_dir    = 'expected/single_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
            hcrml_file      = 'layer1/implml/test1.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
    def test_create_header_from_multiple_hcrml_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
            output_dir      = 'output/multi_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
            expected_dir    = 'expected/multi_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
            hcrml_file      = 'layer1/implml/multi_header.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
    def test_create_nothing_from_outputless_hcrml_file(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
            output_dir      = 'output/no_output',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
            expected_dir    = None, # Check that there is no output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
            hcrml_file      = 'layer1/implml/test3.hcrml')