blob: ed84569f7eea0720732eb8cfdf66992e3c7eeef0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010, 2011 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario;
import java.io.File;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;
import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;
import org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractIntentUITest;
import org.eclipse.mylyn.docs.intent.parser.modelingunit.test.utils.FileToStringConverter;
/**
* Checks that replacing all contents through copy/paste works fine.
* <p>
* Relevant issues : Errors when pasting a big document into a small one
* </p>
* <li>https://bugs.eclipse.org/bugs/show_bug.cgi?id=379390 : </p>
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
*/
public class MultipleReplacementInEditorTest extends AbstractIntentUITest {
private static final String INTENT_SMALL_DOC_PATH = "data/unit/documents/scenario/abstract_resources.intent";
private static final String INTENT_BIG_DOC_PATH = "data/unit/documents/editorupdates/compareTest-03.intent";
private IntentEditor editor;
private IntentEditorDocument document;
/**
* {@inheritDoc}
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
// Step 1 : Generic set up
setUpIntentProject("intentProject", INTENT_SMALL_DOC_PATH, true);
// Step 2 : open an editor on the root document
editor = openIntentEditor();
document = (IntentEditorDocument)editor.getDocumentProvider().getDocument(editor.getEditorInput());
}
/**
* Ensures that pasting several times content inside the document does not cause any issue.
*
* @throws Exception
*/
public void testCopyPastBigDocuments() throws Exception {
String smallDocumentContent = FileToStringConverter.getFileAsString(new File(INTENT_SMALL_DOC_PATH));
String bigDocumentContent = FileToStringConverter.getFileAsString(new File(INTENT_BIG_DOC_PATH));
for (int i = 1; i < 200; i++) {
System.err.println(i);
document.set(bigDocumentContent);
editor.doSave(new NullProgressMonitor());
document.set(smallDocumentContent);
editor.doSave(new NullProgressMonitor());
if (i % 15 == 0) {
waitForAllOperationsInUIThread();
tearDown();
setUp();
}
}
}
}