2
|
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 |
*/
|
|
17 |
package com.nokia.sdt.emf.dm.tests;
|
|
18 |
|
|
19 |
import com.nokia.sdt.emf.dm.IDesignerData;
|
|
20 |
import com.nokia.sdt.symbian.dm.DesignerDataModel;
|
|
21 |
import com.nokia.sdt.testsupport.TestDataModelHelpers;
|
|
22 |
import com.nokia.cpp.internal.api.utils.core.ProjectUtils;
|
|
23 |
|
|
24 |
import org.eclipse.core.resources.IProject;
|
|
25 |
import org.eclipse.emf.ecore.EObject;
|
|
26 |
import org.eclipse.emf.edit.domain.EditingDomain;
|
|
27 |
|
|
28 |
import java.io.File;
|
|
29 |
|
|
30 |
import junit.framework.TestCase;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Simple tests on a newly created data model with no root container
|
|
34 |
*
|
|
35 |
*/
|
|
36 |
public class NewEmptyDataModelTest extends TestCase {
|
|
37 |
|
|
38 |
DesignerDataModel model;
|
|
39 |
|
|
40 |
static final String PROJECT_NAME = "newemptydm";
|
|
41 |
static final String FILE_NAME = "model.nxd";
|
|
42 |
|
|
43 |
protected void setUp() throws Exception {
|
|
44 |
super.setUp();
|
|
45 |
IProject project = ProjectUtils.createAndOpenProject(PROJECT_NAME);
|
|
46 |
File projectDir = new File(project.getLocation().toOSString());
|
|
47 |
File dmFile = new File(projectDir, FILE_NAME);
|
|
48 |
|
|
49 |
// make a file local to this plugin, in the testdata directory
|
|
50 |
model = (DesignerDataModel) TestDataModelHelpers.createTestModel(dmFile, null);
|
|
51 |
TestDataModelHelpers.initDefaultComponentSet(model);
|
|
52 |
}
|
|
53 |
|
|
54 |
protected void tearDown() throws Exception {
|
|
55 |
super.tearDown();
|
|
56 |
model.dispose();
|
|
57 |
ProjectUtils.closeAndDeleteProject(PROJECT_NAME);
|
|
58 |
}
|
|
59 |
|
|
60 |
public void testGetDesignerData() {
|
|
61 |
// we expect the root object to be automatically created
|
|
62 |
EObject root = model.getRoot();
|
|
63 |
assertNotNull(root);
|
|
64 |
// not required by IDesignerDataModel, but it's what we expect
|
|
65 |
assertTrue(root instanceof IDesignerData);
|
|
66 |
}
|
|
67 |
|
|
68 |
public void testGetEditingDomain() {
|
|
69 |
EditingDomain domain = model.getEditingDomain();
|
|
70 |
assertNotNull(domain);
|
|
71 |
}
|
|
72 |
|
|
73 |
public void testGetNullRootContainer() {
|
|
74 |
// no root container is added by default
|
|
75 |
assertEquals(0, model.getRootContainers().length);
|
|
76 |
}
|
|
77 |
|
|
78 |
public void testGetComponentSet() {
|
|
79 |
assertNotNull(model.getComponentSet());
|
|
80 |
}
|
|
81 |
}
|