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

Collapse All | Expand All

(-)plugin.xml (+17 lines)
Lines 22-27 Link Here
22
      <import plugin="org.eclipse.ui.views"/>
22
      <import plugin="org.eclipse.ui.views"/>
23
      <import plugin="org.eclipse.text"/>
23
      <import plugin="org.eclipse.text"/>
24
      <import plugin="org.eclipse.jface.text"/>
24
      <import plugin="org.eclipse.jface.text"/>
25
      <import plugin="org.eclipse.test.performance"/>
25
   </requires>
26
   </requires>
26
27
27
28
Lines 61-67 Link Here
61
            icon="icons/anything.gif"
62
            icon="icons/anything.gif"
62
            class="org.eclipse.ui.tests.api.ViewPerspective"
63
            class="org.eclipse.ui.tests.api.ViewPerspective"
63
            id="org.eclipse.ui.tests.api.ViewPerspective">
64
            id="org.eclipse.ui.tests.api.ViewPerspective">
65
     </perspective>
66
	 <perspective
67
            name="Placeholder Test Perspective"
68
            icon="icons/anything.gif"
69
            class="org.eclipse.ui.tests.placeholders.PlaceholderPerspectiveFactory"
70
            id="org.eclipse.ui.tests.placeholders.placeholder">         
71
      </perspective>   
72
      <perspective
73
            name="Placeholder Test Sandbox Perspective"
74
            icon="icons/anything.gif"
75
            class="org.eclipse.ui.tests.placeholders.PlaceholderPerspectiveFactory"
76
            id="org.eclipse.ui.tests.placeholders.placeholderSandbox">         
64
      </perspective>
77
      </perspective>
78
      <perspective
79
            class="org.eclipse.ui.tests.dnd.RecursiveStackingPerspectiveFactory"
80
            name="Recursive stacking test perspective"
81
            id="org.eclipse.ui.tests.recursiveStackingPerspective"/>   
65
   </extension>
82
   </extension>
66
<!-- Utils End -->
83
<!-- Utils End -->
67
   <extension
84
   <extension
(-)Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java (+2 lines)
Lines 28-33 Link Here
28
import org.eclipse.ui.tests.menus.MenusTestSuite;
28
import org.eclipse.ui.tests.menus.MenusTestSuite;
29
import org.eclipse.ui.tests.multipageeditor.MultiPageEditorTestSuite;
29
import org.eclipse.ui.tests.multipageeditor.MultiPageEditorTestSuite;
30
import org.eclipse.ui.tests.navigator.NavigatorTestSuite;
30
import org.eclipse.ui.tests.navigator.NavigatorTestSuite;
31
import org.eclipse.ui.tests.placeholders.PlaceholderTestSuite;
31
import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
32
import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
32
import org.eclipse.ui.tests.presentations.PresentationsTestSuite;
33
import org.eclipse.ui.tests.presentations.PresentationsTestSuite;
33
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
34
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
Lines 74-79 Link Here
74
        addTest(new ThemesTestSuite());
75
        addTest(new ThemesTestSuite());
75
        addTest(new IntroTestSuite());
76
        addTest(new IntroTestSuite());
76
        addTest(new MenusTestSuite());
77
        addTest(new MenusTestSuite());
78
        addTest(new PlaceholderTestSuite());
77
        addTest(new PresentationsTestSuite());
79
        addTest(new PresentationsTestSuite());
78
    }
80
    }
79
}
81
}
(-)Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java (-23 / +27 lines)
Lines 1337-1365 Link Here
1337
1337
1338
    }
1338
    }
1339
1339
1340
    /**
1340
// Test is no longer valid with new style placeholders since there are
1341
     * Test opening a perspective with placeholders for multi instance views.
1341
// never any placeholders outside of a stack.
1342
     * The placeholders are added at top level (not in any folder).
1342
//
1343
     * 
1343
//    /**
1344
     * @since 3.1
1344
//     * Test opening a perspective with placeholders for multi instance views.
1345
     */
1345
//     * The placeholders are added at top level (not in any folder).
1346
    public void testOpenPerspectiveWithMultiViewPlaceholdersAtTopLevel() {
1346
//     * 
1347
        WorkbenchPage page = (WorkbenchPage) fActivePage;
1347
//     * @since 3.1
1348
1348
//     */
1349
        try {
1349
//    public void testOpenPerspectiveWithMultiViewPlaceholdersAtTopLevel() {
1350
            fWin.getWorkbench().showPerspective(
1350
//        WorkbenchPage page = (WorkbenchPage) fActivePage;
1351
                    PerspectiveWithMultiViewPlaceholdersAtTopLevel.PERSP_ID, fWin);
1351
//
1352
        } catch (WorkbenchException e) {
1352
//        try {
1353
            fail("Unexpected WorkbenchException: " + e);
1353
//            fWin.getWorkbench().showPerspective(
1354
        }
1354
//                    PerspectiveWithMultiViewPlaceholdersAtTopLevel.PERSP_ID, fWin);
1355
1355
//        } catch (WorkbenchException e) {
1356
        PerspectiveState state = new PerspectiveState(page);
1356
//            fail("Unexpected WorkbenchException: " + e);
1357
        ArrayList partIds = state.getPartIds(null);
1357
//        }
1358
        assertTrue(partIds.contains("*"));
1358
//
1359
        assertTrue(partIds.contains(MockViewPart.IDMULT));
1359
//        PerspectiveState state = new PerspectiveState(page);
1360
        assertTrue(partIds.contains(MockViewPart.IDMULT + ":secondaryId"));
1360
//        ArrayList partIds = state.getPartIds(null);
1361
        assertTrue(partIds.contains(MockViewPart.IDMULT + ":*"));
1361
//        
1362
    }
1362
//        assertTrue(partIds.contains("*"));
1363
//        assertTrue(partIds.contains(MockViewPart.IDMULT));
1364
//        assertTrue(partIds.contains(MockViewPart.IDMULT + ":secondaryId"));
1365
//        assertTrue(partIds.contains(MockViewPart.IDMULT + ":*"));
1366
//    }
1363
1367
1364
   /**
1368
   /**
1365
     * Test opening a perspective with placeholders for multi instance views.
1369
     * Test opening a perspective with placeholders for multi instance views.
(-)Eclipse UI Tests/org/eclipse/ui/tests/presentations/Bug48589Test.java (-1 lines)
Lines 20-26 Link Here
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.swt.custom.CTabFolder;
21
import org.eclipse.swt.custom.CTabFolder;
22
import org.eclipse.swt.custom.CTabItem;
22
import org.eclipse.swt.custom.CTabItem;
23
import org.eclipse.ui.IEditorPart;
24
import org.eclipse.ui.IWorkbenchWindow;
23
import org.eclipse.ui.IWorkbenchWindow;
25
import org.eclipse.ui.ide.IDE;
24
import org.eclipse.ui.ide.IDE;
26
import org.eclipse.ui.internal.EditorSashContainer;
25
import org.eclipse.ui.internal.EditorSashContainer;
(-)Eclipse UI Tests/org/eclipse/ui/tests/zoom/ZoomTestCase.java (-1 / +1 lines)
Lines 120-126 Link Here
120
            IViewPart view = page.showView(id);
120
            IViewPart view = page.showView(id);
121
            IViewReference ref = (IViewReference) page.getReference(view);
121
            IViewReference ref = (IViewReference) page.getReference(view);
122
            if (page.isFastView(ref))
122
            if (page.isFastView(ref))
123
                page.removeFastView(ref);
123
                page.reattachFastView(ref);
124
            return view;
124
            return view;
125
        } catch (PartInitException e) {
125
        } catch (PartInitException e) {
126
        }
126
        }
(-)Eclipse (+29 lines)
Added Link Here
1
/*
2
 * Created on Aug 19, 2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Style - Code Templates
6
 */
7
package org.eclipse.ui.tests.dnd;
8
9
import org.eclipse.ui.IFolderLayout;
10
import org.eclipse.ui.IPageLayout;
11
import org.eclipse.ui.IPerspectiveFactory;
12
13
/**
14
 */
15
public class RecursiveStackingPerspectiveFactory implements IPerspectiveFactory {
16
17
	public static final String FOLDER_ID = "org.eclipse.ui.test.dnd.RecursiveStackingPerspectiveFactory.mystack"; 
18
	
19
	/* (non-Javadoc)
20
	 * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
21
	 */
22
	public void createInitialLayout(IPageLayout layout) {
23
24
        IFolderLayout folder = layout.createFolder(FOLDER_ID,
25
                IPageLayout.BOTTOM, 0.5f, IPageLayout.ID_EDITOR_AREA);
26
        folder.addView(IPageLayout.ID_OUTLINE);
27
	}
28
29
}
(-)Eclipse (+68 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
14
import org.eclipse.ui.tests.dnd.DragOperations;
15
16
/**
17
 * THIS TEST DOES NOTHING RIGHT NOW. 
18
 * 
19
 * When detach/dock operations have API, this can be implemented through the
20
 * internalTest method. 
21
 * 
22
 * Tests a single detach view / dock view scenario. Given a view and a dropTarget. 
23
 * The dropTargets are to test placeholder consistancy in several different 
24
 * view states, such as "fast" or "detached". PlaceholderTestSuite generates 
25
 * several of these tests with different dropTargets. 
26
 * 
27
 * Test names indentify which view is being operated on and the dropTarget
28
 * to which it has been moved (if it has been moved). 
29
 * 
30
 * IF THIS TEST FAILS: 
31
 * See DragTest documentation for how to interpret layout description strings. 
32
 **/
33
34
public class DetachDockTest extends PlaceholderTestOperation {
35
36
	public DetachDockTest(String target) {
37
	    super("detching/docking view " + target);
38
	    this.target = target;  
39
	    this.drop = null; 
40
	    
41
	}
42
	
43
	public DetachDockTest(String target, AbstractTestDropTarget drop){
44
	    super("detaching/docking view " + target + " after moving to " + drop.toString());
45
	    this.target = target;  
46
	    this.drop = drop; 
47
	}
48
49
50
51
    public void internalTest(String ID) throws Exception {
52
        
53
        if((dragSource != null) && (drop != null)){
54
            page.showView(ID);
55
            dragSource.setPage(page);
56
            dragSource.drag(drop);
57
        }
58
        setExpectedResult(DragOperations.getLayoutDescription(page));
59
        
60
        
61
        //can't do this test until docking code is in place
62
        //IViewPart part = page.findView(ID);
63
        //ViewPane pane = (ViewPane)((PartSite)part.getSite()).getPane()
64
        
65
    }
66
    
67
68
}
(-)Eclipse (+99 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import org.eclipse.ui.IPerspectiveDescriptor;
14
import org.eclipse.ui.IPerspectiveRegistry;
15
import org.eclipse.ui.IViewPart;
16
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.internal.PartSite;
18
import org.eclipse.ui.internal.ViewPane;
19
import org.eclipse.ui.internal.WorkbenchPage;
20
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
21
import org.eclipse.ui.tests.dnd.DragOperations;
22
23
/**
24
 * Tests a single fast view / unfast view scenario. Given a view and a dropTarget. 
25
 * The dropTargets are to test placeholder consistancy in several different 
26
 * view states, such as "fast" or "detached". PlaceholderTestSuite generates 
27
 * several of these tests with different dropTargets. 
28
 * 
29
 * Test names indentify which view is being operated on and the dropTarget
30
 * to which it has been moved (if it has been moved). 
31
 * 
32
 * IF THIS TEST FAILS: 
33
 * See DragTest documentation for how to interpret layout description strings. 
34
 **/
35
36
public class FastUnfastTest extends PlaceholderTestOperation {
37
38
	public FastUnfastTest(String target, boolean withSaveState) {
39
	    super("addfast then removefast on " + target + " savestate " + withSaveState);
40
	    this.target = target;  
41
	    this.drop = null; 
42
	    this.withSaveState = withSaveState;
43
	    
44
	}
45
	
46
	public FastUnfastTest(String target, AbstractTestDropTarget drop, boolean withSaveState){
47
	    super("addfast then removefast on " + target + " after moving to "
48
	    		+ drop.toString() + " savestate " + withSaveState);
49
	    this.target = target;  
50
	    this.drop = drop; 
51
	    this.withSaveState = withSaveState;
52
	}
53
54
55
56
    public void internalTest(String ID) throws Exception {
57
        
58
        if((dragSource != null) && (drop != null)){
59
            page.showView(ID);
60
            dragSource.setPage(page);
61
            dragSource.drag(drop);
62
        }
63
        
64
        //There is a case where the view is dragged to the fast bar before the test
65
        //and thus fast/unfast isn't applicable and will fail.
66
        if(page.isFastView(page.findViewReference(target))){
67
        	setExpectedResult(DragOperations.getLayoutDescription(page));
68
            return; 
69
        }
70
        
71
        setExpectedResult(DragOperations.getLayoutDescription(page));
72
        
73
        IViewPart part = page.findView(ID);
74
        ViewPane pane = (ViewPane)((PartSite)part.getSite()).getPane();
75
        
76
        page.addFastView(pane.getViewReference());
77
        if(withSaveState) {
78
            IPerspectiveRegistry registry = PlatformUI.getWorkbench()
79
        		.getPerspectiveRegistry();
80
            IPerspectiveDescriptor pd = registry.findPerspectiveWithId
81
        		("org.eclipse.ui.tests.placeholders.placeholderSandbox");
82
            page.savePerspectiveAs(pd);
83
            page.close();
84
            page = (WorkbenchPage) PlatformUI.getWorkbench().showPerspective(
85
                    "org.eclipse.ui.tests.placeholders.placeholder", window);
86
            page.setPerspective(pd);
87
        }
88
89
        part = page.findView(ID);
90
        pane = (ViewPane)((PartSite)part.getSite()).getPane();
91
        
92
        page.reattachFastView(pane.getViewReference());
93
        if(target != null)
94
            page.showView(target);
95
        
96
    }
97
    
98
99
}
(-)Eclipse (+90 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
/**
14
 * Tests a single switch perspective / switch back scenario. Given a view and a dropTarget. 
15
 * The dropTargets are to test placeholder consistancy in several different 
16
 * view states, such as "fast" or "detached". PlaceholderTestSuite generates 
17
 * several of these tests with different dropTargets. 
18
 * 
19
 * Test names indentify which view is being operated on and the dropTarget
20
 * to which it has been moved (if it has been moved). 
21
 * 
22
 * IF THIS TEST FAILS: 
23
 * See DragTest documentation for how to interpret layout description strings. 
24
 **/
25
26
import org.eclipse.ui.IPageLayout;
27
import org.eclipse.ui.IPerspectiveDescriptor;
28
import org.eclipse.ui.IPerspectiveRegistry;
29
import org.eclipse.ui.PlatformUI;
30
import org.eclipse.ui.internal.WorkbenchPage;
31
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
32
import org.eclipse.ui.tests.dnd.DragOperations;
33
34
35
public class PerspectiveSwitchTest extends PlaceholderTestOperation {
36
    
37
    public PerspectiveSwitchTest(String target, boolean withSaveState) {
38
        super("Switching perspectives and back again" + " savestate " + withSaveState);
39
        this.target = target; 
40
        this.withSaveState = withSaveState;
41
    }        
42
    
43
    public PerspectiveSwitchTest(String target, AbstractTestDropTarget drop, boolean withSaveState) {
44
        super("Switching perspectives and back again after moving " + target
45
        		+ " to " + drop.toString() + " savestate " + withSaveState);
46
        this.target = target; 
47
        this.drop = drop; 
48
        this.withSaveState = withSaveState;
49
    }    
50
51
    public void internalTest(String ID) throws Exception {
52
        
53
        if((dragSource != null) && (drop != null)){
54
            page.showView(ID);
55
            dragSource.setPage(page);
56
            dragSource.drag(drop);
57
        }
58
        setExpectedResult(DragOperations.getLayoutDescription(page));
59
        IPerspectiveRegistry registry = PlatformUI.getWorkbench()
60
			.getPerspectiveRegistry();
61
        IPerspectiveDescriptor pd = registry.findPerspectiveWithId
62
			("org.eclipse.ui.tests.placeholders.placeholderSandbox");
63
        
64
        if(withSaveState) {
65
            page.savePerspectiveAs(pd);
66
            page.close();
67
            page = (WorkbenchPage) PlatformUI.getWorkbench().showPerspective(
68
                    "org.eclipse.ui.tests.placeholders.placeholder", window);
69
        }
70
        else {
71
        	pd = registry.findPerspectiveWithId
72
				("org.eclipse.ui.tests.placeholders.placeholder");
73
        }
74
        
75
        PlatformUI.getWorkbench().showPerspective(
76
                "org.eclipse.jdt.ui.JavaPerspective", window);
77
        
78
        page.setPerspective(pd);
79
        
80
//        PlatformUI.getWorkbench().showPerspective(
81
//                "org.eclipse.ui.tests.placeholders.placeholder", window);
82
        if(page.isFastView(page.findViewReference(target))){
83
        	page.activate(page.findView(IPageLayout.ID_OUTLINE));
84
        }
85
        else{
86
            page.activate(page.findView(target));
87
        }
88
    }
89
90
}
(-)Eclipse (+46 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import org.eclipse.ui.IFolderLayout;
14
import org.eclipse.ui.IPageLayout;
15
import org.eclipse.ui.IPerspectiveFactory;
16
17
public class PlaceholderPerspectiveFactory implements IPerspectiveFactory {
18
19
    /* (non-Javadoc)
20
     * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
21
     */
22
    public String WILD_CARD = "*";
23
    
24
    public void createInitialLayout(IPageLayout layout) {
25
        String folderId = "org.eclipse.ui.tests.placeholders.stack";
26
27
        IFolderLayout folder = layout.createFolder(folderId,
28
                IPageLayout.BOTTOM, 0.5f, IPageLayout.ID_EDITOR_AREA);
29
        folder.addView(IPageLayout.ID_OUTLINE);
30
        folder.addView(IPageLayout.ID_PROBLEM_VIEW);
31
        folder.addView(IPageLayout.ID_PROP_SHEET);
32
33
        layout.addView(IPageLayout.ID_RES_NAV, IPageLayout.LEFT, 0.5f,
34
                IPageLayout.ID_EDITOR_AREA);
35
        layout.addPlaceholder("org.eclipse.ui.tests.api.MockViewPartMult:1",
36
        		IPageLayout.LEFT, 0.5f, IPageLayout.ID_EDITOR_AREA);
37
        layout.addPlaceholder("org.eclipse.ui.tests.api.MockViewPartMult:*",
38
        		IPageLayout.RIGHT, 0.5f, IPageLayout.ID_EDITOR_AREA);
39
        /*layout.addView("org.eclipse.ui.tests.api.MockViewPartMult", IPageLayout.LEFT, 0.5f,
40
                IPageLayout.ID_EDITOR_AREA);
41
        layout.addView("org.eclipse.ui.tests.api.MockViewPartMult", IPageLayout.RIGHT, 0.5f,
42
                IPageLayout.ID_EDITOR_AREA);
43
        */
44
    }
45
46
}
(-)Eclipse (+106 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import junit.framework.Assert;
14
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.ui.IPageLayout;
17
import org.eclipse.ui.IPerspectiveDescriptor;
18
import org.eclipse.ui.IPerspectiveRegistry;
19
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.internal.WorkbenchPage;
21
import org.eclipse.ui.internal.WorkbenchWindow;
22
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
23
import org.eclipse.ui.tests.dnd.DragOperations;
24
import org.eclipse.ui.tests.dnd.TestDragSource;
25
import org.eclipse.ui.tests.dnd.ViewDragSource;
26
import org.eclipse.ui.tests.util.UITestCase;
27
28
/**
29
 * Abstract test operation from which all placeholder tests are 
30
 * derived. 
31
 */
32
public abstract class PlaceholderTestOperation extends UITestCase {
33
34
    String intendedResult;
35
    String target; 
36
    static WorkbenchWindow window;
37
    static WorkbenchPage page;
38
    TestDragSource dragSource;
39
    AbstractTestDropTarget drop; 
40
    String initialLayout; 
41
    boolean withSaveState; 
42
    
43
    public PlaceholderTestOperation(String testName) {
44
        super(testName);
45
    }
46
47
    public void doSetUp() throws Exception {
48
        manageWindows(false);
49
        window = (WorkbenchWindow)fWorkbench.getActiveWorkbenchWindow();     
50
        if(window == null) {
51
		    window = (WorkbenchWindow) fWorkbench.openWorkbenchWindow(
52
		             "org.eclipse.ui.tests.placeholders.placeholder", ResourcesPlugin
53
		                  .getWorkspace());
54
        }
55
            
56
        page = (WorkbenchPage) window.getActivePage();
57
        IPerspectiveRegistry registry = PlatformUI.getWorkbench()
58
    		.getPerspectiveRegistry();
59
        IPerspectiveDescriptor pd = registry.findPerspectiveWithId
60
    		("org.eclipse.ui.tests.placeholders.placeholder");
61
        page.setPerspective(pd);
62
	    page.resetPerspective();
63
	    page.closeAllEditors(false);
64
	    page.showView(IPageLayout.ID_OUTLINE);
65
	    page.hideView(page.findView("org.eclipse.ui.internal.introview"));
66
	    page.showView("org.eclipse.ui.tests.api.MockViewPartMult","1",
67
	    			WorkbenchPage.VIEW_ACTIVATE);
68
	    page.showView("org.eclipse.ui.tests.api.MockViewPartMult","*",
69
    			WorkbenchPage.VIEW_ACTIVATE);
70
	    page.showView(IPageLayout.ID_OUTLINE);
71
	    if(target != null){
72
	    	//ensure that target is the focus part (and at the top of its stack)
73
	    	page.showView(target);
74
	    }
75
76
        
77
    }
78
    
79
    public void setExpectedResult(String intended) {
80
        intendedResult = intended;
81
    }
82
    
83
    protected void runTest() throws Throwable {
84
       if(drop != null ){
85
            this.dragSource = new ViewDragSource(target, false);
86
       }
87
            internalTest(target);
88
        String resultingLayout = DragOperations.getLayoutDescription(page);
89
        if (intendedResult != null) {
90
            if (!resultingLayout.equals(intendedResult)) {
91
                String errorMessage = "Expecting '" + intendedResult
92
                        + "' and found '" + resultingLayout + "'";
93
94
                System.out.println("Failed " + getName() + ": " + errorMessage);
95
96
                Assert.assertEquals(
97
                        "Placeholder test operation resulted in incorrect layout",
98
                        intendedResult, resultingLayout);
99
            }
100
        }
101
102
        page.getActivePerspective().testInvariants();
103
    }
104
    
105
    public abstract void internalTest(String target) throws Exception;
106
}
(-)Eclipse (+103 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.ui.IPageLayout;
15
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
16
import org.eclipse.ui.tests.dnd.DetachedDropTarget;
17
import org.eclipse.ui.tests.dnd.FastViewBarDropTarget;
18
import org.eclipse.ui.tests.dnd.ViewDropTarget;
19
import org.eclipse.ui.tests.dnd.WindowDropTarget;
20
21
import junit.framework.Test;
22
import junit.framework.TestSuite;
23
24
25
public class PlaceholderTestSuite extends TestSuite {
26
27
    /**
28
     * Returns the suite. This is required to use the JUnit Launcher.
29
     */
30
    public static Test suite() {
31
        return new PlaceholderTestSuite();
32
    }
33
34
    public PlaceholderTestSuite() {
35
        
36
        //the test view is 3rd in a folder, and a multi instance view
37
        String[] targets = {IPageLayout.ID_PROP_SHEET,
38
                			"org.eclipse.ui.tests.api.MockViewPartMult"
39
                			};
40
        
41
        //the drop targets
42
        AbstractTestDropTarget[] dragTargets = new AbstractTestDropTarget[] {
43
                //test for proper restore when dropped onto a stack
44
                new ViewDropTarget(IPageLayout.ID_RES_NAV, SWT.TOP),
45
                //test for proper restore when dropped to right of stack 
46
                new ViewDropTarget(IPageLayout.ID_RES_NAV, SWT.RIGHT),
47
                //test for proper container upon restore
48
                new WindowDropTarget(SWT.RIGHT),
49
                //test for proper restore upon removefastview
50
                new FastViewBarDropTarget(),
51
                //test for proper windowupon restore
52
                new DetachedDropTarget()};
53
        
54
        addCombinations(targets, dragTargets);
55
       
56
    }
57
    
58
    private void addCombinations(String[] targets, AbstractTestDropTarget[] drops){
59
        for(int i = 0; i < targets.length; i++){
60
	        //add the normal case, no movement
61
	        PlaceholderTestOperation t;
62
	        t = new ReopenTest(targets[i], false);
63
	        addTest(t);
64
	        t = new FastUnfastTest(targets[i], false);
65
	        addTest(t); 
66
	        t = new PerspectiveSwitchTest(targets[i], false);
67
	        addTest(t); 
68
	        t = new ReopenTest(targets[i], true);
69
	        addTest(t);
70
	        t = new FastUnfastTest(targets[i], true);
71
	        addTest(t); 
72
	        t = new PerspectiveSwitchTest(targets[i], true);
73
	        addTest(t); 
74
	        t = new SaveStateTest(targets[i]);
75
	        addTest(t); 
76
	        //t = new DetachDockTest(targets[i]);
77
	        //addTest(t);
78
	        
79
	        
80
	        //move the view to each of the drop targets and try to close/restore it
81
	        for(int j = 0; j < drops.length; j++){
82
	            t = new ReopenTest(targets[i], drops[j], false);
83
	            addTest(t);
84
	            t = new FastUnfastTest(targets[i], drops[j], false);
85
	            addTest(t); 
86
	            t = new PerspectiveSwitchTest(targets[i], drops[j], false);
87
	            addTest(t); 
88
	            t = new ReopenTest(targets[i], drops[j], true);
89
	            addTest(t);
90
	            t = new FastUnfastTest(targets[i], drops[j], true);
91
	            addTest(t); 
92
	            t = new PerspectiveSwitchTest(targets[i], drops[j], true);
93
	            addTest(t); 
94
		        t = new SaveStateTest(targets[i], drops[j]);
95
		        addTest(t); 
96
	            //t = new DetachDockTest(targets[i], drops[j]);
97
	            //addTest(t);
98
	        }
99
        }
100
    }
101
   
102
103
}
(-)Eclipse (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import org.eclipse.ui.IPageLayout;
14
import org.eclipse.ui.IPerspectiveDescriptor;
15
import org.eclipse.ui.IPerspectiveRegistry;
16
import org.eclipse.ui.IViewPart;
17
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.internal.PartSite;
19
import org.eclipse.ui.internal.ViewPane;
20
import org.eclipse.ui.internal.WorkbenchPage;
21
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
22
import org.eclipse.ui.tests.dnd.DragOperations;
23
24
/**
25
 * Tests a single close view / open view scenario. Given a view and a dropTarget. 
26
 * The dropTargets are to test placeholder consistancy in several different 
27
 * view states, such as "fast" or "detached". PlaceholderTestSuite generates 
28
 * several of these tests with different dropTargets. 
29
 * 
30
 * Test names indentify which view is being operated on and the dropTarget
31
 * to which it has been moved (if it has been moved). 
32
 * 
33
 * IF THIS TEST FAILS: 
34
 * See DragTest documentation for how to interpret layout description strings. 
35
 **/
36
37
public class ReopenTest extends PlaceholderTestOperation {
38
39
	public ReopenTest(String target, boolean withSaveState) {
40
	    super("Closing and opening view starting with id: " + target + " savestate " + withSaveState);
41
	    this.target = target;  
42
	    this.drop = null; 
43
	    this.withSaveState = withSaveState; 
44
	    
45
	}
46
	
47
	public ReopenTest(String target, AbstractTestDropTarget drop, boolean withSaveState){
48
	    super("Closing and opening view starting with id: " + target
49
	    		+ " after moving to " + drop.toString() + " savestate " + withSaveState);
50
	    this.target = target;  
51
	    this.drop = drop; 
52
	    this.withSaveState = withSaveState;
53
	}
54
55
56
57
    public void internalTest(String ID) throws Exception {
58
        
59
        if((dragSource != null) && (drop != null)){
60
            page.showView(ID);
61
            dragSource.setPage(page);
62
            dragSource.drag(drop);
63
        }
64
        setExpectedResult(DragOperations.getLayoutDescription(page));
65
        
66
        IViewPart part = page.findView(ID);
67
        ViewPane pane = (ViewPane)((PartSite)part.getSite()).getPane();
68
        page.hideView(part);
69
        if(withSaveState) {
70
            IPerspectiveRegistry registry = PlatformUI.getWorkbench()
71
        		.getPerspectiveRegistry();
72
            IPerspectiveDescriptor pd = registry.findPerspectiveWithId
73
        		("org.eclipse.ui.tests.placeholders.placeholderSandbox");
74
            page.savePerspectiveAs(pd);
75
            page.close();
76
            page = (WorkbenchPage) PlatformUI.getWorkbench().showPerspective(
77
                    "org.eclipse.ui.tests.placeholders.placeholder", window);
78
            page.setPerspective(pd);
79
        }
80
        page.showView(ID);
81
        if(page.isFastView(page.findViewReference(target))){
82
        	page.activate(page.findView(IPageLayout.ID_OUTLINE));
83
        }
84
        else{
85
            page.activate(page.findView(target));
86
        }
87
        
88
    }
89
    
90
91
}
(-)Eclipse (+75 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.placeholders;
12
13
import org.eclipse.ui.IPageLayout;
14
import org.eclipse.ui.IPerspectiveDescriptor;
15
import org.eclipse.ui.IPerspectiveRegistry;
16
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.internal.WorkbenchPage;
18
import org.eclipse.ui.tests.dnd.AbstractTestDropTarget;
19
import org.eclipse.ui.tests.dnd.DragOperations;
20
21
/**
22
 * Tests a single close workbench / open workbench scenario. Given a view and a
23
 * dropTarget. The dropTargets are to test placeholder consistancy in several
24
 * different view states, such as "fast" or "detached". PlaceholderTestSuite
25
 * generates several of these tests with different dropTargets.
26
 * 
27
 * Test names indentify which view is being operated on and the dropTarget to
28
 * which it has been moved (if it has been moved).
29
 * 
30
 * IF THIS TEST FAILS: See DragTest documentation for how to interpret layout
31
 * description strings.
32
 */
33
34
public class SaveStateTest extends PlaceholderTestOperation {
35
36
    public SaveStateTest(String target) {
37
        super("Reopening the workbench");
38
        this.target = target;
39
    }
40
41
    public SaveStateTest(String target, AbstractTestDropTarget drop) {
42
        super("Reopening the workbench after moving " + target + " to "
43
                + drop.toString());
44
        this.target = target;
45
        this.drop = drop;
46
    }
47
48
    public void internalTest(String ID) throws Exception {
49
50
        if ((dragSource != null) && (drop != null)) {
51
            page.showView(ID);
52
            dragSource.setPage(page);
53
            dragSource.drag(drop);
54
        }
55
        setExpectedResult(DragOperations.getLayoutDescription(page));
56
57
        IPerspectiveRegistry registry = PlatformUI.getWorkbench()
58
        	.getPerspectiveRegistry();
59
        IPerspectiveDescriptor pd = registry.findPerspectiveWithId
60
        	("org.eclipse.ui.tests.placeholders.placeholderSandbox");
61
        
62
        page.savePerspectiveAs(pd);
63
        page.close();
64
        page = (WorkbenchPage) PlatformUI.getWorkbench().showPerspective(
65
                "org.eclipse.ui.tests.placeholders.placeholder", window);
66
        page.setPerspective(pd);
67
        if(page.isFastView(page.findViewReference(target))){
68
        	page.activate(page.findView(IPageLayout.ID_OUTLINE));
69
        }
70
        else{
71
            page.activate(page.findView(target));
72
        }
73
    }
74
75
}

Return to bug 72060