C tools test cases [message #457855] |
Sat, 01 August 2009 22:36  |
Eclipse User |
|
|
|
Here are a couple of tests that I added for C with the mingw cdt tools
installed. These are similar to your java examples... creating their
stationery Hello World example as project C1, then running it and checking
the output in the Console View. Note that the StyledText casting code is
a little different. Your java examples were out of date, and I couldn't
figure out an exact mapping, but I take it you just wanted to have the
assert catch the problem if the StyledText cast was about to fail.
@Test
public void canCreateANewCProject() throws Exception {
SWTBotPerspective clangPerspective = bot.perspectiveByLabel("C/C++");
clangPerspective.activate();
bot.menu("File").menu("New").menu("Project...").click();
SWTBotShell shellProj = bot.shell("New Project");
shellProj.activate();
bot.waitUntil(shellIsActive("New Project"));
bot.tree().expandNode("C").select().click().select("C Project").click();
bot.button("Next >").click();
SWTBotShell shellC = bot.shell("C Project");
shellC.activate();
bot.textWithLabel("Project name:").setText("C1");
shellC.activate();
bot.tree().expandNode("Executable").select("Hello World ANSI C
Project").click();
shellC.activate();
bot.button("Finish").click();
bot.sleep(5000);
// FIXME: assert that the project is actually created, for later
}
@Test
public void canExecuteCApplication() throws Exception {
bot.viewByTitle("Project Explorer");
bot.tree().expandNode("C1").expandNode("Debug").select();
bot.menu("Run").menu("Run").click();
bot.sleep(5000);
bot.viewByTitle("Console").setFocus();
Widget consoleViewComposite = bot.getFocusedWidget();
assertThat (consoleViewComposite,instanceOf(StyledText.class));
StyledText console = (StyledText) consoleViewComposite;
SWTBotStyledText styledText = new SWTBotStyledText(console);
assertTextContains("Hello World", styledText);
}
|
|
|
|
|
Re: C tools test cases [message #459824 is a reply to message #457855] |
Sun, 02 August 2009 03:18   |
Eclipse User |
|
|
|
Looking at your email, I do not understand which of the steps is
failing, what is the expected behavior and what is actually happening.
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
On 2/8/09 08:06, Jay Norwood wrote:
> Here are a couple of tests that I added for C with the mingw cdt tools
> installed. These are similar to your java examples... creating their
> stationery Hello World example as project C1, then running it and
> checking the output in the Console View. Note that the StyledText
> casting code is a little different. Your java examples were out of date,
> and I couldn't figure out an exact mapping, but I take it you just
> wanted to have the assert catch the problem if the StyledText cast was
> about to fail.
>
> @Test
> public void canCreateANewCProject() throws Exception {
> SWTBotPerspective clangPerspective = bot.perspectiveByLabel("C/C++");
> clangPerspective.activate();
> bot.menu("File").menu("New").menu("Project...").click();
>
> SWTBotShell shellProj = bot.shell("New Project");
> shellProj.activate();
> bot.waitUntil(shellIsActive("New Project"));
> bot.tree().expandNode("C").select().click().select("C Project").click();
> bot.button("Next >").click();
>
> SWTBotShell shellC = bot.shell("C Project");
> shellC.activate();
>
> bot.textWithLabel("Project name:").setText("C1");
> shellC.activate();
> bot.tree().expandNode("Executable").select("Hello World ANSI C
> Project").click();
> shellC.activate();
> bot.button("Finish").click();
> bot.sleep(5000);
> // FIXME: assert that the project is actually created, for later
> }
>
> @Test
> public void canExecuteCApplication() throws Exception {
> bot.viewByTitle("Project Explorer");
> bot.tree().expandNode("C1").expandNode("Debug").select();
> bot.menu("Run").menu("Run").click();
> bot.sleep(5000);
> bot.viewByTitle("Console").setFocus();
> Widget consoleViewComposite = bot.getFocusedWidget(); assertThat
> (consoleViewComposite,instanceOf(StyledText.class));
> StyledText console = (StyledText) consoleViewComposite;
> SWTBotStyledText styledText = new SWTBotStyledText(console);
>
> assertTextContains("Hello World", styledText);
> }
>
>
|
|
|
Re: C tools test cases [message #467838 is a reply to message #459824] |
Mon, 03 August 2009 02:15  |
Eclipse User |
|
|
|
All the examples I posted now work ok after adding that code that disables
the automatic switching of perspectives when going from Java to C
projects.
What I was seeing when the perspective changed is that bot.menu references
to the main toolbar menus would fail. I don't know why they would fail
other than the workbench bot was referencing something that lost focus
when the perspective changes.
That was my reason for previously asking about how the context is changing
in response to different statements. It seems to me that at least the
shell activations do change the context, as well as the setFocus on the
views.
I also recall it was necessary to move back out and activate the modal
preference settings shells before attempting to find the outer "OK"
button. I think the finders must only look at children from the context
of the last widget or composite that was selected. That's the feeling I
got while trying to figure out why some searches were failing.
You responded before that the context doesn't change, but there must be
some explanation when I can see the button in the shell, but the finder
doesn't locate it.
|
|
|
Powered by
FUDForum. Page generated in 0.04879 seconds