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
54b2e131
Commit
54b2e131
authored
Jul 15, 2014
by
Aurelien Pupier
Browse files
BS-9265: try to have a cleaner tests to avoid aleatory behavior (not
confident)
parent
25f19509
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/org.bonitasoft.studio.diagram.test/src/org/bonitasoft/studio/diagram/test/TestRenameDiagram.java
View file @
54b2e131
/**
* Copyright (C) 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
* 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/>.
*/
package
org.bonitasoft.studio.diagram.test
;
import
org.bonitasoft.studio.common.jface.FileActionDialog
;
...
...
@@ -24,10 +38,13 @@ public class TestRenameDiagram extends SWTBotGefTestCase {
// Before and After
private
static
boolean
disablePopup
;
private
static
boolean
askRenameOnFirstSave
;
@BeforeClass
public
static
void
setUpBeforeClass
()
{
disablePopup
=
FileActionDialog
.
getDisablePopup
();
askRenameOnFirstSave
=
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
getBoolean
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
);
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
setValue
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
,
false
);
FileActionDialog
.
setDisablePopup
(
true
);
}
...
...
@@ -35,76 +52,77 @@ public class TestRenameDiagram extends SWTBotGefTestCase {
@AfterClass
public
static
void
tearDownAfterClass
()
{
FileActionDialog
.
setDisablePopup
(
disablePopup
);
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
setValue
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
,
askRenameOnFirstSave
);
}
@Override
@After
public
void
tearDown
(){
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
setValue
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
,
false
);
bot
.
saveAllEditors
();
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
setValue
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
,
false
);
bot
.
saveAllEditors
();
}
@Test
public
void
testFirstSaveRenaming
(){
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
setValue
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
,
true
);
SWTBotTestUtil
.
createNewDiagram
(
bot
);
SWTBotEditor
botEditor
=
bot
.
activeEditor
();
SWTBotGefEditor
gmfEditor
=
bot
.
gefEditor
(
botEditor
.
getTitle
());
MainProcess
diagram
=
(
MainProcess
)
((
IGraphicalEditPart
)
gmfEditor
.
mainEditPart
().
part
()).
resolveSemanticElement
();
String
originalName
=
diagram
.
getName
();
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
bot
.
waitUntil
(
Conditions
.
shellIsActive
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertTrue
(
"OK should be enabled"
,
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
isEnabled
());
String
newName
=
originalName
+
" renamed"
+
System
.
currentTimeMillis
();
bot
.
textWithLabel
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
name
,
0
).
setText
(
newName
);
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
assertEquals
(
newName
+
" (1.0)"
,
bot
.
activeEditor
().
getTitle
());
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
//Disable dialog
SWTBotTestUtil
.
createNewDiagram
(
bot
);
botEditor
=
bot
.
activeEditor
();
gmfEditor
=
bot
.
gefEditor
(
botEditor
.
getTitle
());
diagram
=
(
MainProcess
)
((
IGraphicalEditPart
)
gmfEditor
.
mainEditPart
().
part
()).
resolveSemanticElement
();
originalName
=
diagram
.
getName
();
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
bot
.
waitUntil
(
Conditions
.
shellIsActive
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertTrue
(
"OK should be enabled"
,
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
isEnabled
());
bot
.
checkBox
(
org
.
bonitasoft
.
studio
.
application
.
i18n
.
Messages
.
doNotDisplayForOtherDiagrams
).
select
();
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
assertEquals
(
originalName
+
" (1.0)"
,
bot
.
activeEditor
().
getTitle
());
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
SWTBotTestUtil
.
createNewDiagram
(
bot
);
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
assertFalse
(
bot
.
activeShell
().
getText
().
equals
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
BonitaStudioPreferencesPlugin
.
getDefault
().
getPreferenceStore
().
setValue
(
BonitaPreferenceConstants
.
ASK_RENAME_ON_FIRST_SAVE
,
true
);
SWTBotTestUtil
.
createNewDiagram
(
bot
);
SWTBotEditor
botEditor
=
bot
.
activeEditor
();
SWTBotGefEditor
gmfEditor
=
bot
.
gefEditor
(
botEditor
.
getTitle
());
MainProcess
diagram
=
(
MainProcess
)
((
IGraphicalEditPart
)
gmfEditor
.
mainEditPart
().
part
()).
resolveSemanticElement
();
String
originalName
=
diagram
.
getName
();
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
bot
.
waitUntil
(
Conditions
.
shellIsActive
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertTrue
(
"OK should be enabled"
,
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
isEnabled
());
final
String
newName
=
originalName
+
" renamed"
+
System
.
currentTimeMillis
();
bot
.
textWithLabel
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
name
,
0
).
setText
(
newName
);
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
assertEquals
(
newName
+
" (1.0)"
,
bot
.
activeEditor
().
getTitle
());
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
//Disable dialog
SWTBotTestUtil
.
createNewDiagram
(
bot
);
botEditor
=
bot
.
activeEditor
();
gmfEditor
=
bot
.
gefEditor
(
botEditor
.
getTitle
());
diagram
=
(
MainProcess
)
((
IGraphicalEditPart
)
gmfEditor
.
mainEditPart
().
part
()).
resolveSemanticElement
();
originalName
=
diagram
.
getName
();
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
bot
.
waitUntil
(
Conditions
.
shellIsActive
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertTrue
(
"OK should be enabled"
,
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
isEnabled
());
bot
.
checkBox
(
org
.
bonitasoft
.
studio
.
application
.
i18n
.
Messages
.
doNotDisplayForOtherDiagrams
).
select
();
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
assertEquals
(
originalName
+
" (1.0)"
,
bot
.
activeEditor
().
getTitle
());
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
SWTBotTestUtil
.
createNewDiagram
(
bot
);
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
assertFalse
(
bot
.
activeShell
().
getText
().
equals
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
}
@Test
public
void
testRenameMenu
(){
SWTBotTestUtil
.
createNewDiagram
(
bot
);
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
SWTBotEditor
botEditor
=
bot
.
activeEditor
();
SWTBotGefEditor
gmfEditor
=
bot
.
gefEditor
(
botEditor
.
getTitle
());
MainProcess
diagram
=
(
MainProcess
)
((
IGraphicalEditPart
)
gmfEditor
.
mainEditPart
().
part
()).
resolveSemanticElement
();
String
originalName
=
diagram
.
getName
();
bot
.
menu
(
"Diagram"
).
menu
(
"Rename..."
).
click
();
bot
.
waitUntil
(
Conditions
.
shellIsActive
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertTrue
(
"OK should be enabled"
,
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
isEnabled
());
final
String
newName
=
originalName
+
" renamed"
+
System
.
currentTimeMillis
();
bot
.
textWithLabel
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
name
,
0
).
setText
(
newName
);
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
assertEquals
(
newName
+
" (1.0)"
,
bot
.
activeEditor
().
getTitle
());
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
SWTBotTestUtil
.
createNewDiagram
(
bot
);
bot
.
menu
(
"Diagram"
).
menu
(
"Save"
).
click
();
final
SWTBotEditor
botEditor
=
bot
.
activeEditor
();
final
SWTBotGefEditor
gmfEditor
=
bot
.
gefEditor
(
botEditor
.
getTitle
());
final
MainProcess
diagram
=
(
MainProcess
)
((
IGraphicalEditPart
)
gmfEditor
.
mainEditPart
().
part
()).
resolveSemanticElement
();
final
String
originalName
=
diagram
.
getName
();
bot
.
menu
(
"Diagram"
).
menu
(
"Rename..."
).
click
();
bot
.
waitUntil
(
Conditions
.
shellIsActive
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
openNameAndVersionDialogTitle
));
assertTrue
(
"OK should be enabled"
,
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
isEnabled
());
final
String
newName
=
originalName
+
" renamed"
+
System
.
currentTimeMillis
();
bot
.
textWithLabel
(
org
.
bonitasoft
.
studio
.
common
.
Messages
.
name
,
0
).
setText
(
newName
);
bot
.
button
(
IDialogConstants
.
OK_LABEL
).
click
();
assertEquals
(
newName
+
" (1.0)"
,
bot
.
activeEditor
().
getTitle
());
assertFalse
(
"Editor is dirty"
,
bot
.
activeEditor
().
isDirty
());
}
...
...
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