Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » "Validation" and "Error Markers" behave strange when testing("Validation" and "Error Markers" behave strange when testing)
"Validation" and "Error Markers" behave strange when testing [message #1180996] Mon, 11 November 2013 09:46 Go to next message
Arne Deutsch is currently offline Arne Deutsch
Messages: 2
Registered: July 2009
Junior Member
Hello all,

we use SWTBot successfully so far to test our application at system level. It is an extension to the eclipse IDE (eclipse 4.2.2 serves as base, we provide some additional plugins and some brandung). But now I experience some strange behaviour (on windows and on linux platform). It is important to note that all is working well when I start the application with a "normal" run-configuration. The following behaviour occures ONLY inside the testing context (when I start the application trough "Run As->SWTBot Test").

Problem description: Inside the tests the "Validate" functionality for XML files does not work correctly. When I open an XML file inside a test with the "XML Editor", display the "Source" tab and open the context menu, then there is an entry "Validate". The entry is active and I can click it. But there is no result displayed. Normally a dialog opens with the message "The validation completed with no Errors or warnings.".

The second thing that is not working correctly are the error markers in the editor. When I open the XML editor and insert a wrong tag (not complient to the XSD) there is no error marker set to indicate the wrong name. This also works when I start the application the usual way.

Anybody an idea what might cause this strange behaviour? I can't find an open bug ticket with something like this but it clearly seems to be related to SWTBot because all is working when I start the application in "non-testing-mode".

Thank you for feedback!
Re: "Validation" and "Error Markers" behave strange when testing [message #1181360 is a reply to message #1180996] Mon, 11 November 2013 14:58 Go to previous messageGo to next message
Arne Deutsch is currently offline Arne Deutsch
Messages: 2
Registered: July 2009
Junior Member
At least for the most critical aspect of my problem I have found the solution in the meantime (by debugging eclipse). Here my solution in case someone stumbles over the same:

org.eclipse.wst.validation.ui.internal.dialog.ResultsDialog is the Dialog that should be opened (but does not in case of a test). It is because of the following code:

@Override
public int open() {
	if (!ErrorDialog.AUTOMATED_MODE) {
		return super.open();
	}
	setReturnCode(OK);
	return OK;
}


When running the tests ErrorDialog.AUTOMATED_MODE is true, probably because under certain conditions the dialog would make the tests unexpectly failing, steals Focus or something similar. In this case I want to have the Dialog, I'm expect it to open. Because of this I set ErrorDialog.AUTOMATED_MODE temporarily to false. Like this:

public boolean isValidationSuccessfull(String projectName) {
	// The opened dialog makes an explicit check if we are currently inside an automated test. If so the dialog is
	// not opened, probably because an unexpected dialog can, asynchronously opened, can result in curious test
	// failures. In this case we expect an error dialog. Because of this we temporarily tell eclipse that we do NOT
	// test automatically, let it open the dialog and reset test information at the end.
	boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
	ErrorDialog.AUTOMATED_MODE = false;
	try {
		getTree().expandNode(projectName, "project.xml.conf2").contextMenu("Validate").click();
		bot.waitUntil(shellIsActive("Validation Results"));
		boolean result = bot.label(1).getText().contains("no errors or warnings");
		bot.button("OK").click();
		return result;
	} finally {
		ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
	}
}
Re: "Validation" and "Error Markers" behave strange when testing [message #1182642 is a reply to message #1180996] Tue, 12 November 2013 10:05 Go to previous message
Mickael Istria is currently offline Mickael Istria
Messages: 765
Registered: July 2009
Location: Grenoble, France
Senior Member
On 11/11/2013 03:19 PM, Arne Deutsch wrote:
> The second thing that is not working correctly are the error markers in
> the editor. When I open the XML editor and insert a wrong tag (not
> complient to the XSD) there is no error marker set to indicate the wrong
> name. This also works when I start the application the usual way.

It might be because you Test Configuration is missing one of the bundles
providing validation.

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Previous Topic:How to click menu items in SWTBOT
Next Topic:How to update a value in a particular cell in SwtBotTree
Goto Forum:
  


Current Time: Fri Oct 24 12:55:54 GMT 2014

Powered by FUDForum. Page generated in 0.22127 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software