12 # Contributors: |
12 # Contributors: |
13 # |
13 # |
14 # Description: |
14 # Description: |
15 # |
15 # |
16 |
16 |
17 import unittest, os, shutil |
17 import unittest, os, sys |
18 |
18 |
19 import __init__ |
19 from cone.public import plugin,api |
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 |
20 |
27 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
21 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
28 |
22 |
29 def impl_from_resource(resource_ref, configuration): |
23 def impl_from_resource(resource_ref, configuration): |
30 doc_root = plugin.ReaderBase._read_xml_doc_from_resource(resource_ref, configuration) |
24 impls = plugin.ImplFactory.get_impls_from_file(resource_ref, configuration) |
31 return maketheme.ThemeImplReader.read_impl(resource_ref, configuration, doc_root) |
25 assert len(impls) == 1 |
|
26 return impls[0] |
32 |
27 |
33 class TestThemePlugin(unittest.TestCase): |
28 class TestThemePlugin(unittest.TestCase): |
34 def setUp(self): |
29 def setUp(self): |
35 self.curdir = os.getcwd() |
30 self.curdir = os.getcwd() |
36 self.output = 'output' |
31 self.output = 'output' |
41 |
36 |
42 def test_list_tpf_files(self): |
37 def test_list_tpf_files(self): |
43 project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75"))) |
38 project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"e75"))) |
44 config = project.get_configuration("root_variant.confml") |
39 config = project.get_configuration("root_variant.confml") |
45 impl = impl_from_resource("variant/implml/theme.thememl", config); |
40 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) |
41 list_tpf_files = impl.list_tpf_files(impl.list_active_theme,impl.list_theme_dir) |
49 self.assertEquals(sorted(list_tpf_files), |
42 self.assertEquals(sorted(list_tpf_files), |
50 sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf'])) |
43 sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf'])) |
51 |
44 |
52 def test_find_tpf_files(self): |
45 def test_find_tpf_files(self): |
68 tpf_paths.append("UI") |
61 tpf_paths.append("UI") |
69 tpf_paths.append("UI/Themes") |
62 tpf_paths.append("UI/Themes") |
70 list_tpf_files = impl.find_tpf_files(tpf_paths) |
63 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'])) |
64 self.assertEquals(sorted(list_tpf_files), sorted(['variant/content/UI/Themes/Armi.tpf', 's60/content/UI/Armi2.tpf'])) |
72 |
65 |
73 |
66 # Only run these tests on Windows |
|
67 if sys.platform != 'win32': |
|
68 del TestThemePlugin |
74 |
69 |
75 if __name__ == '__main__': |
70 if __name__ == '__main__': |
76 unittest.main() |
71 unittest.main() |