|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2006, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2006, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 10-15
Link Here
|
| 10 |
* Stefan Xenos - bug 174539 - add a 1-argument convert(...) method |
10 |
* Stefan Xenos - bug 174539 - add a 1-argument convert(...) method |
| 11 |
* Stefan Xenos - bug 174040 - SubMonitor#convert doesn't always set task name |
11 |
* Stefan Xenos - bug 174040 - SubMonitor#convert doesn't always set task name |
| 12 |
* Stefan Xenos - bug 206942 - Regression test for infinite progress reporting rate |
12 |
* Stefan Xenos - bug 206942 - Regression test for infinite progress reporting rate |
|
|
13 |
* IBM Corporation - bug 252446 - SubMonitor.newChild passes zero ticks to child |
| 13 |
*******************************************************************************/ |
14 |
*******************************************************************************/ |
| 14 |
package org.eclipse.core.tests.runtime; |
15 |
package org.eclipse.core.tests.runtime; |
| 15 |
|
16 |
|
|
Lines 793-798
Link Here
|
| 793 |
} |
794 |
} |
| 794 |
|
795 |
|
| 795 |
/** |
796 |
/** |
|
|
797 |
* Tests reporting of progress by sub-monitors created via newChild() |
| 798 |
*/ |
| 799 |
public void testBug252446() { |
| 800 |
int children = 12; |
| 801 |
int cyclesPerChild = 17; |
| 802 |
|
| 803 |
TestProgressMonitor monitor = new TestProgressMonitor(); |
| 804 |
SubMonitor progress = SubMonitor.convert(monitor, children * cyclesPerChild); |
| 805 |
|
| 806 |
// At this time monitor.getExpectedWork() == SubMonitor.MINIMUM_RESOLUTION == 1000 |
| 807 |
double expectedTicksPerIteration = (double) monitor.getExpectedWork() / children / cyclesPerChild; |
| 808 |
|
| 809 |
for (int i = 0; i < children; i++) { |
| 810 |
IProgressMonitor mon = progress.newChild(cyclesPerChild); |
| 811 |
for (int j = 1; j <= cyclesPerChild; j++) { |
| 812 |
mon.worked(1); |
| 813 |
double expectedTopMonitorWork = expectedTicksPerIteration * (i * cyclesPerChild + j); |
| 814 |
// Progress is passed to the parent monitor as integer leading to rounding |
| 815 |
// errors. The parent's progress has to follow child's progress "close enough" |
| 816 |
// and then it will catch up when next child is created. Hence, a relatively large delta |
| 817 |
// value in this check: |
| 818 |
assertEquals(expectedTopMonitorWork, monitor.getTotalWork(), 2.0d); |
| 819 |
} |
| 820 |
} |
| 821 |
monitor.done(); |
| 822 |
monitor.assertOptimal(); |
| 823 |
} |
| 824 |
|
| 825 |
/** |
| 796 |
* Creates and destroys the given number of child progress monitors under the given parent. |
826 |
* Creates and destroys the given number of child progress monitors under the given parent. |
| 797 |
* |
827 |
* |
| 798 |
* @param monitor monitor to create children under. The caller must call done on this monitor |
828 |
* @param monitor monitor to create children under. The caller must call done on this monitor |