summaryrefslogtreecommitdiffstats
path: root/tests/server-side
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-03-20 15:10:10 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-03-20 15:10:10 +0000
commit3ae537eaf91633b589c9628d68aaae1153f8712e (patch)
treedcf168dbd546a8d304d8425a9b1d35cae7c00776 /tests/server-side
parent9f3b320609250996730b57790a330e35a08f4a03 (diff)
downloadvaadin-framework-3ae537eaf91633b589c9628d68aaae1153f8712e.tar.gz
vaadin-framework-3ae537eaf91633b589c9628d68aaae1153f8712e.zip
#8209 Added a public click() method to Button, simulating a click on server side
svn changeset:23275/svn branch:6.8
Diffstat (limited to 'tests/server-side')
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/button/ButtonClick.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/server-side/com/vaadin/tests/server/component/button/ButtonClick.java b/tests/server-side/com/vaadin/tests/server/component/button/ButtonClick.java
new file mode 100644
index 0000000000..464d131996
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/button/ButtonClick.java
@@ -0,0 +1,47 @@
+package com.vaadin.tests.server.component.button;
+
+import static org.junit.Assert.assertEquals;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+import org.junit.Test;
+
+/**
+ * Tests the public click() method.
+ */
+public class ButtonClick {
+ private boolean clicked = false;
+
+ @Test
+ public void testClick() {
+ getButton().click();
+ assertEquals(clicked, true);
+ }
+
+ @Test
+ public void testClickDisabled() {
+ Button b = getButton();
+ b.setEnabled(false);
+ b.click();
+ assertEquals(clicked, false);
+ }
+
+ @Test
+ public void testClickReadOnly() {
+ Button b = getButton();
+ b.setReadOnly(true);
+ b.click();
+ assertEquals(clicked, false);
+ }
+
+ private Button getButton() {
+ Button b = new Button();
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent ev) {
+ clicked = true;
+ }
+ });
+ return b;
+ }
+}