0
|
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 maketheme
|
|
24 |
from themeplugin import theme_function
|
|
25 |
from cone.storage.filestorage import FileStorage
|
|
26 |
|
|
27 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
28 |
|
|
29 |
def impl_from_resource(resource_ref, configuration):
|
|
30 |
doc_root = plugin.ReaderBase._read_xml_doc_from_resource(resource_ref, configuration)
|
|
31 |
return maketheme.ThemeImplReader.read_impl(resource_ref, configuration, doc_root)
|
|
32 |
|
|
33 |
class TestThemePlugin(unittest.TestCase):
|
|
34 |
def setUp(self):
|
|
35 |
self.curdir = os.getcwd()
|
|
36 |
self.output = 'output'
|
|
37 |
pass
|
|
38 |
|
|
39 |
def tearDown(self):
|
|
40 |
pass
|
|
41 |
|
|
42 |
def test_list_tpf_files(self):
|
|
43 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
|
|
44 |
config = project.get_configuration("root_variant.confml")
|
|
45 |
impl = impl_from_resource("variant/implml/theme.thememl", config);
|
|
46 |
t1 = impl.list_theme_dir
|
|
47 |
t2 = impl.list_active_theme
|
|
48 |
list_tpf_files = impl.list_tpf_files(impl.list_active_theme,impl.list_theme_dir)
|
|
49 |
self.assertEquals(sorted(list_tpf_files),
|
|
50 |
sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf']))
|
|
51 |
|
|
52 |
def test_find_tpf_files(self):
|
|
53 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
|
|
54 |
config = project.get_configuration("root_variant.confml")
|
|
55 |
impl = impl_from_resource("variant/implml/theme.thememl", config)
|
|
56 |
tpf_paths = []
|
|
57 |
tpf_paths.append("UI/Themes")
|
|
58 |
list_tpf_files = impl.find_tpf_files(tpf_paths)
|
|
59 |
# The found TPF should be the one under variant/ not s60/
|
|
60 |
self.assertEquals(list_tpf_files, ['variant/content/UI/Themes/Armi.tpf'])
|
|
61 |
|
|
62 |
tpf_paths = []
|
|
63 |
tpf_paths.append("UI")
|
|
64 |
list_tpf_files = impl.find_tpf_files(tpf_paths)
|
|
65 |
self.assertEquals(list_tpf_files, ['s60/content/UI/Armi2.tpf'])
|
|
66 |
|
|
67 |
tpf_paths = []
|
|
68 |
tpf_paths.append("UI")
|
|
69 |
tpf_paths.append("UI/Themes")
|
|
70 |
list_tpf_files = impl.find_tpf_files(tpf_paths)
|
|
71 |
self.assertEquals(sorted(list_tpf_files), sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf']))
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
if __name__ == '__main__':
|
|
76 |
unittest.main()
|