You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InteractiveBrowserTest.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.tools.ajbrowser;
  14. import java.io.File;
  15. import javax.swing.*;
  16. import junit.framework.*;
  17. //import org.aspectj.asm.*;
  18. import org.aspectj.bridge.*;
  19. import org.aspectj.bridge.IMessage;
  20. import org.aspectj.ajde.*;
  21. /**
  22. * Define system property "ajbrowser.interactive" to run.
  23. * @author Mik Kersten
  24. */
  25. public class InteractiveBrowserTest extends TestCase {
  26. static boolean interactive() {
  27. return (null != System.getProperty("ajbrowser.interactive"));
  28. }
  29. public InteractiveBrowserTest(String name) {
  30. super(name);
  31. }
  32. public static TestSuite suite() {
  33. TestSuite result = new TestSuite();
  34. result.addTestSuite(InteractiveBrowserTest.class);
  35. return result;
  36. }
  37. public void testInitNoArgs() {
  38. //String[] args = { "C:/Dev/aspectj/modules/ajde/testdata/examples/figures-coverage/all.lst" };
  39. String[] args = { };
  40. BrowserManager.getDefault().init(args, true);
  41. }
  42. public void testAddProjectTask() {
  43. if (!interactive()) {
  44. return;
  45. }
  46. BrowserManager.getDefault().init(new String[]{}, true);
  47. Ajde.getDefault().getTaskListManager().addProjectTask(
  48. "project-level task",
  49. IMessage.ERROR);
  50. BrowserManager.getDefault().showMessages();
  51. assertTrue("confirmation result", verifySuccess("Project task is visible."));
  52. }
  53. public void testAddSourceLineTasks() {
  54. if (!interactive()) {
  55. return;
  56. }
  57. BrowserManager.getDefault().init(new String[]{}, true);
  58. ISourceLocation dummyLocation = new SourceLocation(new File("<file>"), 0, 0);
  59. Ajde.getDefault().getTaskListManager().addSourcelineTask(
  60. "error task",
  61. dummyLocation,
  62. IMessage.ERROR);
  63. Ajde.getDefault().getTaskListManager().addSourcelineTask(
  64. "warning task",
  65. dummyLocation,
  66. IMessage.WARNING);
  67. Ajde.getDefault().getTaskListManager().addSourcelineTask(
  68. "info task",
  69. dummyLocation,
  70. IMessage.INFO);
  71. BrowserManager.getDefault().showMessages();
  72. assertTrue("confirmation result", verifySuccess("3 kinds of sourceline tasks are visible."));
  73. }
  74. private boolean verifySuccess(String message) {
  75. int result = JOptionPane.showConfirmDialog(
  76. BrowserManager.getDefault().getRootFrame(),
  77. "Verify Results",
  78. message,
  79. JOptionPane.YES_NO_OPTION);
  80. return result == JOptionPane.YES_OPTION;
  81. }
  82. protected void setUp() throws Exception {
  83. super.setUp();
  84. }
  85. protected void tearDown() throws Exception {
  86. super.tearDown();
  87. }
  88. }