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 |
from projectconvertplugin import convertproject
|
3
|
20 |
from cone.public import plugin,api
|
0
|
21 |
from cone.storage import filestorage
|
|
22 |
from testautomation.base_testcase import BaseTestCase
|
|
23 |
|
|
24 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
25 |
temp_dir = os.path.join(ROOT_PATH, "temp")
|
|
26 |
testdata = os.path.join(ROOT_PATH,'project')
|
|
27 |
|
|
28 |
class TestConvertProjectPlugin(BaseTestCase):
|
|
29 |
|
|
30 |
def test_example_parse_prj(self):
|
|
31 |
output_dir = os.path.join(temp_dir, "new_project2")
|
|
32 |
if os.path.exists(output_dir):
|
|
33 |
shutil.rmtree(output_dir)
|
|
34 |
|
|
35 |
fs = filestorage.FileStorage(testdata)
|
|
36 |
p = api.Project(fs)
|
|
37 |
config = p.get_configuration('product.confml')
|
|
38 |
impls = plugin.get_impl_set(config, r'file1\.convertprojectml$')
|
|
39 |
self.assertEquals(1, len(impls))
|
|
40 |
impl = iter(impls).next()
|
|
41 |
self.assertTrue(isinstance(impl, convertproject.ConvertProjectImpl))
|
|
42 |
|
|
43 |
def test_generate(self):
|
3
|
44 |
os.environ['ncp_version'] = 'platforms'
|
|
45 |
os.environ['variants'] = 'variants'
|
0
|
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')
|
3
|
55 |
context = plugin.GenerationContext(configuration=config,
|
|
56 |
output=output_dir)
|
0
|
57 |
impls = plugin.get_impl_set(config,'\.convertprojectml$')
|
3
|
58 |
context.filtering_disabled = True
|
|
59 |
impls.generate(context)
|
0
|
60 |
|
|
61 |
self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn'])
|
|
62 |
|
|
63 |
|
|
64 |
if __name__ == '__main__':
|
3
|
65 |
unittest.main()
|