configurationengine/source/plugins/symbian/ConeThemePlugin/themeplugin/tests/unittest_theme_container.py
changeset 0 2e8eeb919028
child 3 e7e0ae78773e
equal deleted inserted replaced
-1:000000000000 0:2e8eeb919028
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 import unittest, os, shutil
       
    18 
       
    19 import __init__    
       
    20 from cone.public import exceptions,plugin,api
       
    21 from cone.storage import filestorage
       
    22 from cone.confml import implml
       
    23 from themeplugin import theme_function
       
    24 from themeplugin.theme_container import ThemeContainer
       
    25 from cone.storage.filestorage import FileStorage
       
    26 
       
    27 from unittest_theme_plugin import impl_from_resource
       
    28 
       
    29 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
       
    30 
       
    31 class TestThemePlugin(unittest.TestCase):    
       
    32     def setUp(self):
       
    33         self.curdir = os.getcwd()
       
    34         self.output = 'output'
       
    35         pass
       
    36 
       
    37     def tearDown(self):
       
    38         pass
       
    39   
       
    40   
       
    41     def test_create_themes(self):
       
    42         project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
       
    43         config = project.get_configuration("root_variant.confml")
       
    44         impl = impl_from_resource("variant/implml/theme.thememl", config);
       
    45         list_tpf = impl.list_tpf_files(impl.list_active_theme, impl.list_theme_dir)
       
    46         
       
    47         list_theme=[]
       
    48         container = ThemeContainer(list_tpf,impl.configuration)
       
    49         container.create_themes()
       
    50         self.assertEquals(len(container.list_theme),2)
       
    51         container.removeTempDirs() 
       
    52 
       
    53     def test_prepare_active_themes(self):
       
    54         project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
       
    55         config = project.get_configuration("root_variant.confml")
       
    56         impl = impl_from_resource("variant/implml/theme.thememl", config);
       
    57         list_tpf = impl.list_tpf_files(impl.list_active_theme, impl.list_theme_dir)
       
    58         container = ThemeContainer(list_tpf,impl.configuration)
       
    59         container.create_themes()
       
    60         
       
    61         def get_theme(lst, tpf_path):
       
    62             for theme in lst:
       
    63                 if theme.tpf_path == tpf_path:
       
    64                     return theme
       
    65             self.fail("Theme with tpf_path = %r not found!" % tpf_path)
       
    66         
       
    67         self.assertEquals(len(container.list_theme), 2)
       
    68         theme = get_theme(container.list_theme, 'variant/content/UI/Themes/Armi.tpf')
       
    69         self.assertEquals(theme.get_setting_uids(),[])
       
    70         self.assertEquals(theme.get_uid(), None)
       
    71         
       
    72         container.prepare_active_themes(impl.list_active_theme)
       
    73         theme = get_theme(container.list_theme, 's60/content/UI/Armi2.tpf')
       
    74         self.assertEquals(theme.get_setting_uids(), ["KCRUidPersonalisation.KPslnActiveSkinUid"])
       
    75         self.assertEquals(theme.get_uid(), "0x101FD60A")
       
    76 
       
    77          
       
    78         
       
    79 if __name__ == '__main__':
       
    80   unittest.main()