blob: bac4e9159eef0642516d51f31e5ac183de3bcc79 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011 SAP AG, Walldorf.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* SAP AG - initial API and implementation
*******************************************************************************/
package org.eclipse.platform.discovery.ui.test.comp.internal.pageobjects.swtbot;
import org.eclipse.platform.discovery.ui.test.comp.internal.pageobjects.swtbot.utils.MouseUtils;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.results.BoolResult;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
import org.eclipse.ui.forms.widgets.Section;
/**
* SWTBot for {@link Section}. The implementation expands and collapses the section via mouse interaction. The reason for this is that calling
* {@link Section#setExpanded(boolean)} does broadcast selection events. This is important for the search console since the section title is expected
* to change when the section expansion state changes
*
* @author Danail Branekov
*
*/
public class SWTBotSection extends AbstractSWTBotControl<Section>
{
private final MouseUtils mouseUtils;
public SWTBotSection(Section w) throws WidgetNotFoundException
{
super(w);
this.mouseUtils = new MouseUtils(display);
}
public void toggle()
{
mouseUtils.clickOn(this, 10, 5);
};
private boolean isExpanded()
{
return syncExec(new BoolResult()
{
@Override
public Boolean run()
{
return widget.isExpanded();
}
});
}
public void expand()
{
if (isExpanded())
{
return;
}
toggle();
}
public void collapse()
{
if (!isExpanded())
{
return;
}
toggle();
}
}