configurationengine/source/plugins/symbian/ConeHCRPlugin/hcrplugin/tests/unittest_hcrml_writer.py
author m2lahtel
Tue, 10 Aug 2010 14:29:28 +0300
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
permissions -rw-r--r--
ConE 1.2.11 release
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
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    17
import os
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
from cone.public import api, plugin
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
from testautomation.base_testcase import BaseTestCase
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
class TestHCRMLWrite(BaseTestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
    def _run_generate_test(self, project_dir, output_dir, expected_dir, hcrml_file):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
        project_dir = os.path.join(ROOT_PATH, project_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
        output_dir = os.path.join(ROOT_PATH, output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
        if expected_dir != None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
            expected_dir = os.path.join(ROOT_PATH, expected_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        config = prj.get_configuration('root.confml')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    36
        context = plugin.GenerationContext(configuration=config, output=output_dir)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        impls = plugin.ImplFactory.get_impls_from_file(hcrml_file, config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        self.assertEquals(len(impls), 1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        impl = impls[0]
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    40
        impl.generate(context)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        if expected_dir != None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
            self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
            self.assertFalse(os.path.exists(output_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
    def test_create_hcr_dat_from_single_hcrml_file(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
            project_dir     = 'project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
            output_dir      = 'output/single_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
            expected_dir    = 'expected/single_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
            hcrml_file      = 'implml/example.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
    def test_create_hcr_dat_from_multiple_hcrml_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
            output_dir      = 'output/multi_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
            expected_dir    = 'expected/multi_dat',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
            hcrml_file      = 'layer1/implml/hcr_dat.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
    def test_create_header_from_single_hcrml_file(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
            output_dir      = 'output/single_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
            expected_dir    = 'expected/single_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
            hcrml_file      = 'layer1/implml/test1.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
    def test_create_header_from_multiple_hcrml_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
            output_dir      = 'output/multi_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
            expected_dir    = 'expected/multi_header',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
            hcrml_file      = 'layer1/implml/multi_header.hcrml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
    def test_create_nothing_from_outputless_hcrml_file(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        self._run_generate_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
            project_dir     = 'multifile_project',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
            output_dir      = 'output/no_output',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
            expected_dir    = None, # Check that there is no output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
            hcrml_file      = 'layer1/implml/test3.hcrml')