Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 138192
Collapse All | Expand All

(-)src/org/eclipse/draw2d/test/Draw2dTestSuite.java (+1 lines)
Lines 44-49 Link Here
44
	addTest(new TestSuite(PointListTests.class));
44
	addTest(new TestSuite(PointListTests.class));
45
    addTest(new TestSuite(PrecisionRectangleTest.class));
45
    addTest(new TestSuite(PrecisionRectangleTest.class));
46
    addTest(new TestSuite(ThumbnailTest.class));
46
    addTest(new TestSuite(ThumbnailTest.class));
47
    addTest(new TestSuite(FigureUtilitiesTest.class));
47
//    addTest(new TestSuite(ColorConstantTest.class));
48
//    addTest(new TestSuite(ColorConstantTest.class));
48
}
49
}
49
50
(-)src/org/eclipse/draw2d/test/FigureUtilitiesTest.java (+58 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.draw2d.test;
13
14
import junit.framework.TestCase;
15
16
import org.eclipse.draw2d.Figure;
17
import org.eclipse.draw2d.FigureUtilities;
18
import org.eclipse.draw2d.IFigure;
19
20
21
public class FigureUtilitiesTest  extends TestCase {
22
    /**
23
     * @see TestCase#setUp()
24
     */
25
    protected void setUp() throws Exception {
26
        super.setUp();
27
    }
28
29
    /**
30
     * @see TestCase#tearDown()
31
     */
32
    protected void tearDown() throws Exception {
33
        super.tearDown();
34
    }
35
    
36
    public void test_findCommonAncestor_happypath() {
37
        IFigure figureParent = new Figure();
38
        IFigure figureChild1 = new Figure();
39
        IFigure figureChild2 = new Figure();
40
        IFigure figureChild3 = new Figure();
41
        
42
        figureParent.add(figureChild1);
43
        figureChild1.add(figureChild2);
44
        figureParent.add(figureChild3);
45
        
46
        IFigure result = FigureUtilities.findCommonAncestor(figureChild2, figureChild3);
47
        assertTrue(figureParent == result);
48
    }
49
    
50
    public void test_findCommonAncestor_bugzilla130042() {
51
        IFigure figureParent = new Figure();
52
        IFigure figureChild = new Figure();
53
        figureParent.add(figureChild);
54
        
55
        IFigure result = FigureUtilities.findCommonAncestor(figureParent, figureChild);
56
        assertTrue(figureParent == result);
57
    }
58
}
(-)src/org/eclipse/draw2d/FigureUtilities.java (-10 / +11 lines)
Lines 398-413 Link Here
398
	}
398
	}
399
	if (left.isEmpty() || right.isEmpty())
399
	if (left.isEmpty() || right.isEmpty())
400
		return null;
400
		return null;
401
	int il = left.size() - 1;
401
    
402
	int ir = right.size() - 1;
402
    int il = left.size() - 1;
403
	while (left.get(il) == right.get(ir)) {
403
    int ir = right.size() - 1;
404
		il--;
404
    do {
405
		ir--;
405
        if (left.get(il) != right.get(ir))
406
	}
406
                break;
407
	++il;
407
        il--;
408
	if (il < left.size())
408
        ir--;           
409
		return (IFigure)left.get(il);
409
    } while (il >= 0 && ir >= 0);
410
	return null;
410
411
    return (IFigure) left.get(il + 1);
411
}
412
}
412
413
413
/**
414
/**

Return to bug 138192