configurationengine/source/plugins/symbian/ConeCRMLPlugin/CRMLPlugin/tests/unittest_txt_generation.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
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
import sys, os, unittest
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from testautomation.base_testcase import BaseTestCase
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    22
from cone.public import exceptions, plugin, api, container, utils
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
from CRMLPlugin import crml_impl
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
def abspath(path):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
    return os.path.normpath(os.path.join(ROOT_PATH, path))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
class TestCrmlImpl(BaseTestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
    def test_generate_from_project_with_rfs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
        project_dir     = abspath('gen_project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        config          = 'root.confml'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        output_dir      = abspath('temp/gen_output1')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        expected_dir    = abspath('gen_expected')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        config = prj.get_configuration(config)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    41
        gc = plugin.GenerationContext(configuration=config,
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    42
                      output=output_dir)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    43
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        impls = plugin.get_impl_set(config, 'crml$')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    45
        gc.tags['target'] = ['rofs2']
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    46
        gc.filtering_disabled = True
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    47
        impls.generate(gc)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    48
        impls.post_generate(gc)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
    def test_generate_from_project_without_rfs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        project_dir     = abspath('gen_project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        config          = 'root.confml'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        output_dir      = abspath('temp/gen_output2')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        expected_dir    = abspath('gen_expected')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        config = prj.get_configuration(config)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    62
        gc = plugin.GenerationContext(configuration=config,
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    63
                                      output=output_dir)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    64
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        impls = plugin.get_impl_set(config, 'crml$')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    66
        gc.tags['target'] = []
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    67
        gc.filtering_disabled = True
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    68
        impls.generate(gc)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    69
        impls.post_generate(gc)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn', 'private'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        self.assertFalse(os.path.exists(os.path.join(output_dir, 'private/100059C9/cenrep_rfs.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
    def test_generate_from_project_duplicate_rfs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        project_dir     = abspath('duplicate_rfs_project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
        config          = 'root.confml'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
        output_dir      = abspath('temp/duplicate_rfs_output')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
        expected_dir    = abspath('duplicate_rfs_expected')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
        config = prj.get_configuration(config)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    85
        gc = plugin.GenerationContext(configuration=config,
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    86
                                      output=output_dir)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87
        impls = plugin.get_impl_set(config, 'crml$')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    88
        gc.tags['target'] = ['rofs2']
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    89
        gc.filtering_disabled = True
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    90
        impls.generate(gc)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    91
        impls.post_generate(gc)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
    
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    95
    def test_generate_delta_cenreps(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    96
        project_dir     = abspath('gen_project')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    97
        config          = 'root2.confml'
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    98
        output_dir      = abspath('temp/gen_output_deltacenrep')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    99
        expected_dir    = abspath('gen_expected_deltacenrep')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   100
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   101
        self.remove_if_exists(output_dir)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   102
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   103
        prj = api.Project(api.Storage.open(project_dir))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   104
        config = prj.get_configuration(config)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   105
        gc = plugin.GenerationContext(configuration=config,
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   106
                                      output=output_dir)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   107
        # Get refs from the last layer
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   108
        layer = config.get_configuration_by_index(-1)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   109
        refs = utils.distinct_array(layer.list_leaf_datas())
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   110
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   111
        impls = plugin.get_impl_set(config, 'crml$')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   112
        impls = impls | plugin.get_impl_set(config, 'implml$')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   113
        impls = impls.filter_implementations(refs=refs)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   114
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   115
        gc.tags['crml'] = ['deltacenrep']
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   116
        gc.changed_refs = refs
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   117
        gc.filtering_disabled = True
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   118
        impls.generate(gc)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   119
        impls.post_generate(gc)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   120
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   121
        output_dir = os.path.join(output_dir, 'deltacenreps')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   122
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])