View | Details | Raw Unified | Return to bug 86221
Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java (+2 lines)
Lines 40-45 Link Here
40
import org.eclipse.ui.tests.operations.OperationsTestSuite;
40
import org.eclipse.ui.tests.operations.OperationsTestSuite;
41
import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
41
import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
42
import org.eclipse.ui.tests.presentations.PresentationsTestSuite;
42
import org.eclipse.ui.tests.presentations.PresentationsTestSuite;
43
import org.eclipse.ui.tests.progress.ProgressTestSuite;
43
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
44
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
44
import org.eclipse.ui.tests.quickaccess.QuickAccessTestSuite;
45
import org.eclipse.ui.tests.quickaccess.QuickAccessTestSuite;
45
import org.eclipse.ui.tests.services.ServicesTestSuite;
46
import org.eclipse.ui.tests.services.ServicesTestSuite;
Lines 91-96 Link Here
91
        addTest(new MenusTestSuite());
92
        addTest(new MenusTestSuite());
92
        addTest(new EncodingTestSuite());
93
        addTest(new EncodingTestSuite());
93
        addTest(new PresentationsTestSuite());
94
        addTest(new PresentationsTestSuite());
95
        addTest(new ProgressTestSuite());
94
        addTest(new TestSuite(LeakTests.class));
96
        addTest(new TestSuite(LeakTests.class));
95
        addTest(new ConcurrencyTestSuite());
97
        addTest(new ConcurrencyTestSuite());
96
        addTest(new OperationsTestSuite());
98
        addTest(new OperationsTestSuite());
(-)Eclipse (+160 lines)
Added Link Here
1
/******************************************************************************
2
 * Copyright (c) 2008 Versant 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
 *     Remy Chi Jian Suen (Versant Corporation) - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.ui.tests.progress;
12
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CTabFolder;
17
import org.eclipse.swt.custom.CTabItem;
18
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.FontData;
20
import org.eclipse.ui.IEditorPart;
21
import org.eclipse.ui.IViewPart;
22
import org.eclipse.ui.IWorkbenchPage;
23
import org.eclipse.ui.PartInitException;
24
import org.eclipse.ui.ide.IDE;
25
import org.eclipse.ui.internal.EditorSashContainer;
26
import org.eclipse.ui.internal.ViewPane;
27
import org.eclipse.ui.internal.WorkbenchPage;
28
import org.eclipse.ui.internal.WorkbenchPlugin;
29
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
30
import org.eclipse.ui.tests.api.MockViewPart;
31
import org.eclipse.ui.tests.harness.util.FileUtil;
32
import org.eclipse.ui.tests.harness.util.UITestCase;
33
34
public class IWorkbenchSiteProgressServiceTest extends UITestCase {
35
36
	private IWorkbenchPage activePage;
37
38
	private IProject project;
39
40
	public IWorkbenchSiteProgressServiceTest(String testName) {
41
		super(testName);
42
	}
43
44
	protected void doSetUp() throws Exception {
45
		super.doSetUp();
46
		activePage = openTestWindow().getActivePage();
47
	}
48
49
	protected void doTearDown() throws Exception {
50
		if (project != null) {
51
			FileUtil.deleteProject(project);
52
		}
53
		super.doTearDown();
54
	}
55
56
	public void testWarnOfContentChangeForViews() throws CoreException,
57
			PartInitException {
58
		activePage.setPerspective(WorkbenchPlugin.getDefault()
59
				.getPerspectiveRegistry().findPerspectiveWithId(
60
						"org.eclipse.ui.tests.api.ViewPerspective"));
61
62
		// show one view and activate it
63
		IViewPart hiddenView = activePage.showView(MockViewPart.ID, null,
64
				IWorkbenchPage.VIEW_ACTIVATE);
65
		// show the second view and activate it,
66
		IViewPart activeView = activePage.showView(MockViewPart.ID2, null,
67
				IWorkbenchPage.VIEW_ACTIVATE);
68
69
		assertFalse(
70
				"Another view that was activated should have prevented this view from being visible", //$NON-NLS-1$
71
				activePage.isPartVisible(hiddenView));
72
		assertTrue("View was shown and activate but appears to not be visible", //$NON-NLS-1$
73
				activePage.isPartVisible(activeView));
74
75
		// retrieve the IWorkbenchSiteProgressService from the first view
76
		// that's behind in the view stack
77
		IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) hiddenView
78
				.getSite().getService(IWorkbenchSiteProgressService.class);
79
		assertNotNull(
80
				"Could not retrieve an IWorkbenchSiteProgressService from getService(Class)", //$NON-NLS-1$
81
				service);
82
83
		// warn of content change
84
		service.warnOfContentChange();
85
86
		WorkbenchPage page = (WorkbenchPage) activePage;
87
		// find the view pane for our test view, our first one and the one
88
		// that should be hidden
89
		ViewPane pane = (ViewPane) page.getPerspectivePresentation().findPart(
90
				MockViewPart.ID, null);
91
		assertNotNull("Could not find the ViewPane for " + MockViewPart.ID, //$NON-NLS-1$
92
				pane);
93
94
		// retrieve the SWT CTabFolder
95
		CTabFolder tabFolder = (CTabFolder) pane.getStack().getControl();
96
		// index is 0 because 1 is the one that's activated and in front, our
97
		// hidden view is 0 and is behind it
98
		CTabItem item = tabFolder.getItem(0);
99
100
		// get the CTabItem's font
101
		Font font = item.getFont();
102
		FontData[] data = font.getFontData();
103
		// check that it's been bolded, have discussed with SWT and we only need
104
		// to check the first FontData because if the first one is not bolded,
105
		// then the rest of the FontData (if any) in the array will also not be
106
		// bolded
107
		assertTrue("Font does not have a bold style", //$NON-NLS-1$
108
				(data[0].getStyle() & SWT.BOLD) == SWT.BOLD);
109
	}
110
111
	public void testWarnOfContentChangeForEditors() throws CoreException,
112
			PartInitException {
113
		project = FileUtil.createProject("testWarnOfContentPage");
114
115
		// open two editors
116
		IEditorPart hiddenEditor = IDE.openEditor(activePage, FileUtil
117
				.createFile("a.mock1", project), true);
118
		IEditorPart visibleEditor = IDE.openEditor(activePage, FileUtil
119
				.createFile("b.mock1", project), true);
120
121
		// first one shouldn't be visible since we opened a second one
122
		assertFalse("Editor is visible when another editor has been activated", //$NON-NLS-1$
123
				activePage.isPartVisible(hiddenEditor));
124
		// the second one should be visible
125
		assertTrue("Editor is not visible when it was activated", activePage //$NON-NLS-1$
126
				.isPartVisible(visibleEditor));
127
128
		// retrive an IWorkbenchSiteProgressService from the first editor that
129
		// is behind in the editor stack
130
		IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) hiddenEditor
131
				.getSite().getService(IWorkbenchSiteProgressService.class);
132
		assertNotNull(
133
				"Could not retrieve an IWorkbenchSiteProgressService from getService(Class)",
134
				service);
135
136
		// warn of content change
137
		service.warnOfContentChange();
138
139
		WorkbenchPage page = (WorkbenchPage) activePage;
140
		EditorSashContainer container = (EditorSashContainer) page
141
				.getEditorPresentation().getLayoutPart();
142
		// retrieve the SWT CTabFolder
143
		CTabFolder tabFolder = (CTabFolder) container.getActiveWorkbook()
144
				.getControl();
145
		// index is 0 since we want the editor that's behind in the editor
146
		// stack, 1 should be the second one that we activated
147
		CTabItem item = tabFolder.getItem(0);
148
149
		// get the CTabItem's font
150
		Font font = item.getFont();
151
		FontData[] data = font.getFontData();
152
		// check that it's been bolded, have discussed with SWT and we only need
153
		// to check the first FontData because if the first one is not bolded,
154
		// then the rest of the FontData (if any) in the array will also not be
155
		// bolded
156
		assertTrue("Font does not have a bold style", //$NON-NLS-1$
157
				(data[0].getStyle() & SWT.BOLD) == SWT.BOLD);
158
	}
159
160
}
(-)Eclipse (+25 lines)
Added Link Here
1
/******************************************************************************
2
 * Copyright (c) 2008 Versant 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
 *     Remy Chi Jian Suen (Versant Corporation) - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.ui.tests.progress;
12
13
import junit.framework.Test;
14
import junit.framework.TestSuite;
15
16
public final class ProgressTestSuite extends TestSuite {
17
18
	public static final Test suite() {
19
		return new ProgressTestSuite();
20
	}
21
22
	public ProgressTestSuite() {
23
		addTest(new TestSuite(IWorkbenchSiteProgressServiceTest.class));
24
	}
25
}
(-)Eclipse UI/org/eclipse/ui/internal/EditorPane.java (-1 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen (Versant Corporation) - bug 86221
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.internal;
12
package org.eclipse.ui.internal;
12
13
Lines 22-27 Link Here
22
import org.eclipse.ui.IWorkbenchPart;
23
import org.eclipse.ui.IWorkbenchPart;
23
import org.eclipse.ui.internal.tweaklets.TabBehaviour;
24
import org.eclipse.ui.internal.tweaklets.TabBehaviour;
24
import org.eclipse.ui.internal.tweaklets.Tweaklets;
25
import org.eclipse.ui.internal.tweaklets.Tweaklets;
26
import org.eclipse.ui.presentations.IPresentablePart;
25
import org.eclipse.ui.presentations.StackPresentation;
27
import org.eclipse.ui.presentations.StackPresentation;
26
28
27
/**
29
/**
Lines 215-219 Link Here
215
    public boolean isCloseable() {
217
    public boolean isCloseable() {
216
        return true;
218
        return true;
217
    }
219
    }
220
    
221
    /* (non-Javadoc)
222
     * @see org.eclipse.ui.internal.PartPane#showHighlight()
223
     */
224
    public void showHighlight() {
225
    	firePropertyChange(IPresentablePart.PROP_HIGHLIGHT_IF_BACK);
226
    }
218
227
219
}
228
}

Return to bug 86221