From b9f03594a89d9fc5f026c6170212affba5caec68 Mon Sep 17 00:00:00 2001 From: anttil <anttil> Date: Tue, 25 Sep 2012 06:12:43 +0000 Subject: [PATCH] SWE-2 / SP-263: Build simplified. Browser refresh wait is now based on paging toolbar values. SVN: 26778 --- ui-test/build/build.xml | 13 ++------ .../infra/application/ApplicationRunner.java | 1 + .../infra/webdriver/WaitForRefreshOf.java | 31 ++++++++++++------- .../uitest/page/tab/ExperimentBrowser.java | 10 ++++-- .../page/tab/ExperimentTypeBrowser.java | 2 +- .../uitest/page/tab/ProjectBrowser.java | 2 +- .../tab/PropertyTypeAssignmentBrowser.java | 2 +- .../uitest/page/tab/PropertyTypeBrowser.java | 2 +- .../uitest/page/tab/SampleBrowser.java | 2 +- .../uitest/page/tab/SampleTypeBrowser.java | 2 +- .../openbis/uitest/page/tab/SpaceBrowser.java | 2 +- .../uitest/page/tab/VocabularyBrowser.java | 2 +- .../openbis/uitest/suite/SeleniumTest.java | 2 +- .../openbis/uitest/widget/FilterToolBar.java | 6 ++-- .../cisd/openbis/uitest/widget/Grid.java | 8 +---- .../openbis/uitest/widget/PagingToolBar.java | 19 +++++++++++- .../openbis/uitest/widget/Refreshable.java | 4 ++- 17 files changed, 65 insertions(+), 45 deletions(-) diff --git a/ui-test/build/build.xml b/ui-test/build/build.xml index a257d980257..a389618f942 100644 --- a/ui-test/build/build.xml +++ b/ui-test/build/build.xml @@ -19,19 +19,10 @@ <target name="run-tests-ui" depends="compile-tests"> <delete dir="${output.test}" /> - <antcall target="_run-testng-ui"> <param name="test.suite" value="${test.suite}" /> <param name="failure.property" value="tests.failed" /> </antcall> - - <junitreport todir="${output.test}"> - <fileset dir="${output.test}"> - <include name="*/*.xml" /> - </fileset> - <report format="noframes" todir="${output.test}" /> - </junitreport> - <fail if="tests.failed" message="At least one test failed." /> </target> <target name="_run-testng-ui"> @@ -44,11 +35,13 @@ workingDir="." outputdir="${output.test}" failureproperty="${failure.property}"> - <xmlfileset dir="${sources.test}" includes="${test.suite}" /> + <xmlfileset dir="source/java" includes="${test.suite}" /> <jvmarg value="-Xmx1024M" /> <jvmarg value="-XX:MaxPermSize=512m" /> <jvmarg value="-Dui-test.url=${internal-url}" /> </testng> + + <fail if="${failure.property}" /> </target> diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/application/ApplicationRunner.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/application/ApplicationRunner.java index 2903e75c61e..945154d8ba7 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/application/ApplicationRunner.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/application/ApplicationRunner.java @@ -151,6 +151,7 @@ public class ApplicationRunner { browser.delete(); } + browser.resetFilters(); } public void delete(Vocabulary vocabulary) diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java index e6638d88e49..2f3432e9c08 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.uitest.infra.webdriver; import java.util.concurrent.TimeUnit; +import org.openqa.selenium.TimeoutException; import org.openqa.selenium.support.ui.FluentWait; import com.google.common.base.Predicate; @@ -30,14 +31,12 @@ import ch.systemsx.cisd.openbis.uitest.widget.Refreshable; public class WaitForRefreshOf<T> extends FluentWait<Refreshable> { - private final String state; - private Action<T> action; public WaitForRefreshOf(Refreshable widget) { super(widget); - this.state = widget.getState(); + widget.prepareWait(); } @SuppressWarnings("hiding") @@ -52,16 +51,24 @@ public class WaitForRefreshOf<T> extends FluentWait<Refreshable> T result = action.execute(); if (action.shouldWait(result)) { - withTimeout(seconds, TimeUnit.SECONDS) - .pollingEvery(100, TimeUnit.MILLISECONDS) - .until(new Predicate<Refreshable>() - { - @Override - public boolean apply(Refreshable widget) + try + { + withTimeout(seconds, TimeUnit.SECONDS) + .pollingEvery(100, TimeUnit.MILLISECONDS) + .until(new Predicate<Refreshable>() { - return !state.equals(widget.getState()); - } - }); + @Override + public boolean apply(Refreshable widget) + { + return widget.hasRefreshed(); + } + }); + + } catch (TimeoutException e) + { + System.out.println("TIMEOUT"); + throw e; + } } return result; } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentBrowser.java index d6dbe5fc128..b2741cd5002 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentBrowser.java @@ -25,6 +25,7 @@ import ch.systemsx.cisd.openbis.uitest.type.Project; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.DeletionConfirmationBox; import ch.systemsx.cisd.openbis.uitest.widget.Grid; +import ch.systemsx.cisd.openbis.uitest.widget.PagingToolBar; import ch.systemsx.cisd.openbis.uitest.widget.TreeGrid; public class ExperimentBrowser implements Browser<Experiment> @@ -32,6 +33,7 @@ public class ExperimentBrowser implements Browser<Experiment> @Locate("openbis_select-project") private TreeGrid projectTree; + @SuppressWarnings("unused") @Locate("openbis_experiment-browser-grid-grid") private Grid grid; @@ -42,9 +44,13 @@ public class ExperimentBrowser implements Browser<Experiment> @Locate("deletion-confirmation-dialog") private DeletionConfirmationBox deletionDialog; + @Lazy + @Locate("openbis_experiment-browser-grid-grid-paging-toolbar") + private PagingToolBar paging; + public boolean selectProject(final Project project) { - return new WaitForRefreshOf<Boolean>(grid).after(new Action<Boolean>() + return new WaitForRefreshOf<Boolean>(paging).after(new Action<Boolean>() { @Override public Boolean execute() @@ -57,7 +63,7 @@ public class ExperimentBrowser implements Browser<Experiment> { return result; } - }).withTimeoutOf(10); + }).withTimeoutOf(20); } public void deleteAll() diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java index c54e8b9d110..42567b18bba 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java @@ -79,7 +79,7 @@ public class ExperimentTypeBrowser implements Browser<ExperimentType> public void filter(final ExperimentType type) { paging.filters(); - filters.setCode(type.getCode(), grid); + filters.setCode(type.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java index 122a30b4c47..8934149b4bd 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java @@ -67,7 +67,7 @@ public class ProjectBrowser implements Browser<Project> public void filter(Project project) { paging.filters(); - filters.setCode(project.getCode(), grid); + filters.setCode(project.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java index 339d772bae8..f772e3f64b8 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java @@ -60,7 +60,7 @@ public class PropertyTypeAssignmentBrowser implements Browser<PropertyTypeAssign public void filter(PropertyTypeAssignment assignment) { paging.filters(); - filters.setCode(assignment.getPropertyType().getCode(), grid); + filters.setCode(assignment.getPropertyType().getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java index f8fae0c8edb..0a21dec36a8 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java @@ -71,7 +71,7 @@ public class PropertyTypeBrowser implements Browser<PropertyType> public void filter(PropertyType propertyType) { paging.filters(); - filters.setCode(propertyType.getCode(), grid); + filters.setCode(propertyType.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java index a3fbf5c4b16..7887d6f4fc4 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java @@ -86,7 +86,7 @@ public class SampleBrowser implements Browser<Sample> public void filter(Sample sample) { paging.filters(); - filters.setCode(sample.getCode(), grid); + filters.setCode(sample.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java index 0fe7fe4542f..1ec48ce5584 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java @@ -82,7 +82,7 @@ public class SampleTypeBrowser implements Browser<SampleType> public void filter(SampleType type) { paging.filters(); - filters.setCode(type.getCode(), grid); + filters.setCode(type.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java index 7f8ee12c341..58528761d92 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java @@ -75,7 +75,7 @@ public class SpaceBrowser implements Browser<Space> public void filter(final Space space) { paging.filters(); - filters.setCode(space.getCode(), grid); + filters.setCode(space.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java index 70af98719f0..8526a710a39 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java @@ -74,7 +74,7 @@ public class VocabularyBrowser implements Browser<Vocabulary> public void filter(Vocabulary vocabulary) { paging.filters(); - filters.setCode(vocabulary.getCode(), grid); + filters.setCode(vocabulary.getCode(), paging); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/suite/SeleniumTest.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/suite/SeleniumTest.java index 8b86834305e..9216d550696 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/suite/SeleniumTest.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/suite/SeleniumTest.java @@ -103,7 +103,7 @@ public abstract class SeleniumTest { uid = new DictionaryUidGenerator(new File("resource/corncob_lowercase.txt")); - // System.setProperty("webdriver.firefox.profile", "default"); + System.setProperty("webdriver.firefox.profile", "default"); driver = new FirefoxDriver(); setImplicitWaitToDefault(); diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java index 15393c039da..5b1a63576a2 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java @@ -28,11 +28,11 @@ public class FilterToolBar implements Widget private WidgetContext context; - public void setCode(final String text, Grid refreshingGrid) + public void setCode(final String text, Refreshable refresher) { final Text t = context.find(".//input[contains(@id, 'Code-input')]", Text.class); - new WaitForRefreshOf<Void>(refreshingGrid) + new WaitForRefreshOf<Void>(refresher) .after(new DeterminateAction<Void>() { @Override @@ -41,7 +41,7 @@ public class FilterToolBar implements Widget t.write(text); return null; } - }).withTimeoutOf(10); + }).withTimeoutOf(20); } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java index ee49297ad28..bb94d5e18ec 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java @@ -32,7 +32,7 @@ import ch.systemsx.cisd.openbis.uitest.suite.SeleniumTest; /** * @author anttil */ -public class Grid implements Widget, Refreshable +public class Grid implements Widget { private WidgetContext context; @@ -133,12 +133,6 @@ public class Grid implements Widget, Refreshable return s; } - @Override - public synchronized String getState() - { - return "" + this.getCells().size() + "/" + this.getColumns().size(); - } - @Override public void setContext(WidgetContext context) { diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java index e2117953676..b7534c8e051 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java @@ -21,7 +21,7 @@ import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WidgetContext; /** * @author anttil */ -public class PagingToolBar implements Widget +public class PagingToolBar implements Widget, Refreshable { private WidgetContext context; @@ -40,4 +40,21 @@ public class PagingToolBar implements Widget { this.context = context; } + + String displayText; + + @Override + public void prepareWait() + { + displayText = context.find(".//div[contains(@class, 'my-paging-display')]").getText(); + } + + @Override + public boolean hasRefreshed() + { + String currentText = + context.find(".//div[contains(@class, 'my-paging-display')]").getText(); + System.out.println("comparing " + displayText + " with " + currentText); + return (this.displayText.equals(currentText) == false); + } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Refreshable.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Refreshable.java index e8c2ff0be46..1c8d2b7b384 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Refreshable.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Refreshable.java @@ -21,5 +21,7 @@ package ch.systemsx.cisd.openbis.uitest.widget; */ public interface Refreshable { - public String getState(); + public void prepareWait(); + + public boolean hasRefreshed(); } -- GitLab