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 os
|
0
|
18 |
|
|
19 |
from cone.public import api, plugin
|
|
20 |
from testautomation.base_testcase import BaseTestCase
|
|
21 |
|
|
22 |
|
|
23 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
24 |
|
|
25 |
class TestHCRMLWrite(BaseTestCase):
|
|
26 |
def _run_generate_test(self, project_dir, output_dir, expected_dir, hcrml_file):
|
|
27 |
project_dir = os.path.join(ROOT_PATH, project_dir)
|
|
28 |
output_dir = os.path.join(ROOT_PATH, output_dir)
|
|
29 |
if expected_dir != None:
|
|
30 |
expected_dir = os.path.join(ROOT_PATH, expected_dir)
|
|
31 |
|
|
32 |
self.remove_if_exists(output_dir)
|
|
33 |
|
|
34 |
prj = api.Project(api.Storage.open(project_dir))
|
|
35 |
config = prj.get_configuration('root.confml')
|
3
|
36 |
context = plugin.GenerationContext(configuration=config, output=output_dir)
|
0
|
37 |
impls = plugin.ImplFactory.get_impls_from_file(hcrml_file, config)
|
|
38 |
self.assertEquals(len(impls), 1)
|
|
39 |
impl = impls[0]
|
3
|
40 |
impl.generate(context)
|
0
|
41 |
|
|
42 |
if expected_dir != None:
|
|
43 |
self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn'])
|
|
44 |
else:
|
|
45 |
self.assertFalse(os.path.exists(output_dir))
|
|
46 |
|
|
47 |
def test_create_hcr_dat_from_single_hcrml_file(self):
|
|
48 |
self._run_generate_test(
|
|
49 |
project_dir = 'project',
|
|
50 |
output_dir = 'output/single_dat',
|
|
51 |
expected_dir = 'expected/single_dat',
|
|
52 |
hcrml_file = 'implml/example.hcrml')
|
|
53 |
|
|
54 |
def test_create_hcr_dat_from_multiple_hcrml_files(self):
|
|
55 |
self._run_generate_test(
|
|
56 |
project_dir = 'multifile_project',
|
|
57 |
output_dir = 'output/multi_dat',
|
|
58 |
expected_dir = 'expected/multi_dat',
|
|
59 |
hcrml_file = 'layer1/implml/hcr_dat.hcrml')
|
|
60 |
|
|
61 |
def test_create_header_from_single_hcrml_file(self):
|
|
62 |
self._run_generate_test(
|
|
63 |
project_dir = 'multifile_project',
|
|
64 |
output_dir = 'output/single_header',
|
|
65 |
expected_dir = 'expected/single_header',
|
|
66 |
hcrml_file = 'layer1/implml/test1.hcrml')
|
|
67 |
|
|
68 |
def test_create_header_from_multiple_hcrml_files(self):
|
|
69 |
self._run_generate_test(
|
|
70 |
project_dir = 'multifile_project',
|
|
71 |
output_dir = 'output/multi_header',
|
|
72 |
expected_dir = 'expected/multi_header',
|
|
73 |
hcrml_file = 'layer1/implml/multi_header.hcrml')
|
|
74 |
|
|
75 |
def test_create_nothing_from_outputless_hcrml_file(self):
|
|
76 |
self._run_generate_test(
|
|
77 |
project_dir = 'multifile_project',
|
|
78 |
output_dir = 'output/no_output',
|
|
79 |
expected_dir = None, # Check that there is no output
|
|
80 |
hcrml_file = 'layer1/implml/test3.hcrml')
|