0
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 |
|
|
18 |
package com.nokia.s60tools.imaker.internal.tests;
|
|
19 |
|
|
20 |
|
|
21 |
import java.io.BufferedReader;
|
|
22 |
import java.io.File;
|
|
23 |
import java.io.FileInputStream;
|
|
24 |
import java.io.IOException;
|
|
25 |
import java.io.InputStream;
|
|
26 |
import java.io.InputStreamReader;
|
|
27 |
import java.util.ArrayList;
|
|
28 |
import java.util.List;
|
|
29 |
|
|
30 |
import org.eclipse.core.runtime.IPath;
|
|
31 |
|
|
32 |
import com.nokia.s60tools.imaker.internal.managers.ProjectManager;
|
|
33 |
|
|
34 |
public class ProjectManagerTest extends ProjectBuilder {
|
|
35 |
private final String CONTENT = "sample content";
|
|
36 |
private final String LOCATION = "rofs3";
|
|
37 |
private final String FILENAME = ProjectManager.IBY_FILENAME_PREFIX+LOCATION;
|
|
38 |
private ProjectManager projectManager;
|
|
39 |
|
|
40 |
public void setUp() throws Exception {
|
|
41 |
createDefaultProject();
|
|
42 |
addImakerImpFiles();
|
|
43 |
assertTrue(project.isAccessible());
|
|
44 |
projectManager = new ProjectManager(project);
|
|
45 |
}
|
|
46 |
|
|
47 |
public void tearDown() throws Exception {
|
|
48 |
// closeAndDeleteDefaultProject();
|
|
49 |
}
|
|
50 |
|
|
51 |
public void testLocation() {
|
|
52 |
assertTrue(!projectManager.getRoot().equals(""));
|
|
53 |
}
|
|
54 |
public void testImplFiles() throws Exception {
|
|
55 |
assertTrue("No impl files found. There shoud be some in the testdata folder!",!projectManager.getImakerFiles().isEmpty());
|
|
56 |
}
|
|
57 |
|
|
58 |
public void testIbyFiles() {
|
|
59 |
IPath path = project.getLocation();
|
|
60 |
IPath filePath = projectManager.createIbyFile(FILENAME, CONTENT, path);
|
|
61 |
File file = filePath.toFile();
|
|
62 |
assertTrue("Coudn't create iby file under test projec!", file.exists());
|
|
63 |
try {
|
|
64 |
FileInputStream fs = new FileInputStream(file);
|
|
65 |
String line = getContents(fs);
|
|
66 |
assertEquals(CONTENT, line);
|
|
67 |
} catch (IOException e) {
|
|
68 |
e.printStackTrace();
|
|
69 |
}
|
|
70 |
}
|
|
71 |
|
|
72 |
private String getContents(InputStream contents) throws IOException {
|
|
73 |
BufferedReader br = new BufferedReader(new InputStreamReader(contents));
|
|
74 |
String line = br.readLine();
|
|
75 |
return line;
|
|
76 |
}
|
|
77 |
|
|
78 |
public void testMakefile() throws Exception {
|
|
79 |
List<IPath> ifiles = new ArrayList<IPath>();
|
|
80 |
IPath path = project.getLocation();
|
|
81 |
IPath filePath = projectManager.createIbyFile(FILENAME, CONTENT, path);
|
|
82 |
ifiles.add(filePath);
|
|
83 |
|
|
84 |
IPath mk = projectManager.createAdditionsMakefile(ifiles,path);
|
|
85 |
|
|
86 |
assertNotNull("Makefile creation failled!",mk);
|
|
87 |
assertTrue("Makefile creation failled!", mk.toFile().exists());
|
|
88 |
FileInputStream fs = new FileInputStream(mk.toFile());
|
|
89 |
String cons = getContents(fs);
|
|
90 |
assertNotNull(cons);
|
|
91 |
assertEquals(LOCATION.toUpperCase()+"_OBY += "+ filePath.toFile().getAbsolutePath(),cons);
|
|
92 |
}
|
|
93 |
}
|