11package at .asit .pdfover .gui .demo ;
22
3+ import at .asit .pdfover .commons .Messages ;
4+ import at .asit .pdfover .gui .Main ;
35import at .asit .pdfover .gui .demo .SignWidget ;
6+ import at .asit .pdfover .gui .tests .FileExistsCondition ;
7+ import at .asit .pdfover .gui .tests .WidgetExistsCondition ;
8+ import at .asit .pdfover .gui .workflow .StateMachine ;
49import org .eclipse .swt .layout .FillLayout ;
510import org .eclipse .swt .widgets .Display ;
611import org .eclipse .swt .widgets .Shell ;
712import org .eclipse .swtbot .swt .finder .SWTBot ;
13+ import org .eclipse .swtbot .swt .finder .exceptions .WidgetNotFoundException ;
814import org .eclipse .swtbot .swt .finder .waits .DefaultCondition ;
15+ import org .eclipse .swtbot .swt .finder .waits .ICondition ;
916import org .junit .After ;
1017import org .junit .Before ;
1118import org .junit .Test ;
1219
20+ import java .io .File ;
21+
1322import static org .junit .Assert .assertEquals ;
23+ import static org .junit .jupiter .api .Assertions .assertTrue ;
24+ import static org .junit .jupiter .api .Assertions .fail ;
1425
1526public class SignWidgetSWTBotTest {
1627 private Shell shell ;
1728 private SWTBot bot ;
1829 private SignWidget widget ;
30+ private StateMachine sm ;
31+ private static final File inputFile = new File ("src/test/resources/TestFile.pdf" );
32+ protected String str (String k ) { return Messages .getString (k ); }
1933
2034 @ Before
2135 public void setUp () {
2236 Display display = Display .getDefault ();
23- shell = new Shell (display );
24- shell .setLayout (new FillLayout ());
25- widget = new SignWidget (shell );
26- shell .setSize (400 , 200 );
27- shell .open ();
37+ sm = Main .setup (new String []{inputFile .getAbsolutePath ()});
38+ shell = sm .getMainShell ();
39+ sm .start ();
2840 bot = new SWTBot (shell );
2941 }
3042
@@ -40,4 +52,20 @@ public void transitionsToSuccess() throws Exception {
4052 }, 10000 );
4153 assertEquals ("SUCCESS" , widget .statusText ());
4254 }
55+
56+ @ Test
57+ public void setCredentials () {
58+ try {
59+ ICondition widgetExists = new WidgetExistsCondition (str ("mobileBKU.number" ));
60+ bot .waitUntil (widgetExists , 50000 );
61+ bot .textWithLabel (str ("mobileBKU.number" )).setText ("TestUser-1902503362" );
62+ bot .textWithLabel (str ("mobileBKU.password" )).setText ("123456789" );
63+ bot .button (str ("common.Ok" )).click ();
64+ }
65+ catch (WidgetNotFoundException wnf ) {
66+ bot .button (str ("common.Cancel" )).click ();
67+ fail (wnf .getMessage ());
68+ }
69+
70+ }
4371}
0 commit comments