Changeset 39029
- Timestamp:
- 2024-05-15T21:48:53+12:00 (4 weeks ago)
- Location:
- gs3-extensions/testing/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/testing/trunk/src/README
r39023 r39029 33 33 - https://junit.org/junit4/ (we appear to use junit4) 34 34 - there's also the older wiki page by Sam that has his own work (not yet incorporated): https://wiki.greenstone.org/doku.php?id=internal:gs3_automated_testing 35 36 Pages that are useful 37 - https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/exception/EdtViolationException.html 38 - VERY USEFUL BASICS: https://docs.oracle.com/javase/6/docs/api/javax/swing/package-summary.html#threading 39 - EDT and AssertJ Swing: https://joel-costigliola.github.io/assertj/assertj-swing-edt.html 35 40 36 41 ---------------------- … … 91 96 Reminder: to shift code into the Event Dispatch Thread/EDT, there's SwingUtilities.invokeLater(), which is asynchronous. To be synchronous (code that Must happen now because the code that follows is dependent on results/successful finish of the sequence of events being shifted into the EDT), use SwingUtilities.invokeAndWait() in a try/catch. 92 97 93 Pages that are useful94 - https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/exception/EdtViolationException.html95 - VERY USEFUL BASICS: https://docs.oracle.com/javase/6/docs/api/javax/swing/package-summary.html#threading96 98 97 99 -
gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java
r39025 r39029 86 86 87 87 private static Properties props; 88 // TODO: Do we ever expect tutorials to take more than a minute or 2 mins to build? 89 // And do we think a test can get stuck waiting for the entire time before it bails? 90 public static final int MAX_BUILD_TIMEOUT = 60; 88 91 89 92 // Changing Exit SecurityManager is now unused as GLI now doesn't System.exit in testing mode … … 235 238 //changeUserMode("librarian"); 236 239 //openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()); 237 238 // Start a new collection within the Librarian Interface: 239 /*createCollection("Small HTML Collection", 240 "A small collection of HTML pages.", 241 null); 242 */ 243 loadCollection("smallhtm"); // TODO 244 PAUSE(3); 245 246 String dragNodePath = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()+"simple_html/html_files", SELECT); 247 248 dragNDrop(dragNodePath, ""); 249 240 250 241 /* 251 242 loadCollection("lucene-jdbm-demo"); 252 243 // wait a couple of seconds for loading to be done 253 244 PAUSE(2); 254 openCollectionPath("b17mie/b17mie.htm", false);245 openCollectionPath("b17mie/b17mie.htm", CLICK); 255 246 PAUSE(3); 256 247 openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()); 257 248 258 249 */ 259 PAUSE(2); 250 251 // Start a new collection within the Librarian Interface: 252 createCollection("Small HTML Collection", 253 "A small collection of HTML pages.", 254 null); 255 256 //loadCollection("smallhtm"); // TODO 257 PAUSE(3); 258 259 260 String dragNodePath = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()+"simple_html/html_files", SELECT); 261 262 dragNDrop(dragNodePath, ""); 263 264 265 266 switchToPane(CREATE_PANE); 267 buildCollection(); 268 previewCollectionWhenReady(MAX_BUILD_TIMEOUT); 269 PAUSE(4); 260 270 } 261 271 -
gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java
r39025 r39029 9 9 import org.junit.Assert; 10 10 import org.assertj.swing.fixture.*; 11 import org.assertj.swing.timing.Timeout ; 12 11 import org.assertj.swing.timing.Timeout; 12 13 import org.assertj.swing.timing.Pause; 14 import org.assertj.swing.timing.Condition; 15 import java.util.concurrent.TimeUnit; 16 13 17 // GLI imports 14 18 import org.greenstone.gatherer.Gatherer; … … 82 86 83 87 /****************************** APPLICATION *******************************/ 88 //TODO 84 89 public static void PAUSE() { 85 90 PAUSE(5); 91 //Pause.pause(5, TimeUnit.SECONDS); 86 92 } 87 93 public static void PAUSE(int seconds) { 94 //if(!PAUSE_ON) return; // ignore calls to PAUSE 95 //Pause.pause(seconds, TimeUnit.SECONDS); 96 97 88 98 if(!PAUSE_ON) return; // ignore calls to PAUSE 89 90 99 // wait a couple of seconds again? 91 100 try{ … … 383 392 384 393 /********************** CREATE PANEL ********************/ 385 public static void buildOpenCollection() {} 386 public static void buildOpenCollection(boolean minimalRebuild) {} 394 public static JButtonFixture waitForPreviewReady(int maxWaitSeconds) { 395 return waitForPreviewReady(maxWaitSeconds, true); 396 } 397 public static JButtonFixture waitForPreviewReady(int maxWaitSeconds, boolean bailTestingOnBuildFailure) { 398 //while(!previewButton.isEnabled()) {} 399 400 JButtonFixture previewButtonTester = window.button("CreatePane.preview_button"); 401 javax.swing.JButton previewButton = previewButtonTester.target(); 402 Pause.pause(new Condition("Preview button to be enabled") { 403 public boolean test() { 404 return previewButton.isEnabled(); 405 } 406 407 }, Timeout.timeout(maxWaitSeconds, TimeUnit.SECONDS)); 408 409 if(bailTestingOnBuildFailure) { 410 JTextComponentFixture txtArea = window.textBox("CreatePane.log_textarea"); 411 //txtArea.requireText("************** Build Finished **************"); 412 //txtArea.requireText(java.util.regex.Pattern.compile("Build Finished|buildcol.pl> Command complete")); 413 //System.err.println("@@@@ text: " + txtArea.text()); 414 } 415 416 return previewButtonTester; 417 } 418 public static void buildCollection() { 419 window.button("CreatePane.build_button").click(); 420 } 421 public static void buildCollectionTillReady(int maxWaitSeconds) { 422 buildCollection(); 423 waitForPreviewReady(maxWaitSeconds); 424 } 425 public static void buildCollection(boolean minimalRebuild) { 426 if(minimalRebuild) { 427 // try with or without s in sincremental 428 window.button("CreatePane.sincremental_build_radio_button").click(); // JRadioButtonFixture 429 } else { 430 buildCollection(); 431 } 432 } 433 public static void previewCollection() { 434 window.button("CreatePane.preview_button").click(); 435 } 436 437 // Usage of AssertJ Swing Condition, and Pause on Condition 438 // https://gist.github.com/hashrock/26afb842db35eb03699acf735a692f2e 439 // https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/timing/Pause.html 440 // https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/timing/Condition.html 441 public static void previewCollectionWhenReady(int maxWaitSeconds) { 442 JButtonFixture preview = waitForPreviewReady(maxWaitSeconds); 443 preview.click(); 444 } 445 446 public static void buildAndPreviewCollection(int maxWaitForBuilding) { 447 buildCollection(); 448 //JButtonFixture preview = waitForPreviewReady(maxWaitSeconds); 449 //previewCollection(); 450 previewCollectionWhenReady(maxWaitForBuilding); 451 } 452 387 453 public static void configureImportOptions(Map params) {} 388 454 public static void configureBuildOptions(Map params) {} 389 455 390 public static void buildOutputContains(String ... n) {} 391 456 public static void buildOutputContains(String ... n) {} 457 392 458 /******************** GATHER PANE ********************/ 393 459 public static void createWorkspaceShortcut(){} … … 403 469 workspaceTree.drag(workspacePath); 404 470 if(collPath == null || collPath.equals("")) { 405 collTree.drop( "bla");471 collTree.drop(); // empty tree, call ancestor method AbstractComponentFixture.drop() 406 472 } else { 407 collTree.drop(collPath); 408 } 409 } 410 411 412 public static String openWorkspacePath(String topGLIFolder, String workspacePath, int leafNodeAction) { 473 collTree.drop(collPath); // call a JTreeFixture.drop() method 474 } 475 System.err.println("@@@ New collPath: " + collPath); 476 String newPath = workspacePath.substring(workspacePath.lastIndexOf("/")+1); 477 collPath = (collPath==null || collPath.equals("")) ? newPath : (collPath + "/" + newPath); 478 openCollectionPath(collPath, SELECT); 479 System.err.println("@@@ New collPath: " + collPath); 480 } 481 482 483 public static String openWorkspacePath(String topGLIFolder, String workspacePath, int mouseAction) { 413 484 if(workspacePath.startsWith("/")) { 414 485 workspacePath = workspacePath.substring(1); … … 449 520 wks_ptr = workspaceTree.expandPath(nodes[i]); 450 521 } else { // final node 451 switch(leafNodeAction) {522 /*switch(leafNodeAction) { 452 523 case EXPAND: 453 524 wks_ptr = workspaceTree.expandPath(nodes[i]); … … 468 539 System.err.println("GSGUITestingUtil.openWorkspacePath - unknown action " + leafNodeAction); 469 540 } 541 */ 542 wks_ptr = handleLeafNode(workspaceTree, nodes[i], mouseAction); 470 543 } 471 544 } … … 478 551 479 552 } 480 public static JTreeFixture openCollectionPath(String collPath, boolean openFile) { 553 554 public static JTreeFixture handleLeafNode(JTreeFixture tree, String node, int mouseAction){ 555 JTreeFixture tree_ptr = tree; 556 switch(mouseAction) { 557 case EXPAND: 558 tree_ptr = tree.expandPath(node); 559 break; 560 case CLICK: 561 tree_ptr = tree.clickPath(node); 562 break; 563 case DOUBLE_CLICK: 564 tree_ptr = tree.doubleClickPath(node); 565 break; 566 case SELECT: 567 tree_ptr = tree.doubleClickPath(node); 568 break; 569 case RIGHT_CLICK: 570 tree_ptr = tree.rightClickPath(node); 571 break; 572 default: 573 System.err.println("GSGUITestingUtil.handleLeafNode - unknown action " + mouseAction); 574 } 575 return tree_ptr; 576 } 577 578 public static JTreeFixture openCollectionPath(String collPath, int mouseAction) { 481 579 /* 482 580 JTreeFixture tree = window.tree(); … … 509 607 510 608 System.err.println("\t" + nodes[i]); 511 609 if(i < nodes.length) { 610 collTree = collTree.expandPath(nodes[i]); 611 } else { 612 collTree = handleLeafNode(collTree, nodes[i], mouseAction); 613 } 614 /* 512 615 if(i == (nodes.length-1) && !openFile) { 513 616 collTree = collTree.clickPath(nodes[i]); … … 517 620 // which can open it in browser. This may not be what we want. 518 621 } 622 */ 519 623 520 624 }
Note:
See TracChangeset
for help on using the changeset viewer.