9
|
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 the License "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 |
*/
|
2
|
17 |
package com.nokia.cdt.debug.cw.symbian.tests;
|
|
18 |
|
|
19 |
import java.io.File;
|
|
20 |
import java.io.IOException;
|
|
21 |
|
|
22 |
import junit.framework.TestCase;
|
|
23 |
|
|
24 |
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
|
25 |
import org.eclipse.core.runtime.IPath;
|
|
26 |
import org.eclipse.core.runtime.Path;
|
|
27 |
|
|
28 |
import com.nokia.cdt.debug.cw.symbian.binaryparser.SymbianE32Parser;
|
|
29 |
|
|
30 |
public class SymbianE32ParserTest extends TestCase {
|
|
31 |
|
|
32 |
static String s_testFileName = "data\\_h2_dma.dll";
|
|
33 |
|
|
34 |
IPath m_testFilePath = null;
|
|
35 |
|
|
36 |
SymbianE32Parser m_parser = null;
|
|
37 |
|
|
38 |
/*
|
|
39 |
* (non-Javadoc)
|
|
40 |
*
|
|
41 |
* @see junit.framework.TestCase#setUp()
|
|
42 |
*/
|
|
43 |
@Override
|
|
44 |
protected void setUp() throws Exception {
|
|
45 |
super.setUp();
|
|
46 |
m_parser = new SymbianE32Parser();
|
|
47 |
if (m_parser == null)
|
|
48 |
fail("Failed to instantiate SymbianE32Parser.");
|
|
49 |
|
|
50 |
File f = TestsPlugin.projectRelativeFile(s_testFileName);
|
|
51 |
if (f == null || !f.exists())
|
|
52 |
fail("Data file " + s_testFileName + " not found.");
|
|
53 |
|
|
54 |
m_testFilePath = new Path(f.getAbsolutePath());
|
|
55 |
}
|
|
56 |
|
|
57 |
/*
|
|
58 |
* (non-Javadoc)
|
|
59 |
*
|
|
60 |
* @see junit.framework.TestCase#tearDown()
|
|
61 |
*/
|
|
62 |
@Override
|
|
63 |
protected void tearDown() throws Exception {
|
|
64 |
super.tearDown();
|
|
65 |
// Dispose the parser
|
|
66 |
m_parser = null;
|
|
67 |
}
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Test method for
|
|
71 |
* {@link com.nokia.cdt.debug.cw.symbian.binaryparser.SymbianE32Parser#getBinary(org.eclipse.core.runtime.IPath)}.
|
|
72 |
*/
|
|
73 |
// @Test
|
|
74 |
public void testGetBinaryIPath() {
|
|
75 |
IBinaryFile binary = null;
|
|
76 |
|
|
77 |
String msg = "The file " + s_testFileName + " is not recognized.";
|
|
78 |
try {
|
|
79 |
binary = m_parser.getBinary(m_testFilePath);
|
|
80 |
} catch (IOException e) {
|
|
81 |
fail(msg);
|
|
82 |
}
|
|
83 |
|
|
84 |
assertTrue(msg, binary != null);
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Test method for
|
|
89 |
* {@link com.nokia.cdt.debug.cw.symbian.binaryparser.SymbianE32Parser#getFormat()}.
|
|
90 |
*/
|
|
91 |
// @Test
|
|
92 |
public void testGetFormat() {
|
|
93 |
assertTrue("getFormat() fails", m_parser.getFormat() == "Symbian E32");
|
|
94 |
}
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Test method for
|
|
98 |
* {@link com.nokia.cdt.debug.cw.symbian.binaryparser.SymbianE32Parser#isBinary(byte[], org.eclipse.core.runtime.IPath)}.
|
|
99 |
*/
|
|
100 |
// @Test
|
|
101 |
public void testIsBinary() {
|
|
102 |
assertTrue("File " + s_testFileName + " is not Symbian E32 binary",
|
|
103 |
m_parser.isBinary(null, m_testFilePath));
|
|
104 |
}
|
|
105 |
}
|