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 107753 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java (+1 lines)
Lines 28-33 Link Here
28
	 */
28
	 */
29
	public DecoratorsTestSuite() {
29
	public DecoratorsTestSuite() {
30
		addTest(new TestSuite(ExceptionDecoratorTestCase.class));
30
		addTest(new TestSuite(ExceptionDecoratorTestCase.class));
31
		addTest(new TestSuite(ExceptionDecoratorErrorHandlingTest.class));
31
		addTest(new TestSuite(DecoratorTestCase.class));
32
		addTest(new TestSuite(DecoratorTestCase.class));
32
		addTest(new TestSuite(LightweightDecoratorTestCase.class));
33
		addTest(new TestSuite(LightweightDecoratorTestCase.class));
33
		addTest(new TestSuite(BadIndexDecoratorTestCase.class));
34
		addTest(new TestSuite(BadIndexDecoratorTestCase.class));
(-)Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java (+3 lines)
Lines 142-147 Link Here
142
	
142
	
143
	public static Table getTable(){
143
	public static Table getTable(){
144
		Composite c = getListAreaComposite();
144
		Composite c = getListAreaComposite();
145
		if(c == null){
146
			return null;
147
		}
145
		if(c.getChildren().length == 0){
148
		if(c.getChildren().length == 0){
146
			return null;
149
			return null;
147
		}
150
		}
(-)Eclipse (+135 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 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
package org.eclipse.ui.tests.decorators;
12
13
import java.util.ArrayList;
14
import java.util.Collection;
15
16
import org.eclipse.core.runtime.OperationCanceledException;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.jface.dialogs.ErrorDialog;
19
import org.eclipse.jface.viewers.ILabelProviderListener;
20
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
21
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.internal.WorkbenchMessages;
24
import org.eclipse.ui.internal.WorkbenchPlugin;
25
import org.eclipse.ui.internal.decorators.DecoratorDefinition;
26
import org.eclipse.ui.internal.decorators.DecoratorManager;
27
import org.eclipse.ui.tests.navigator.AbstractNavigatorTest;
28
import org.eclipse.ui.tests.statushandlers.StatusDialogUtil;
29
30
/**
31
 * @version 	1.0
32
 */
33
public class ExceptionDecoratorErrorHandlingTest extends AbstractNavigatorTest
34
        implements ILabelProviderListener {
35
	
36
	protected DecoratorDefinition definition;
37
38
	protected boolean updated = false;
39
    
40
    private Collection problemDecorators = new ArrayList();
41
42
    private DecoratorDefinition light;
43
44
    /**
45
     * Constructor for DecoratorTestCase.
46
     * @param testName
47
     */
48
    public ExceptionDecoratorErrorHandlingTest(String testName) {
49
        super(testName);
50
    }
51
52
    /**
53
     * Sets up the hierarchy.
54
     */
55
    protected void doSetUp() throws Exception {
56
    	ErrorDialog.AUTOMATED_MODE = false;
57
    	super.doSetUp();
58
        createTestFile();
59
        showNav();
60
61
        WorkbenchPlugin.getDefault().getDecoratorManager().addListener(this);
62
63
        //reset the static fields so that the decorators will fail
64
        HeavyNullImageDecorator.fail = true;
65
        HeavyNullTextDecorator.fail = true;
66
        NullImageDecorator.fail = true;
67
        DecoratorDefinition[] definitions = WorkbenchPlugin.getDefault()
68
                .getDecoratorManager().getAllDecoratorDefinitions();
69
        for (int i = 0; i < definitions.length; i++) {
70
            String id = definitions[i].getId();
71
            if (id.equals("org.eclipse.ui.tests.heavyNullImageDecorator")
72
                    || id.equals("org.eclipse.ui.tests.heavyNullTextDecorator")) {
73
                definitions[i].setEnabled(true);
74
                problemDecorators.add(definitions[i]);
75
            }
76
77
            //Do not cache the light one - the disabling issues
78
            //still need to be worked out.
79
            if (id.equals("org.eclipse.ui.tests.lightNullImageDecorator")) {
80
                definitions[i].setEnabled(true);
81
                light = definitions[i];
82
            }
83
        }
84
    } /* (non-Javadoc)
85
     * @see org.eclipse.ui.tests.navigator.LightweightDecoratorTestCase#doTearDown()
86
     */
87
88
    protected void doTearDown() throws Exception {
89
        super.doTearDown();
90
        ErrorDialog.AUTOMATED_MODE = true;
91
        if(StatusDialogUtil.getStatusShell() == null){
92
        	StatusDialogUtil.getStatusShell().dispose();
93
        }
94
    }
95
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.jface.viewers.ILabelProviderListener#labelProviderChanged(org.eclipse.jface.viewers.LabelProviderChangedEvent)
98
	 */
99
	public void labelProviderChanged(
100
		LabelProviderChangedEvent event) {
101
		updated = true;
102
103
	}
104
105
	public void testStatusHandlingDialog() {
106
		// Need to wait for decoration to end to allow for all
107
		// errors to occur
108
		try {
109
			Job.getJobManager().join(DecoratorManager.FAMILY_DECORATE, null);
110
		} catch (OperationCanceledException e) {
111
		} catch (InterruptedException e) {
112
		}
113
		int count1 = 50;
114
		while(StatusDialogUtil.getStatusShell() == null && count1-- != 0){
115
			Display.getDefault().readAndDispatch();
116
			Thread.yield();
117
		}
118
		// be sure that dialog was displayed
119
		assertTrue(count1 > 0);
120
		
121
		int count2 = 50;
122
		while (StatusDialogUtil.getTable() == null && count2-- != 0) {
123
			Display.getDefault().readAndDispatch();
124
			Thread.yield();
125
		}
126
		// be sure that more than one status was reported
127
		assertTrue(count2 > 0);
128
		String message = StatusDialogUtil.getTable().getItem(0).getText();
129
		String pattern = WorkbenchMessages.DecoratorError + " "
130
				+ NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, ".*");
131
		assertTrue(message.matches(pattern));
132
		// Turnoff the lightweight one so as not to clutter the methods.
133
		light.setEnabled(false);
134
	}
135
}

Return to bug 107753