01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.tests.performance.layout;
11:
12: import junit.framework.Assert;
13:
14: import org.eclipse.core.runtime.CoreException;
15: import org.eclipse.swt.graphics.Point;
16: import org.eclipse.swt.widgets.Composite;
17: import org.eclipse.ui.IWorkbenchPage;
18: import org.eclipse.ui.IWorkbenchWindow;
19: import org.eclipse.ui.PlatformUI;
20: import org.eclipse.ui.WorkbenchException;
21: import org.eclipse.ui.tests.harness.util.UITestCase;
22:
23: /**
24: * @since 3.1
25: */
26: public class PerspectiveWidgetFactory extends TestWidgetFactory {
27:
28: private String perspectiveId;
29: private IWorkbenchWindow window;
30:
31: public PerspectiveWidgetFactory(String initialPerspective) {
32: perspectiveId = initialPerspective;
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.ui.tests.performance.TestWidgetFactory#getMaxSize()
37: */
38: public Point getMaxSize() {
39: return new Point(1024, 768);
40: }
41:
42: /* (non-Javadoc)
43: * @see org.eclipse.ui.tests.performance.TestWidgetFactory#init()
44: */
45: public void init() throws WorkbenchException {
46: // open the perspective in a new window
47: window = PlatformUI.getWorkbench().openWorkbenchWindow(
48: perspectiveId, UITestCase.getPageInput());
49: IWorkbenchPage page = window.getActivePage();
50: Assert.assertNotNull(page);
51: }
52:
53: /* (non-Javadoc)
54: * @see org.eclipse.ui.tests.performance.TestWidgetFactory#getName()
55: */
56: public String getName() {
57: return "Perspective " + perspectiveId;
58: }
59:
60: /* (non-Javadoc)
61: * @see org.eclipse.ui.tests.performance.TestWidgetFactory#getControl()
62: */
63: public Composite getControl() {
64: return window.getShell();
65: }
66:
67: /* (non-Javadoc)
68: * @see org.eclipse.ui.tests.performance.layout.TestWidgetFactory#done()
69: */
70: public void done() throws CoreException, WorkbenchException {
71: window.close();
72: super.done();
73: }
74: }
|