Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Monnier2016-09-21 07:40:14 +0000
committerSteve Monnier2016-09-23 11:58:39 +0000
commitd58c3477b8f78008585c5d1dfdbd93bea2220850 (patch)
tree50c9fab8ed529a7b18b2952eaf9960c30f6215da
parentefc74fefd2f91419c8b003ae2965284fe2a7e337 (diff)
downloadorg.eclipse.sirius-d58c3477b8f78008585c5d1dfdbd93bea2220850.tar.gz
org.eclipse.sirius-d58c3477b8f78008585c5d1dfdbd93bea2220850.tar.xz
org.eclipse.sirius-d58c3477b8f78008585c5d1dfdbd93bea2220850.zip
[501900] Add a new condition checking checkbox status
Bug: 501900 Change-Id: I0d1bb77cb889dd7f81c655f01c2626acb1149c59 Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckboxStatusCondition.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckboxStatusCondition.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckboxStatusCondition.java
new file mode 100644
index 0000000000..289144a1e5
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckboxStatusCondition.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2016 THALES GLOBAL SERVICES
+ * 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:
+ * Obeo - Initial API and implementation
+ */
+package org.eclipse.sirius.tests.swtbot.support.api.condition;
+
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+
+/**
+ * Condition validating a checkbox status (checked or unchecked).
+ *
+ * @author <a href="mailto:steve.monnier@obeo.fr">Steve Monnier</a>
+ */
+public class CheckboxStatusCondition extends DefaultCondition {
+
+ private SWTBotCheckBox checkBox;
+
+ private boolean expectedToBeChecked;
+
+ /**
+ * Constructor.
+ *
+ * @param checkBox
+ * the checkbox to validate the status.
+ *
+ * @param expectedToBeChecked
+ * true if expected to be checked, false otherwise.
+ */
+ public CheckboxStatusCondition(SWTBotCheckBox checkBox, Boolean expectedToBeChecked) {
+ this.checkBox = checkBox;
+ this.expectedToBeChecked = expectedToBeChecked;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ return this.checkBox.isChecked() == this.expectedToBeChecked;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ if (expectedToBeChecked) {
+ return "The checkbox was expected to be checked but it was unchecked";
+ } else {
+ return "The checkbox was expected to be unchecked but was checked";
+ }
+ }
+}

Back to the top