Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-studio
Commits
b4231b57
Commit
b4231b57
authored
Jul 16, 2014
by
Aurelien Pupier
Browse files
Use waitUntil conditions to avoid aleatory behavior
parent
4d2e3a67
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/org.bonitasoft.studio.tests/src/org/bonitasoft/studio/tests/form/TestBug1682.java
View file @
b4231b57
/**
* Copyright (C) 2010 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
*
* Copyright (C) 2010-2014 Bonitasoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.bonitasoft.studio.tests.form
;
...
...
@@ -23,7 +20,9 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase
;
import
org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor
;
import
org.eclipse.swtbot.swt.finder.SWTBot
;
import
org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner
;
import
org.eclipse.swtbot.swt.finder.waits.ICondition
;
import
org.eclipse.ui.PlatformUI
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -37,7 +36,6 @@ public class TestBug1682 extends SWTBotGefTestCase {
protected
Rectangle
bounds
;
private
int
nbParts
;
private
int
nbPartsAfterDelete
;
@Test
public
void
testBug1682
()
throws
Exception
{
...
...
@@ -45,37 +43,51 @@ public class TestBug1682 extends SWTBotGefTestCase {
public
void
run
()
{
try
{
FormDiagramEditor
editor
=
TestCommands
.
openFormEditorWithBaseTestForForm
();
final
FormDiagramEditor
editor
=
TestCommands
.
openFormEditorWithBaseTestForForm
();
nbParts
=
editor
.
getDiagramEditPart
().
getChildren
().
size
();
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
}
}
});
/*The editor for process*/
String
title
=
bot
.
activeEditor
().
getTitle
();
SWTBotGefEditor
gefEditor
=
bot
.
gefEditor
(
title
);
final
String
title
=
bot
.
activeEditor
().
getTitle
();
final
SWTBotGefEditor
gefEditor
=
bot
.
gefEditor
(
title
);
/*get the form in the first process (pool)*/
gefEditor
.
mainEditPart
().
children
().
get
(
0
).
select
();
gefEditor
.
clickContextMenu
(
"Delete"
);
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
Display
.
getDefault
().
syncExec
(
new
Runnable
()
{
public
void
run
()
{
try
{
FormDiagramEditor
editor
=
(
FormDiagramEditor
)
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
().
getActivePage
().
getActiveEditor
();
nbPartsAfterDelete
=
editor
.
getDiagramEditPart
().
getChildren
().
size
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
bot
.
waitUntil
(
new
ICondition
()
{
private
int
nbPartsAfterDelete
;
public
boolean
test
()
throws
Exception
{
Display
.
getDefault
().
syncExec
(
new
Runnable
()
{
public
void
run
()
{
try
{
final
FormDiagramEditor
editor
=
(
FormDiagramEditor
)
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
().
getActivePage
()
.
getActiveEditor
();
nbPartsAfterDelete
=
editor
.
getDiagramEditPart
().
getChildren
().
size
();
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
}
}
});
return
nbParts
-
1
==
nbPartsAfterDelete
;
}
});
gefEditor
.
save
();
assertEquals
(
"Part not deleted"
,
nbParts
-
1
,
nbPartsAfterDelete
);
public
void
init
(
final
SWTBot
bot
)
{
}
public
String
getFailureMessage
()
{
return
"Part not deleted"
;
}
});
gefEditor
.
save
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment