|
Swtfiner5MinutesTutorial
5 Minutes TutorialIntroductionThis 5 minutes tutorial shows how to use swtfinder. In this tutorial, swtfinder is used to help testing the eclipse outline view. Eclipse Outline ViewThe Eclipse outline view displays an outline of a structured file that is currently open in the editor area. When there is no editor page in current workbench page,the view looks like the following picture. Now, we will try to write a junit plug-in test to test this scenario from UI. Test case for thisHow to do this? test case 1:
test case 2: ... test case 3: ... We will implement the test case 1 as junit plug-in test. Use UI tool plug-in for SWTFinderfirst, use ui plug-in tool of swtfinder to analysis the controls in outline view(download and install it first). Following the following way to analyze the initial state of outline view.
the following picture lists the control tree of the outline view.
Let's locate the label control with text "An outline is not available"
Use the core API in test classActually, the generated code just invokes the core API to locate the control. Users can write such API manually. Core API provides many different ways to locate a control in eclipse view/editor. The generated code is just one of these powerful APIs. Label returnControl= (Label)Finder.getDefault().findIndexByClassInEclipseView( "org.eclipse.ui.views.ContentOutline",Label.class,1); The API can be used directly in you java program,and this API and other API in core plug-in can be invoked both in UI thread and non-UI thread. An example project is created to implement the first test case to test the outline view. Download the project at here. Unzip it and import this project into eclipse with swtfinder core plug-in installed. Read the source code of TestOutlineView.java to figure out how to use the generated code to locate control in java program.
|
Sign in to add a comment