|
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 projectconvertplugin import convertproject |
|
21 from cone.public import exceptions,plugin,api |
|
22 from cone.storage import filestorage |
|
23 from cone.confml import implml |
|
24 from testautomation.base_testcase import BaseTestCase |
|
25 |
|
26 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
27 temp_dir = os.path.join(ROOT_PATH, "temp") |
|
28 testdata = os.path.join(ROOT_PATH,'project') |
|
29 |
|
30 class TestConvertProjectPlugin(BaseTestCase): |
|
31 |
|
32 def test_example_parse_prj(self): |
|
33 output_dir = os.path.join(temp_dir, "new_project2") |
|
34 if os.path.exists(output_dir): |
|
35 shutil.rmtree(output_dir) |
|
36 |
|
37 fs = filestorage.FileStorage(testdata) |
|
38 p = api.Project(fs) |
|
39 config = p.get_configuration('product.confml') |
|
40 impls = plugin.get_impl_set(config, r'file1\.convertprojectml$') |
|
41 self.assertEquals(1, len(impls)) |
|
42 impl = iter(impls).next() |
|
43 self.assertTrue(isinstance(impl, convertproject.ConvertProjectImpl)) |
|
44 |
|
45 def test_generate(self): |
|
46 output_dir = os.path.join(temp_dir, "new_project") |
|
47 if os.path.exists(output_dir): |
|
48 shutil.rmtree(output_dir) |
|
49 expected_dir = os.path.join(ROOT_PATH, "expected/new_project") |
|
50 oldPath = os.path.join(ROOT_PATH,'old_structure/epoc32/rom/config') |
|
51 |
|
52 fs = filestorage.FileStorage(oldPath) |
|
53 p = api.Project(fs) |
|
54 config = p.get_configuration('convert.confml') |
|
55 impls = plugin.get_impl_set(config,'\.convertprojectml$') |
|
56 impls.output = output_dir |
|
57 impls.generate() |
|
58 |
|
59 self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn']) |
|
60 |
|
61 |
|
62 if __name__ == '__main__': |
|
63 unittest.main() |