コード例 #1
0
  /** Test SubProgressMonitor's created with negative a work value. */
  public void testNegativeWorkValues() {
    TestProgressMonitor top = new TestProgressMonitor();
    top.beginTask("", 10);

    SubProgressMonitor childMonitor = new SubProgressMonitor(top, IProgressMonitor.UNKNOWN); // -1
    childMonitor.beginTask("", 10);
    childMonitor.worked(5);
    Assert.assertEquals(0.0, top.getTotalWork(), 0.01d);
    childMonitor.done();
    Assert.assertEquals(0.0, top.getTotalWork(), 0.01d);

    top.done();
  }
コード例 #2
0
  /**
   * Test behaviors that subclasses of SubProgressMonitor will expect from their base class.
   *
   * @deprecated to suppress deprecation warnings
   */
  public void testCustomSubclass() {
    TestProgressMonitor top = new TestProgressMonitor();
    top.beginTask("", 1000);

    SubProgressSubclass customSubclass = new SubProgressSubclass(top, 1000);
    customSubclass.beginTask("", 10000);

    for (int count = 0; count < 10000; count++) customSubclass.worked(1);

    Assert.assertEquals(
        "If there is a custom subclass of SubProgressMonitor, all calls to worked() should delegate to internalWorked",
        10000,
        customSubclass.internalWorkedCalls);
    customSubclass.done();
    top.done();
  }