testdev/ite/test/com.nokia.testfw.test/src/com/nokia/testfw/test/framework/ViewPartTest.java
changeset 1 96906a986c3b
equal deleted inserted replaced
0:f1112f777ce9 1:96906a986c3b
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 package com.nokia.testfw.test.framework;
       
    18 
       
    19 import junit.framework.TestCase;
       
    20 
       
    21 import org.eclipse.ui.IViewPart;
       
    22 
       
    23 import org.eclipse.ui.PlatformUI;
       
    24 
       
    25 //import junit.framework.TestCase;
       
    26 import org.junit.Before;
       
    27 import org.junit.After;
       
    28 
       
    29 
       
    30 /**
       
    31  * this class is used to test a view part.
       
    32  * the subclass need to implememnt getViewId() method to return the view id under test
       
    33  * @author xiaoma
       
    34  *
       
    35  */
       
    36 public abstract class ViewPartTest extends TestCase{
       
    37 	
       
    38 	protected IViewPart viewPart;
       
    39 	
       
    40 	@Before
       
    41 	public void setUp() throws Exception {
       
    42 		viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
       
    43 	    		getViewId());
       
    44 	    if (viewPart == null) {
       
    45 	    	throw new RuntimeException("can't find view:" + getViewId());
       
    46 	    }	    
       
    47 	}
       
    48 	
       
    49 	@After
       
    50 	public void tearDown() throws Exception {
       
    51 		viewPart.dispose();
       
    52 	}
       
    53 	
       
    54 	protected abstract String getViewId(); 
       
    55 	
       
    56 }