Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 120084 Details for
Bug 252446
SubMonitor.newChild passes zero ticks to child
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch with a JUnit test
patch SubMonitor.txt (text/plain), 5.80 KB, created by
Oleg Besedin
on 2008-12-10 12:51:10 EST
(
hide
)
Description:
Patch with a JUnit test
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2008-12-10 12:51:10 EST
Size:
5.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.runtime >Index: src/org/eclipse/core/tests/runtime/TestProgressMonitor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/TestProgressMonitor.java,v >retrieving revision 1.2 >diff -u -r1.2 TestProgressMonitor.java >--- src/org/eclipse/core/tests/runtime/TestProgressMonitor.java 8 Mar 2007 16:30:09 -0000 1.2 >+++ src/org/eclipse/core/tests/runtime/TestProgressMonitor.java 10 Dec 2008 17:47:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -254,6 +254,10 @@ > totalWork += work; > } > >+ public int getExpectedWork() { >+ return expectedWork; >+ } >+ > /** > * <p>Asserts that the progress reported on this monitor was optimal. That is, > * there were no redundant method calls, and progress was reported in between >Index: src/org/eclipse/core/tests/runtime/SubMonitorTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/SubMonitorTest.java,v >retrieving revision 1.8 >diff -u -r1.8 SubMonitorTest.java >--- src/org/eclipse/core/tests/runtime/SubMonitorTest.java 9 Dec 2008 15:30:45 -0000 1.8 >+++ src/org/eclipse/core/tests/runtime/SubMonitorTest.java 10 Dec 2008 17:47:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,7 @@ > * Stefan Xenos - bug 174539 - add a 1-argument convert(...) method > * Stefan Xenos - bug 174040 - SubMonitor#convert doesn't always set task name > * Stefan Xenos - bug 206942 - Regression test for infinite progress reporting rate >+ * IBM Corporation - bug 252446 - SubMonitor.newChild passes zero ticks to child > *******************************************************************************/ > package org.eclipse.core.tests.runtime; > >@@ -793,6 +794,35 @@ > } > > /** >+ * Tests reporting of progress by sub-monitors created via newChild() >+ */ >+ public void testBug252446() { >+ int children = 12; >+ int cyclesPerChild = 17; >+ >+ TestProgressMonitor monitor = new TestProgressMonitor(); >+ SubMonitor progress = SubMonitor.convert(monitor, children * cyclesPerChild); >+ >+ // At this time monitor.getExpectedWork() == SubMonitor.MINIMUM_RESOLUTION == 1000 >+ double expectedTicksPerIteration = (double) monitor.getExpectedWork() / children / cyclesPerChild; >+ >+ for (int i = 0; i < children; i++) { >+ IProgressMonitor mon = progress.newChild(cyclesPerChild); >+ for (int j = 1; j <= cyclesPerChild; j++) { >+ mon.worked(1); >+ double expectedTopMonitorWork = expectedTicksPerIteration * (i * cyclesPerChild + j); >+ // Progress is passed to the parent monitor as integer leading to rounding >+ // errors. The parent's progress has to follow child's progress "close enough" >+ // and then it will catch up when next child is created. Hence, a relatively large delta >+ // value in this check: >+ assertEquals(expectedTopMonitorWork, monitor.getTotalWork(), 2.0d); >+ } >+ } >+ monitor.done(); >+ monitor.assertOptimal(); >+ } >+ >+ /** > * Creates and destroys the given number of child progress monitors under the given parent. > * > * @param monitor monitor to create children under. The caller must call done on this monitor >#P org.eclipse.equinox.common >Index: src/org/eclipse/core/runtime/SubMonitor.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/components/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java,v >retrieving revision 1.8 >diff -u -r1.8 SubMonitor.java >--- src/org/eclipse/core/runtime/SubMonitor.java 9 Dec 2008 15:02:58 -0000 1.8 >+++ src/org/eclipse/core/runtime/SubMonitor.java 10 Dec 2008 17:47:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,7 @@ > * Stefan Xenos - bug 174539 - add a 1-argument convert(...) method > * Stefan Xenos - bug 174040 - SubMonitor#convert doesn't always set task name > * Stefan Xenos - bug 206942 - updated javadoc to recommend better constants for infinite progress >+ * IBM Corporation - bug 252446 - SubMonitor.newChild passes zero ticks to child > *******************************************************************************/ > package org.eclipse.core.runtime; > >@@ -743,7 +744,7 @@ > // is no method on the child that would delegate to beginTask on the parent. > childFlags |= suppressFlags; > >- SubMonitor result = new SubMonitor(root, consume(totalWorkDouble), 0, childFlags); >+ SubMonitor result = new SubMonitor(root, consume(totalWorkDouble), (int) totalWorkDouble, childFlags); > lastSubMonitor = result; > return result; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 252446
:
119846
|
119985
| 120084