uidesigner/com.nokia.sdt.emf.dm.tests/src/com/nokia/sdt/emf/dm/tests/NewEmptyDataModelTest.java
author timkelly
Mon, 06 Apr 2009 14:15:39 -0500
changeset 52 e26ecc088f24
parent 2 d760517a8095
permissions -rw-r--r--
Add tests for regressing bug 8804.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
/*
cawthron
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
cawthron
parents:
diff changeset
     3
* All rights reserved.
cawthron
parents:
diff changeset
     4
* This component and the accompanying materials are made available
cawthron
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
cawthron
parents:
diff changeset
     6
* which accompanies this distribution, and is available
cawthron
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
cawthron
parents:
diff changeset
     8
*
cawthron
parents:
diff changeset
     9
* Initial Contributors:
cawthron
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
cawthron
parents:
diff changeset
    11
*
cawthron
parents:
diff changeset
    12
* Contributors:
cawthron
parents:
diff changeset
    13
*
cawthron
parents:
diff changeset
    14
* Description: 
cawthron
parents:
diff changeset
    15
*
cawthron
parents:
diff changeset
    16
*/
cawthron
parents:
diff changeset
    17
package com.nokia.sdt.emf.dm.tests;
cawthron
parents:
diff changeset
    18
cawthron
parents:
diff changeset
    19
import com.nokia.sdt.emf.dm.IDesignerData;
cawthron
parents:
diff changeset
    20
import com.nokia.sdt.symbian.dm.DesignerDataModel;
cawthron
parents:
diff changeset
    21
import com.nokia.sdt.testsupport.TestDataModelHelpers;
cawthron
parents:
diff changeset
    22
import com.nokia.cpp.internal.api.utils.core.ProjectUtils;
cawthron
parents:
diff changeset
    23
cawthron
parents:
diff changeset
    24
import org.eclipse.core.resources.IProject;
cawthron
parents:
diff changeset
    25
import org.eclipse.emf.ecore.EObject;
cawthron
parents:
diff changeset
    26
import org.eclipse.emf.edit.domain.EditingDomain;
cawthron
parents:
diff changeset
    27
cawthron
parents:
diff changeset
    28
import java.io.File;
cawthron
parents:
diff changeset
    29
cawthron
parents:
diff changeset
    30
import junit.framework.TestCase;
cawthron
parents:
diff changeset
    31
cawthron
parents:
diff changeset
    32
/**
cawthron
parents:
diff changeset
    33
 * Simple tests on a newly created data model with no root container
cawthron
parents:
diff changeset
    34
 *
cawthron
parents:
diff changeset
    35
 */
cawthron
parents:
diff changeset
    36
public class NewEmptyDataModelTest extends TestCase {
cawthron
parents:
diff changeset
    37
	
cawthron
parents:
diff changeset
    38
	DesignerDataModel model;
cawthron
parents:
diff changeset
    39
	
cawthron
parents:
diff changeset
    40
	static final String PROJECT_NAME = "newemptydm";
cawthron
parents:
diff changeset
    41
	static final String FILE_NAME = "model.nxd";
cawthron
parents:
diff changeset
    42
cawthron
parents:
diff changeset
    43
	protected void setUp() throws Exception {
cawthron
parents:
diff changeset
    44
		super.setUp();
cawthron
parents:
diff changeset
    45
		IProject project = ProjectUtils.createAndOpenProject(PROJECT_NAME);
cawthron
parents:
diff changeset
    46
		File projectDir = new File(project.getLocation().toOSString());
cawthron
parents:
diff changeset
    47
		File dmFile = new File(projectDir, FILE_NAME);
cawthron
parents:
diff changeset
    48
		
cawthron
parents:
diff changeset
    49
		// make a file local to this plugin, in the testdata directory
cawthron
parents:
diff changeset
    50
		model = (DesignerDataModel) TestDataModelHelpers.createTestModel(dmFile, null);
cawthron
parents:
diff changeset
    51
		TestDataModelHelpers.initDefaultComponentSet(model);
cawthron
parents:
diff changeset
    52
	}
cawthron
parents:
diff changeset
    53
cawthron
parents:
diff changeset
    54
	protected void tearDown() throws Exception {
cawthron
parents:
diff changeset
    55
		super.tearDown();
cawthron
parents:
diff changeset
    56
		model.dispose();
cawthron
parents:
diff changeset
    57
		ProjectUtils.closeAndDeleteProject(PROJECT_NAME);
cawthron
parents:
diff changeset
    58
	}
cawthron
parents:
diff changeset
    59
cawthron
parents:
diff changeset
    60
	public void testGetDesignerData() {
cawthron
parents:
diff changeset
    61
		// we expect the root object to be automatically created
cawthron
parents:
diff changeset
    62
		EObject root = model.getRoot();
cawthron
parents:
diff changeset
    63
		assertNotNull(root);
cawthron
parents:
diff changeset
    64
		// not required by IDesignerDataModel, but it's what we expect
cawthron
parents:
diff changeset
    65
		assertTrue(root instanceof IDesignerData);
cawthron
parents:
diff changeset
    66
	}
cawthron
parents:
diff changeset
    67
cawthron
parents:
diff changeset
    68
	public void testGetEditingDomain() {
cawthron
parents:
diff changeset
    69
		EditingDomain domain = model.getEditingDomain();
cawthron
parents:
diff changeset
    70
		assertNotNull(domain);
cawthron
parents:
diff changeset
    71
	}
cawthron
parents:
diff changeset
    72
cawthron
parents:
diff changeset
    73
	public void testGetNullRootContainer() {
cawthron
parents:
diff changeset
    74
		// no root container is added by default
cawthron
parents:
diff changeset
    75
		assertEquals(0, model.getRootContainers().length);
cawthron
parents:
diff changeset
    76
	}
cawthron
parents:
diff changeset
    77
cawthron
parents:
diff changeset
    78
	public void testGetComponentSet() {
cawthron
parents:
diff changeset
    79
		assertNotNull(model.getComponentSet());
cawthron
parents:
diff changeset
    80
	}
cawthron
parents:
diff changeset
    81
}