configurationengine/source/plugins/symbian/ConeImagePlugin/imageplugin/tests/unittest_imageml_plugin.py
changeset 0 2e8eeb919028
child 3 e7e0ae78773e
equal deleted inserted replaced
-1:000000000000 0:2e8eeb919028
       
     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
       
    18 import os, shutil, re
       
    19 import sys
       
    20 import logging
       
    21 import shutil
       
    22 import __init__
       
    23 		
       
    24 from cone.public import exceptions,plugin,api,container
       
    25 from cone.storage import filestorage
       
    26 from imageplugin import imageml
       
    27 from testautomation.base_testcase import BaseTestCase
       
    28 
       
    29 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
       
    30 testdata  = os.path.join(ROOT_PATH,'imageproject')
       
    31 
       
    32 class TestGeneratorFromProject(BaseTestCase):
       
    33     def test_create_generator_from_project_and_generate_all(self):
       
    34         orig_workdir = os.getcwd()
       
    35         os.chdir(ROOT_PATH)
       
    36         try:
       
    37             output = os.path.join(ROOT_PATH, "temp/output_all")
       
    38             self.recreate_dir(output)
       
    39             
       
    40             prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH,"imageproject")))
       
    41             config = prj.get_configuration('product.confml')
       
    42             implcontainer = plugin.get_impl_set(config, 'imageml$')
       
    43             self.assertEquals(len(implcontainer), 4)
       
    44             implcontainer.output = output
       
    45             implcontainer.generate()
       
    46             
       
    47             def check_gen(p):
       
    48                 self.assert_exists_and_contains_something(os.path.join(output, p))
       
    49             def check_not_gen(p):
       
    50                 self.assertFalse(os.path.exists(os.path.join(output, p)), "'%s' exists when it should not!" % p)
       
    51             
       
    52             try:
       
    53 	            check_gen('startup.mbm')
       
    54 	            check_gen('startup_mif.mif')
       
    55 	            
       
    56 	            check_not_gen('optional1_mbm.mbm')
       
    57 	            check_gen('optional2_mbm.mbm')
       
    58 	            check_not_gen('optional3_mbm.mbm')
       
    59 	            check_not_gen('optional4_mbm.mbm')
       
    60 	            
       
    61 	            check_not_gen('optional1_mif.mif')
       
    62 	            check_gen('optional2_mif.mif')
       
    63 	            check_not_gen('optional3_mif.mif')
       
    64 	            check_not_gen('optional4_mif.mif')
       
    65 	            
       
    66 	            check_gen('resource/apps/startup.mif')
       
    67 	            
       
    68 	            check_gen('depth_from_ref_test_mbm.mbm')
       
    69 	            check_gen('depth_from_ref_test_mif.mif')
       
    70     	    except AssertionError:
       
    71 	            if ' ' in ROOT_PATH:
       
    72 	                self.fail("Known bug (#177)")
       
    73 	            else:
       
    74 	                raise
       
    75         finally:
       
    76             os.chdir(orig_workdir)
       
    77     
       
    78     def _get_impl(self, filename):
       
    79     	prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH, "imageproject")))
       
    80         config = prj.get_configuration('product.confml')
       
    81         implcontainer = plugin.get_impl_set(config, re.escape(filename) + '$')
       
    82         self.assertEquals(len(implcontainer), 1)
       
    83         return iter(implcontainer).next()
       
    84         
       
    85     
       
    86     def test_get_refs(self):
       
    87     	impl = self._get_impl('startupmif_animation.imageml')
       
    88     	self.assertEquals(impl.get_refs(), None)
       
    89     	self.assertEquals(impl.has_ref('Foo.Bar'), None)
       
    90     	
       
    91     	impl = self._get_impl('optional_test.imageml')
       
    92     	self.assertEquals(impl.get_refs(), ['OptionalTest.EmptyString',
       
    93 										    'OptionalTest.EmptyString2'])
       
    94     	self.assertEquals(impl.has_ref('OptionalTest.EmptyString'), True)
       
    95     	self.assertEquals(impl.has_ref('Foo.Foo'), False)
       
    96     	
       
    97     	impl = self._get_impl('startup_animation.imageml')
       
    98     	self.assertEquals(impl.get_refs(), ['CVC_StartupAnimationSequence.CVC_StartupFrameLocation.localPath'])
       
    99     	self.assertEquals(impl.has_ref('CVC_StartupAnimationSequence.CVC_StartupFrameLocation.localPath'), True)
       
   100     	self.assertEquals(impl.has_ref('Foo.Foo'), False)
       
   101 
       
   102 if __name__ == '__main__':
       
   103     unittest.main()