Add more warnings source to 1.6) and fix warnings
[nikiroo-utils.git] / src / be / nikiroo / utils / test / ProgressTest.java
index be8b46a0103ac2d9b6741d2d3741b40a55362951..bd05bc5b4dbf2d6fb6cf9c4ca17735aa0fc0ef4d 100644 (file)
@@ -38,6 +38,7 @@ class ProgressTest extends TestLauncher {
                                        public void test() throws Exception {
                                                Progress p = new Progress();
                                                p.addProgressListener(new Progress.ProgressListener() {
+                                                       @Override
                                                        public void progress(Progress progress, String name) {
                                                                pg = progress.getProgress();
                                                        }
@@ -102,6 +103,7 @@ class ProgressTest extends TestLauncher {
                                                p.addProgress(child2, 50);
 
                                                p.addProgressListener(new Progress.ProgressListener() {
+                                                       @Override
                                                        public void progress(Progress progress, String name) {
                                                                pg = p.getProgress();
                                                        }
@@ -132,6 +134,7 @@ class ProgressTest extends TestLauncher {
                                                p.addProgress(child2, 500);
 
                                                p.addProgressListener(new Progress.ProgressListener() {
+                                                       @Override
                                                        public void progress(Progress progress, String name) {
                                                                pg = p.getProgress();
                                                        }
@@ -164,6 +167,7 @@ class ProgressTest extends TestLauncher {
                                                // 200 = local progress
 
                                                p.addProgressListener(new Progress.ProgressListener() {
+                                                       @Override
                                                        public void progress(Progress progress, String name) {
                                                                pg = p.getProgress();
                                                        }
@@ -182,6 +186,55 @@ class ProgressTest extends TestLauncher {
                                        }
                                });
 
+                               addTest(new TestCase("Listeners with 5+ children, 4+ depth") {
+                                       int pg;
+
+                                       @Override
+                                       public void test() throws Exception {
+                                               final Progress p = new Progress();
+                                               Progress child1 = new Progress();
+                                               Progress child2 = new Progress();
+                                               p.addProgress(child1, 50);
+                                               p.addProgress(child2, 50);
+                                               Progress child11 = new Progress();
+                                               child1.addProgress(child11, 100);
+                                               Progress child111 = new Progress();
+                                               child11.addProgress(child111, 100);
+                                               Progress child1111 = new Progress();
+                                               child111.addProgress(child1111, 20);
+                                               Progress child1112 = new Progress();
+                                               child111.addProgress(child1112, 20);
+                                               Progress child1113 = new Progress();
+                                               child111.addProgress(child1113, 20);
+                                               Progress child1114 = new Progress();
+                                               child111.addProgress(child1114, 20);
+                                               Progress child1115 = new Progress();
+                                               child111.addProgress(child1115, 20);
+
+                                               p.addProgressListener(new Progress.ProgressListener() {
+                                                       @Override
+                                                       public void progress(Progress progress, String name) {
+                                                               pg = p.getProgress();
+                                                       }
+                                               });
+
+                                               child1111.setProgress(100);
+                                               child1112.setProgress(50);
+                                               child1113.setProgress(25);
+                                               child1114.setProgress(25);
+                                               child1115.setProgress(50);
+                                               assertEquals(25, pg);
+                                               child2.setProgress(100);
+                                               assertEquals(75, pg);
+                                               child1111.setProgress(100);
+                                               child1112.setProgress(100);
+                                               child1113.setProgress(100);
+                                               child1114.setProgress(100);
+                                               child1115.setProgress(100);
+                                               assertEquals(100, pg);
+                                       }
+                               });
+
                                addTest(new TestCase("Listeners with children, multi-thread") {
                                        int pg;
                                        boolean decrease;
@@ -200,6 +253,7 @@ class ProgressTest extends TestLauncher {
                                                p.addProgress(child2, 100);
 
                                                p.addProgressListener(new Progress.ProgressListener() {
+                                                       @Override
                                                        public void progress(Progress progress, String name) {
                                                                int now = p.getProgress();
                                                                if (now < pg) {
@@ -214,6 +268,7 @@ class ProgressTest extends TestLauncher {
                                                for (int i = 0; i <= 100; i++) {
                                                        final int step = i;
                                                        new Thread(new Runnable() {
+                                                               @Override
                                                                public void run() {
                                                                        synchronized (lock1) {
                                                                                if (step > currentStep1) {
@@ -225,6 +280,7 @@ class ProgressTest extends TestLauncher {
                                                        }).start();
 
                                                        new Thread(new Runnable() {
+                                                               @Override
                                                                public void run() {
                                                                        synchronized (lock2) {
                                                                                if (step > currentStep2) {