Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1d8d599be4538a67065543bcdc695048925fa187 (plain) (blame)
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
/*****************************************************************************
 * Copyright (c) 2015 CEA LIST 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:
 *   CEA LIST - Initial API and implementation
 *   
 *****************************************************************************/

package org.eclipse.papyrus.uml.nattable.clazz.config.tests.unset;

import java.util.Collections;

import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandler;
import org.eclipse.papyrus.infra.ui.util.EclipseCommandUtils;
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests.AbstractTableTest;
import org.junit.Assert;

/**
 * @author VL222926
 *         Abstract class used to test the unset cell value The unset feature reset the selected cell to its default.
 *         This feature is binded on org.eclipse.ui.edit.delete command
 */
public abstract class AbstractUnsetCellValueTest extends AbstractTableTest {


	/**
	 * 
	 * @param wantedStatus
	 *            the expected status for the handler
	 */
	protected void checkUnsetCellValueHandlerStatusAndExecuteCommandIfRequired(boolean wantedStatus) {
		Command cmd = EclipseCommandUtils.getCommandService().getCommand(EclipseCommandUtils.DELETE_COMMAND);
		Assert.assertNotNull(cmd);
		IHandler handler = cmd.getHandler();
		Assert.assertNotNull(handler);
		/*
		 * the setEnabled of UnsetCellValueHandler has been modified to }
		 */
		Assert.assertEquals(wantedStatus, handler.isEnabled());
		if (wantedStatus) {
			ExecutionEvent event = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null);
			try {
				cmd.executeWithChecks(event);
			} catch (Exception e) {
				Assert.assertNull("An exception occured during the command execution", e); ////$NON-NLS-1$
			}

		}
	}
}

Back to the top