Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f765a53b51f0d9946942dc3c2ebf91734394b18e (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
/*******************************************************************************
 * Copyright (c) 2015 Red Hat.
 * 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:
 *     Red Hat - Initial Contribution
 *******************************************************************************/

package org.eclipse.linuxtools.internal.docker.ui.testutils.swt;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.junit.rules.ExternalResource;

/**
 * Closes the wizard(s) after each test, if the "Cancel" button is available
 */
public class CloseWizardRule extends ExternalResource {

	@Override
	protected void after() {
		final SWTWorkbenchBot bot = new SWTWorkbenchBot();
		try {
			while (bot.button("Cancel") != null) {
				bot.button("Cancel").click();
			}
		} catch (WidgetNotFoundException e) {
			// ignoring
		}
	}
}

Back to the top