project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView.java
changeset 610 bfb3ab3f70f2
parent 0 fb279309251b
child 611 5d967503c150
equal deleted inserted replaced
609:bf7dbec89c47 610:bfb3ab3f70f2
    20 import com.nokia.carbide.cpp.epoc.engine.model.bldinf.*;
    20 import com.nokia.carbide.cpp.epoc.engine.model.bldinf.*;
    21 import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IMakefileReference.EMakeEngine;
    21 import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IMakefileReference.EMakeEngine;
    22 import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory;
    22 import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory;
    23 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
    23 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
    24 import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTProblemNode;
    24 import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTProblemNode;
       
    25 import com.nokia.cpp.internal.api.utils.core.HostOS;
    25 import com.nokia.cpp.internal.api.utils.core.IMessage;
    26 import com.nokia.cpp.internal.api.utils.core.IMessage;
    26 
    27 
       
    28 import org.eclipse.core.runtime.IPath;
    27 import org.eclipse.core.runtime.Path;
    29 import org.eclipse.core.runtime.Path;
    28 
    30 
    29 import java.util.ArrayList;
    31 import java.util.ArrayList;
    30 import java.util.HashMap;
    32 import java.util.HashMap;
    31 import java.util.List;
    33 import java.util.List;
   444 		assertEquals(new Path("src/MyFile.txt"), exp.getSourcePath());
   446 		assertEquals(new Path("src/MyFile.txt"), exp.getSourcePath());
   445 		view.getExports().add(exp);
   447 		view.getExports().add(exp);
   446 		
   448 		
   447 		exp = view.createExport();
   449 		exp = view.createExport();
   448 		exp.setSourcePath(new Path("gfx/myfile.mbm"));
   450 		exp.setSourcePath(new Path("gfx/myfile.mbm"));
   449 		exp.setTargetPath(new Path("\\sys\\resources\\MyApp\\myfile.mbm"));
   451 		exp.setTargetPath(new Path("/sys/resources/MyApp/myfile.mbm"));
   450 		assertEquals(new Path("\\sys\\resources\\MyApp\\myfile.mbm"), exp.getTargetPath());
   452 		assertEquals(new Path("/sys/resources/MyApp/myfile.mbm"), exp.getTargetPath());
   451 		view.getExports().add(exp);
   453 		view.getExports().add(exp);
   452 
   454 
   453 		exp = view.createExport();
   455 		exp = view.createExport();
   454 		exp.setSourcePath(new Path("inc/header2.h"));
   456 		exp.setSourcePath(new Path("inc/header2.h"));
   455 		exp.setTargetPath(new Path("\\epoc32\\include\\header2.h"));
   457 		exp.setTargetPath(new Path("/epoc32/include/header2.h"));
   456 		view.getExports().add(exp);
   458 		view.getExports().add(exp);
   457 
   459 
   458 		exp = view.createExport();
   460 		exp = view.createExport();
   459 		exp.setSourcePath(new Path("group/here.exe"));
   461 		exp.setSourcePath(new Path("group/here.exe"));
   460 		exp.setTargetPath(new Path("c:/sys/bin/virus.exe"));
   462 		exp.setTargetPath(new Path("c:/sys/bin/virus.exe"));
   507 				":zip v28archive.zip \\epoc32\\releases\\winscw\\patches\n");
   509 				":zip v28archive.zip \\epoc32\\releases\\winscw\\patches\n");
   508 
   510 
   509 		IBldInfView view = getView(config);
   511 		IBldInfView view = getView(config);
   510 		assertNotNull(view);
   512 		assertNotNull(view);
   511 	
   513 	
   512 		view.getExports().get(1).setTargetPath(new Path("\\sys\\resources\\MyApp\\myfile.mbm"));
   514 		view.getExports().get(1).setTargetPath(new Path("/sys/resources/MyApp/myfile.mbm"));
   513 		
   515 		
   514 		commitTest(view,
   516 		commitTest(view,
   515 				"PRJ_EXPORTS\n"+
   517 				"PRJ_EXPORTS\n"+
   516 				"../src/MyFile.txt\n"+
   518 				"../src/MyFile.txt\n"+
   517 				"// user mistake below, should be full path\n"+
   519 				"// user mistake below, should be full path\n"+
   563 				"../src/MyFile.txt\n"+
   565 				"../src/MyFile.txt\n"+
   564 				"PRJ_PLATFORMS eee ooo\n");
   566 				"PRJ_PLATFORMS eee ooo\n");
   565 		assertEquals(2, view.getMessages().length);
   567 		assertEquals(2, view.getMessages().length);
   566 	}
   568 	}
   567 	
   569 	
       
   570 	private static IPath insideSDKPath;
       
   571 	static {
       
   572 		if (HostOS.IS_WIN32) {
       
   573 			insideSDKPath = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello\\group\\bld.inf");
       
   574 		} else {
       
   575 			insideSDKPath = new Path("/home/user/symbian/9.1/S60_3rd/S60Ex/Hello/group/bld.inf");
       
   576 		}
       
   577 	}
   568 	public void testRootProject() {
   578 	public void testRootProject() {
   569 		// make sure we handle project root correctly when it's the root directory
   579 		// make sure we handle project root correctly when it's the root directory
   570 		for (int i = 0; i < 2; i++){
   580 		for (int i = 0; i < 2; i++){
   571 			parserConfig.projectPath = i == 0 ? new Path("c:\\") : new Path("c:");
   581 			parserConfig.projectPath = i == 0 ? new Path("c:\\") : new Path("c:");
   572 			this.path = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello\\group\\bld.inf");
   582 			this.path = insideSDKPath;
   573 			makeModel("PRJ_MMPFILES\n"+
   583 			makeModel("PRJ_MMPFILES\n"+
   574 					"test.mmp\n");
   584 					"test.mmp\n");
   575 			
   585 			
   576 			IBldInfView view =model.createView(config);
   586 			IBldInfView view =model.createView(config);
   577 			_testRootProject(view);
   587 			_testRootProject(view);
   579 		}
   589 		}
   580 	}
   590 	}
   581 
   591 
   582 	private void _testRootProject(IBldInfData bldInfData) {
   592 	private void _testRootProject(IBldInfData bldInfData) {
   583 		IMMPReference mmp = bldInfData.getAllMMPReferences()[0];
   593 		IMMPReference mmp = bldInfData.getAllMMPReferences()[0];
   584 		// important to be relative
   594 		// important to be relative and with no drive
   585 		assertEquals(new Path("symbian/9.1/S60_3rd/S60Ex/Hello/group/test.mmp"), mmp.getPath());
   595 		if (HostOS.IS_WIN32)
       
   596 			assertEquals(insideSDKPath.makeRelative().setDevice(null).removeLastSegments(1).append("test.mmp"), mmp.getPath());
       
   597 		else
       
   598 			assertEquals(insideSDKPath.removeLastSegments(1).append("test.mmp"), mmp.getPath());
   586 	}
   599 	}
   587 	
   600 	
   588 	/**
   601 	/**
   589 	 * The base directory changes as files are #included
   602 	 * The base directory changes as files are #included
   590 	 *
   603 	 *
   591 	 */
   604 	 */
       
   605 	private static IPath basePath;
   592 	public void testBaseDirectory() {
   606 	public void testBaseDirectory() {
   593 		parserConfig.getFilesystem().put(new Path("c:/test/bld.inf").toOSString(), 
   607 		if (HostOS.IS_WIN32)
       
   608 			basePath = new Path("c:/test/");
       
   609 		else
       
   610 			basePath = new Path("/tmp/test/");
       
   611 		parserConfig.getFilesystem().put(basePath.append("bld.inf").toOSString(), 
   594 				"PRJ_MMPFILES\n"+
   612 				"PRJ_MMPFILES\n"+
   595 				"base.mmp\n"+
   613 				"base.mmp\n"+
   596 				"gnumakefile sub\\base.mk\n"+
   614 				"gnumakefile sub\\base.mk\n"+
   597 				"PRJ_EXPORTS\n"+
   615 				"PRJ_EXPORTS\n"+
   598 				"base.txt\n");
   616 				"base.txt\n");
   605 				"nmakefile ..\\utils.mk\n");
   623 				"nmakefile ..\\utils.mk\n");
   606 
   624 
   607 		makeModel(
   625 		makeModel(
   608 				"PRJ_MMPFILES\n"+
   626 				"PRJ_MMPFILES\n"+
   609 				"first.mmp\n"+
   627 				"first.mmp\n"+
   610 				"#include \"c:\\test\\bld.inf\"\n"+
   628 				"#include \"" + basePath.toOSString() + "bld.inf\"\n"+
   611 				"#include \"../utils/bld.inf\"\n"+
   629 				"#include \"../utils/bld.inf\"\n"+
   612 				"PRJ_MMPFILES\n"+
   630 				"PRJ_MMPFILES\n"+
   613 				"last.mmp\n" +
   631 				"last.mmp\n" +
   614 				"PRJ_EXPORTS\n"+
   632 				"PRJ_EXPORTS\n"+
   615 				"last.txt\n");
   633 				"last.txt\n");
   624 		assertEquals(6, bldInfData.getMakMakeReferences().size());
   642 		assertEquals(6, bldInfData.getMakMakeReferences().size());
   625 		
   643 		
   626 		assertEquals(new Path("group/first.mmp"), bldInfData.getMakMakeReferences().get(0).getPath());
   644 		assertEquals(new Path("group/first.mmp"), bldInfData.getMakMakeReferences().get(0).getPath());
   627 		
   645 		
   628 		// note: should not be relative path when outside the project
   646 		// note: should not be relative path when outside the project
   629 		assertEquals(new Path("c:/test/base.mmp"), bldInfData.getMakMakeReferences().get(1).getPath());
   647 		assertEquals(basePath.append("base.mmp"), bldInfData.getMakMakeReferences().get(1).getPath());
   630 		assertEquals(new Path("c:/test/sub/base.mk"), bldInfData.getMakMakeReferences().get(2).getPath());
   648 		assertEquals(basePath.append("sub/base.mk"), bldInfData.getMakMakeReferences().get(2).getPath());
   631 		
   649 		
   632 		assertEquals(new Path("utils/utils.mmp"), bldInfData.getMakMakeReferences().get(3).getPath());
   650 		assertEquals(new Path("utils/utils.mmp"), bldInfData.getMakMakeReferences().get(3).getPath());
   633 		assertEquals(new Path("utils.mk"), bldInfData.getMakMakeReferences().get(4).getPath());
   651 		assertEquals(new Path("utils.mk"), bldInfData.getMakMakeReferences().get(4).getPath());
   634 		
   652 		
   635 		assertEquals(new Path("group/last.mmp"), bldInfData.getMakMakeReferences().get(5).getPath());
   653 		assertEquals(new Path("group/last.mmp"), bldInfData.getMakMakeReferences().get(5).getPath());
   636 
   654 
   637 		assertEquals(3, bldInfData.getExports().size());
   655 		assertEquals(3, bldInfData.getExports().size());
   638 		assertEquals(new Path("c:/test/base.txt"), bldInfData.getExports().get(0).getSourcePath());
   656 		assertEquals(basePath.append("base.txt"), bldInfData.getExports().get(0).getSourcePath());
   639 		assertEquals(new Path("utils/utils.txt"), bldInfData.getExports().get(1).getSourcePath());
   657 		assertEquals(new Path("utils/utils.txt"), bldInfData.getExports().get(1).getSourcePath());
   640 		assertEquals(new Path("group/last.txt"), bldInfData.getExports().get(2).getSourcePath());
   658 		assertEquals(new Path("group/last.txt"), bldInfData.getExports().get(2).getSourcePath());
   641 	}
   659 	}
   642 	
   660 	
   643 	public void testPreprocessorProblems() {
   661 	public void testPreprocessorProblems() {
   976 				"\r\n" + 
   994 				"\r\n" + 
   977 				"\r\n" + 
   995 				"\r\n" + 
   978 				"//  End of File  \r\n"; 
   996 				"//  End of File  \r\n"; 
   979 				
   997 				
   980 		Map<String, String> originalFiles = new HashMap<String, String>();
   998 		Map<String, String> originalFiles = new HashMap<String, String>();
   981 		originalFiles.put("..\\Speeddial\\group\\bld.inf", spdiaText);
   999 		originalFiles.put(new Path("../Speeddial/group/bld.inf").toOSString(), spdiaText);
   982 		// this fails
  1000 		// this fails
   983 		originalFiles.put("platform_paths.hrh", "\n"+"#ifndef MACRO\n"+"#define MACRO\n"+"\n"+"#endif\n"+"\n");
  1001 		originalFiles.put("platform_paths.hrh", "\n"+"#ifndef MACRO\n"+"#define MACRO\n"+"\n"+"#endif\n"+"\n");
   984 		// this passes
  1002 		// this passes
   985 		//originalFiles.put("platform_paths.hrh", "#ifndef MACRO\n"+"#define MACRO\n"+"\n"+"#endif\n");
  1003 		//originalFiles.put("platform_paths.hrh", "#ifndef MACRO\n"+"#define MACRO\n"+"\n"+"#endif\n");
   986 		/////originalFiles.put("platform_paths.hrh", loadFileText("data/s60/platform_paths.hrh"));
  1004 		/////originalFiles.put("platform_paths.hrh", loadFileText("data/s60/platform_paths.hrh"));
  1268 			"*  Name        : bld.inf\r\n" + 
  1286 			"*  Name        : bld.inf\r\n" + 
  1269 			"*  Part of     : \r\n" + 
  1287 			"*  Part of     : \r\n" + 
  1270 			"*  Description : \r\n" + 
  1288 			"*  Description : \r\n" + 
  1271 			"*  Version     : \r\n" + 
  1289 			"*  Version     : \r\n" + 
  1272 			"*\r\n" + 
  1290 			"*\r\n" + 
  1273 			"*  Copyright © 2006 Nokia. All rights reserved.\r\n" + 
  1291 			"*  Copyright (c) 2006 Nokia. All rights reserved.\r\n" + 
  1274 			"*  This material, including documentation and any related\r\n" + 
  1292 			"*  This material, including documentation and any related\r\n" + 
  1275 			"*  computer programs, is protected by copyright controlled by\r\n" + 
  1293 			"*  computer programs, is protected by copyright controlled by\r\n" + 
  1276 			"*  Nokia Corporation. All rights are reserved. Copying,\r\n" + 
  1294 			"*  Nokia Corporation. All rights are reserved. Copying,\r\n" + 
  1277 			"*  including reproducing, storing, adapting or translating, any\r\n" + 
  1295 			"*  including reproducing, storing, adapting or translating, any\r\n" + 
  1278 			"*  or all of this material requires the prior written consent of\r\n" + 
  1296 			"*  or all of this material requires the prior written consent of\r\n" + 
  1327 			"*  Description : \r\n" + 
  1345 			"*  Description : \r\n" + 
  1328 			"*    This file provides the information required for building the\r\n" + 
  1346 			"*    This file provides the information required for building the\r\n" + 
  1329 			"*    whole MusicPlayer application including all related libraries.\r\n" + 
  1347 			"*    whole MusicPlayer application including all related libraries.\r\n" + 
  1330 			"*  Version     : \r\n" + 
  1348 			"*  Version     : \r\n" + 
  1331 			"*\r\n" + 
  1349 			"*\r\n" + 
  1332 			"*  Copyright © 2002-2006 Nokia Corporation.\r\n" + 
  1350 			"*  Copyright (c) 2002-2006 Nokia Corporation.\r\n" + 
  1333 			"*  This material, including documentation and any related \r\n" + 
  1351 			"*  This material, including documentation and any related \r\n" + 
  1334 			"*  computer programs, is protected by copyright controlled by \r\n" + 
  1352 			"*  computer programs, is protected by copyright controlled by \r\n" + 
  1335 			"*  Nokia Corporation. All rights are reserved. Copying, \r\n" + 
  1353 			"*  Nokia Corporation. All rights are reserved. Copying, \r\n" + 
  1336 			"*  including reproducing, storing, adapting or translating, any \r\n" + 
  1354 			"*  including reproducing, storing, adapting or translating, any \r\n" + 
  1337 			"*  or all of this material requires the prior written consent of \r\n" + 
  1355 			"*  or all of this material requires the prior written consent of \r\n" + 
  1428 			"*  Part of	: MusicShop\r\n" + 
  1446 			"*  Part of	: MusicShop\r\n" + 
  1429 			"*  Description	: This is a top level bld file that drives all sub-components\r\n" + 
  1447 			"*  Description	: This is a top level bld file that drives all sub-components\r\n" + 
  1430 			"*                that make up the MusicShopEmbed, MusicShopApp and MusicShopLib\r\n" + 
  1448 			"*                that make up the MusicShopEmbed, MusicShopApp and MusicShopLib\r\n" + 
  1431 			"*  Version	: %version: da1mmcf#15 %\r\n" + 
  1449 			"*  Version	: %version: da1mmcf#15 %\r\n" + 
  1432 			"*\r\n" + 
  1450 			"*\r\n" + 
  1433 			"*  Copyright © 2006 Nokia. All rights reserved.\r\n" + 
  1451 			"*  Copyright (c) 2006 Nokia. All rights reserved.\r\n" + 
  1434 			"*  This material, including documentation and any related\r\n" + 
  1452 			"*  This material, including documentation and any related\r\n" + 
  1435 			"*  computer programs, is protected by copyright controlled by\r\n" + 
  1453 			"*  computer programs, is protected by copyright controlled by\r\n" + 
  1436 			"*  Nokia Corporation. All rights are reserved. Copying,\r\n" + 
  1454 			"*  Nokia Corporation. All rights are reserved. Copying,\r\n" + 
  1437 			"*  including reproducing, storing, adapting or translating, any\r\n" + 
  1455 			"*  including reproducing, storing, adapting or translating, any\r\n" + 
  1438 			"*  or all of this material requires the prior written consent of\r\n" + 
  1456 			"*  or all of this material requires the prior written consent of\r\n" + 
  1475 			"*  Description : \r\n" + 
  1493 			"*  Description : \r\n" + 
  1476 			"*    This file provides the information required for building the\r\n" + 
  1494 			"*    This file provides the information required for building the\r\n" + 
  1477 			"*    all MusicVisualization projects including plugins.\r\n" + 
  1495 			"*    all MusicVisualization projects including plugins.\r\n" + 
  1478 			"*  Version     : \r\n" + 
  1496 			"*  Version     : \r\n" + 
  1479 			"*\r\n" + 
  1497 			"*\r\n" + 
  1480 			"*  Copyright © 2005 Nokia Corporation.\r\n" + 
  1498 			"*  Copyright (c) 2005 Nokia Corporation.\r\n" + 
  1481 			"*  This material, including documentation and any related \r\n" + 
  1499 			"*  This material, including documentation and any related \r\n" + 
  1482 			"*  computer programs, is protected by copyright controlled by \r\n" + 
  1500 			"*  computer programs, is protected by copyright controlled by \r\n" + 
  1483 			"*  Nokia Corporation. All rights are reserved. Copying, \r\n" + 
  1501 			"*  Nokia Corporation. All rights are reserved. Copying, \r\n" + 
  1484 			"*  including reproducing, storing, adapting or translating, any \r\n" + 
  1502 			"*  including reproducing, storing, adapting or translating, any \r\n" + 
  1485 			"*  or all of this material requires the prior written consent of \r\n" + 
  1503 			"*  or all of this material requires the prior written consent of \r\n" + 
  1506 			"\r\n" + 
  1524 			"\r\n" + 
  1507 			"PRJ_TESTMMPFILES\r\n" + 
  1525 			"PRJ_TESTMMPFILES\r\n" + 
  1508 			"\r\n" + 
  1526 			"\r\n" + 
  1509 			"// End of File\r\n" ; 
  1527 			"// End of File\r\n" ; 
  1510 			
  1528 			
  1511 		parserConfig.getFilesystem().put("..\\MusicPlayer\\group\\bld.inf", musicPlayerBldInf);
  1529 		parserConfig.getFilesystem().put("../MusicPlayer/group/bld.inf", musicPlayerBldInf);
  1512 		parserConfig.getFilesystem().put("..\\MusicShop\\group\\bld.inf", musicShopBldInf);
  1530 		parserConfig.getFilesystem().put("../MusicShop/group/bld.inf", musicShopBldInf);
  1513 		parserConfig.getFilesystem().put("..\\MusicVisualization\\group\\bld.inf", musicVisualizationBldInf);
  1531 		parserConfig.getFilesystem().put("../MusicVisualization/group/bld.inf", musicVisualizationBldInf);
  1514 			
  1532 			
  1515 		makeModel(origFile);
  1533 		makeModel(origFile);
  1516 		
  1534 		
  1517 		IBldInfView view = getView(config);
  1535 		IBldInfView view = getView(config);
  1518 		assertNotNull(view);
  1536 		assertNotNull(view);
  1519 		
  1537 		
  1520 		IMMPReference ref = view.createMMPReference();
  1538 		IMMPReference ref = view.createMMPReference();
  1521 		ref.setPath(new Path("group\\FMRadio.mmp"));
  1539 		ref.setPath(new Path("group/FMRadio.mmp"));
  1522 		view.getMakMakeReferences().add(ref);
  1540 		view.getMakMakeReferences().add(ref);
  1523 		
  1541 		
  1524 		commitTest(view, updatedFile);
  1542 		commitTest(view, updatedFile);
  1525 		assertEquals(parserConfig.getFilesystem().get("..\\MusicPlayer\\group\\bld.inf"), musicPlayerBldInf);
  1543 		assertEquals(parserConfig.getFilesystem().get("../MusicPlayer/group/bld.inf"), musicPlayerBldInf);
  1526 		assertEquals(parserConfig.getFilesystem().get("..\\MusicShop\\group\\bld.inf"), musicShopBldInf);
  1544 		assertEquals(parserConfig.getFilesystem().get("../MusicShop/group/bld.inf"), musicShopBldInf);
  1527 		assertEquals(parserConfig.getFilesystem().get("..\\MusicVisualization\\group\\bld.inf"), musicVisualizationBldInf);
  1545 		assertEquals(parserConfig.getFilesystem().get("../MusicVisualization/group/bld.inf"), musicVisualizationBldInf);
  1528  
  1546  
  1529 	}
  1547 	}
  1530 	
  1548 	
  1531 	
  1549 	
  1532 	/**
  1550 	/**