1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
* Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Martin Fluegge - initial API and implementation
*/
package org.eclipse.emf.cdo.dawn.tests.ui.emf;
import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
import org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditor;
import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* @author Martin Fluegge
*/
public class DawnBasicEMFUITest extends AbstractCDOTest
{
@Override
public void doSetUp() throws Exception
{
super.doSetUp();
getRepositoryConfig().getRepositoryProperties().put("overrideUUID", "");
}
public void testGetEditorIdForDawnEditor()
{
final CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/test.acore");
String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
assertEquals(DawnAcoreEditor.ID, editorID);
}
public void testEditorInput() throws PartInitException
{
final CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/sample/test.acore");
String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
assertEquals(DawnAcoreEditor.ID, editorID);
DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
editorInput.setResource(resource);
assertEquals(resource, editorInput.getResource());
assertEquals(resource.getPath(), editorInput.getResourcePath());
assertEquals(transaction, editorInput.getView());
assertEquals(resource.getURI(), editorInput.getURI());
assertEquals(false, editorInput.isViewOwned());
}
public void testOpenEditor() throws PartInitException
{
final CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/test.acore");
ACoreRoot aCoreRoot = AcoreFactory.eINSTANCE.createACoreRoot();
resource.getContents().add(aCoreRoot);
try
{
transaction.commit();
}
catch (CommitException ex)
{
throw new RuntimeException(ex);
}
String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
assertEquals(DawnAcoreEditor.ID, editorID);
DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
// TODO Test case fails because the ConnectionUtil is not initialized. Fake it here or use the DawnExplorer to open
// the editor.
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite()
.getPage().openEditor(editorInput, editorID);
sleep(5000);
assertInstanceOf(DawnAcoreEditor.class, editor);
}
}
|