Search in sources :

Example 6 with ICondition

use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.

the class SyncopeViewTest method canAddReportTemplate.

private boolean canAddReportTemplate() {
    SWTBotTreeItem rTemplateHead = syncopeView.bot().tree().getTreeItem("Report Templates");
    rTemplateHead.setFocus();
    rTemplateHead.select().contextMenu("Add Template").click();
    BOT.sleep(1000);
    // Filling Dialog details
    SWTBotShell addTemplateShell = BOT.activeShell();
    addTemplateShell.activate();
    BOT.textWithLabel("Key").setText("newReportTemplate");
    BOT.button("Add").click();
    // wait for template keys reload
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            String title = BOT.activeShell().getText();
            return title.equals("Loading Templates");
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
    // recheck available templates
    syncopeView = BOT.viewByTitle("Apache Syncope Templates");
    rTemplateItem = syncopeView.bot().tree().expandNode("Report Templates");
    rtemplateList = rTemplateItem.getItems();
    return (rtemplateList.length == 3 && rtemplateList[1].getText().equals("newReportTemplate"));
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition)

Example 7 with ICondition

use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.

the class SyncopeViewTest method canLoginAdmin.

@Test
public void canLoginAdmin() throws Exception {
    SWTBotShell loginShell = BOT.activeShell();
    loginShell.activate();
    BOT.textWithLabel("Deployment Url").setText(ADDRESS);
    BOT.textWithLabel("Username").setText(ADMIN_UNAME);
    BOT.textWithLabel("Password").setText(ADMIN_PWD);
    BOT.button("Login").click();
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            String title = BOT.activeShell().getText();
            return title.equals("Loading Templates");
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition) Test(org.junit.jupiter.api.Test)

Example 8 with ICondition

use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.

the class SyncopeViewTest method canAddMailTemplate.

private boolean canAddMailTemplate() {
    SWTBotTreeItem mTemplateHead = syncopeView.bot().tree().getTreeItem("Mail Templates");
    mTemplateHead.setFocus();
    mTemplateHead.select().contextMenu("Add Template").click();
    BOT.sleep(1000);
    // Filling Dialog details
    SWTBotShell addTemplateShell = BOT.activeShell();
    addTemplateShell.activate();
    BOT.textWithLabel("Key").setText("newMailTemplate");
    BOT.button("Add").click();
    // wait for template keys reload
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            String title = BOT.activeShell().getText();
            return title.equals("Loading Templates");
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
    // recheck available templates
    syncopeView = BOT.viewByTitle("Apache Syncope Templates");
    mTemplateItem = syncopeView.bot().tree().expandNode("Mail Templates");
    mtemplateList = mTemplateItem.getItems();
    return (mtemplateList.length == 5 && mtemplateList[1].getText().equals("newMailTemplate"));
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition)

Example 9 with ICondition

use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.

the class SyncopeViewTest method canOpenReportTemplateEditor.

public boolean canOpenReportTemplateEditor() {
    final int initBotEditors = BOT.editors().size();
    SWTBotTreeItem sample = syncopeView.bot().tree().expandNode("Report Templates").getNode("sample");
    sample.setFocus();
    sample.select().contextMenu("View Template").click();
    // wait for template keys reload
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            return BOT.editors().size() == initBotEditors;
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
    return !BOT.editors().isEmpty();
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition)

Example 10 with ICondition

use of org.eclipse.swtbot.swt.finder.waits.ICondition in project syncope by apache.

the class SyncopeViewTest method canDeleteMailTemplate.

private boolean canDeleteMailTemplate() {
    SWTBotTreeItem mTemplateHead = syncopeView.bot().tree().getTreeItem("Mail Templates");
    if (!mTemplateHead.isExpanded()) {
        mTemplateHead.expand();
    }
    SWTBotTreeItem mNewTemplate = mTemplateHead.getNode("newMailTemplate");
    mNewTemplate.setFocus();
    mNewTemplate.select().contextMenu("Remove template").click();
    BOT.sleep(1000);
    // wait for template keys reload
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            String title = BOT.activeShell().getText();
            return title.equals("Loading Templates");
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
    // recheck available templates
    mTemplateItem = syncopeView.bot().tree().expandNode("Mail Templates");
    mtemplateList = mTemplateItem.getItems();
    return (mtemplateList.length == 4);
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition)

Aggregations

ICondition (org.eclipse.swtbot.swt.finder.waits.ICondition)11 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)10 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)8 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)6 ArrayList (java.util.ArrayList)2 TimeoutException (org.eclipse.swtbot.swt.finder.widgets.TimeoutException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 CommitOperation (org.eclipse.egit.core.op.CommitOperation)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Image (org.eclipse.swt.graphics.Image)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1