configurationengine/source/plugins/symbian/ConeThemePlugin/themeplugin/tests/unittest_theme_container.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 unittest, os, shutil
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
import __init__    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
from cone.public import exceptions,plugin,api
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from cone.storage import filestorage
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
from cone.confml import implml
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
from themeplugin import theme_function
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
from themeplugin.theme_container import ThemeContainer
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
from cone.storage.filestorage import FileStorage
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
from unittest_theme_plugin import impl_from_resource
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
class TestThemePlugin(unittest.TestCase):    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
    def setUp(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        self.curdir = os.getcwd()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        self.output = 'output'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
    def tearDown(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
  
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
  
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
    def test_create_themes(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        config = project.get_configuration("root_variant.confml")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        impl = impl_from_resource("variant/implml/theme.thememl", config);
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        list_tpf = impl.list_tpf_files(impl.list_active_theme, impl.list_theme_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
        list_theme=[]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        container = ThemeContainer(list_tpf,impl.configuration)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        container.create_themes()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        self.assertEquals(len(container.list_theme),2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
        container.removeTempDirs() 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
    def test_prepare_active_themes(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        config = project.get_configuration("root_variant.confml")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        impl = impl_from_resource("variant/implml/theme.thememl", config);
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        list_tpf = impl.list_tpf_files(impl.list_active_theme, impl.list_theme_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        container = ThemeContainer(list_tpf,impl.configuration)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        container.create_themes()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        def get_theme(lst, tpf_path):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
            for theme in lst:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
                if theme.tpf_path == tpf_path:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
                    return theme
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
            self.fail("Theme with tpf_path = %r not found!" % tpf_path)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
        self.assertEquals(len(container.list_theme), 2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
        theme = get_theme(container.list_theme, 'variant/content/UI/Themes/Armi.tpf')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        self.assertEquals(theme.get_setting_uids(),[])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        self.assertEquals(theme.get_uid(), None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        container.prepare_active_themes(impl.list_active_theme)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
        theme = get_theme(container.list_theme, 's60/content/UI/Armi2.tpf')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        self.assertEquals(theme.get_setting_uids(), ["KCRUidPersonalisation.KPslnActiveSkinUid"])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        self.assertEquals(theme.get_uid(), "0x101FD60A")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
         
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
if __name__ == '__main__':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
  unittest.main()