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 |
|
3
|
17 |
import unittest, os, sys
|
0
|
18 |
|
3
|
19 |
from cone.public import plugin,api
|
0
|
20 |
|
|
21 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
22 |
|
|
23 |
def impl_from_resource(resource_ref, configuration):
|
3
|
24 |
impls = plugin.ImplFactory.get_impls_from_file(resource_ref, configuration)
|
|
25 |
assert len(impls) == 1
|
|
26 |
return impls[0]
|
0
|
27 |
|
|
28 |
class TestThemePlugin(unittest.TestCase):
|
|
29 |
def setUp(self):
|
|
30 |
self.curdir = os.getcwd()
|
|
31 |
self.output = 'output'
|
|
32 |
pass
|
|
33 |
|
|
34 |
def tearDown(self):
|
|
35 |
pass
|
|
36 |
|
|
37 |
def test_list_tpf_files(self):
|
|
38 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
|
|
39 |
config = project.get_configuration("root_variant.confml")
|
|
40 |
impl = impl_from_resource("variant/implml/theme.thememl", config);
|
|
41 |
list_tpf_files = impl.list_tpf_files(impl.list_active_theme,impl.list_theme_dir)
|
|
42 |
self.assertEquals(sorted(list_tpf_files),
|
|
43 |
sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf']))
|
|
44 |
|
|
45 |
def test_find_tpf_files(self):
|
|
46 |
project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75")))
|
|
47 |
config = project.get_configuration("root_variant.confml")
|
|
48 |
impl = impl_from_resource("variant/implml/theme.thememl", config)
|
|
49 |
tpf_paths = []
|
|
50 |
tpf_paths.append("UI/Themes")
|
|
51 |
list_tpf_files = impl.find_tpf_files(tpf_paths)
|
|
52 |
# The found TPF should be the one under variant/ not s60/
|
|
53 |
self.assertEquals(list_tpf_files, ['variant/content/UI/Themes/Armi.tpf'])
|
|
54 |
|
|
55 |
tpf_paths = []
|
|
56 |
tpf_paths.append("UI")
|
|
57 |
list_tpf_files = impl.find_tpf_files(tpf_paths)
|
|
58 |
self.assertEquals(list_tpf_files, ['s60/content/UI/Armi2.tpf'])
|
|
59 |
|
|
60 |
tpf_paths = []
|
|
61 |
tpf_paths.append("UI")
|
|
62 |
tpf_paths.append("UI/Themes")
|
|
63 |
list_tpf_files = impl.find_tpf_files(tpf_paths)
|
|
64 |
self.assertEquals(sorted(list_tpf_files), sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf']))
|
|
65 |
|
3
|
66 |
# Only run these tests on Windows
|
|
67 |
if sys.platform != 'win32':
|
|
68 |
del TestThemePlugin
|
0
|
69 |
|
|
70 |
if __name__ == '__main__':
|
3
|
71 |
unittest.main()
|