aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorLeif Ã…strand <leif@vaadin.com>2013-07-08 17:23:49 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2013-07-10 10:32:38 +0000
commit20162dbe200111a514ab0849963dcf3eea1a9c83 (patch)
treedeb40c8ef3b6ec2c5f620d1a02658050fbac8dbb /uitest/src/com
parente4011c6fa4d7a00b718551885339854ceacc0cf0 (diff)
downloadvaadin-framework-20162dbe200111a514ab0849963dcf3eea1a9c83.tar.gz
vaadin-framework-20162dbe200111a514ab0849963dcf3eea1a9c83.zip
Set current instances when calling UI.push from VaadinSession.unlock (#12168)
Change-Id: I27795ab9ae3e3692f508e847936ccaa5a1ebadd4
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UiAccess.html26
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UiAccess.java54
2 files changed, 80 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.html b/uitest/src/com/vaadin/tests/components/ui/UiAccess.html
index 613691623c..734b95952a 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UiAccess.html
+++ b/uitest/src/com/vaadin/tests/components/ui/UiAccess.html
@@ -161,6 +161,32 @@
<td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td>
<td>3. Test value after access: Set before run pending</td>
</tr>
+<!-- Run last part with push enabled -->
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.ui.UiAccess?restartApplication&amp;transport=websocket</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForNotText</td>
+ <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td>
+ <td>exact:1. Current session matches in beforeResponse? true</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td>
+ <td>exact:0. Current UI matches in beforeResponse? true</td>
+</tr>
</tbody></table>
</body>
</html>
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java b/uitest/src/com/vaadin/tests/components/ui/UiAccess.java
index 2bc91fa7b4..09f2fd8816 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java
+++ b/uitest/src/com/vaadin/tests/components/ui/UiAccess.java
@@ -23,13 +23,18 @@ import java.util.concurrent.locks.ReentrantLock;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
+import com.vaadin.server.VaadinSession;
+import com.vaadin.shared.communication.PushMode;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.UI;
import com.vaadin.util.CurrentInstance;
public class UiAccess extends AbstractTestUIWithLog {
+ private volatile boolean checkCurrentInstancesBeforeResponse = false;
+
private Future<Void> checkFromBeforeClientResponse;
private class CurrentInstanceTestType {
@@ -283,6 +288,46 @@ public class UiAccess extends AbstractTestUIWithLog {
.get(CurrentInstanceTestType.class));
}
}));
+
+ addComponent(new Button("CurrentInstance when pushing",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ if (getPushConfiguration().getPushMode() != PushMode.AUTOMATIC) {
+ log("Can only test with automatic push enabled");
+ return;
+ }
+
+ final VaadinSession session = getSession();
+ new Thread() {
+ @Override
+ public void run() {
+ // Pretend this isn't a Vaadin thread
+ CurrentInstance.clearAll();
+
+ /*
+ * Get explicit lock to ensure the (implicit)
+ * push does not happen during normal request
+ * handling.
+ */
+ session.lock();
+ try {
+ access(new Runnable() {
+ @Override
+ public void run() {
+ checkCurrentInstancesBeforeResponse = true;
+ // Trigger beforeClientResponse
+ markAsDirty();
+ }
+ });
+ } finally {
+ session.unlock();
+ }
+ }
+ }.start();
+ }
+ }));
}
@Override
@@ -292,6 +337,15 @@ public class UiAccess extends AbstractTestUIWithLog {
+ checkFromBeforeClientResponse.isDone());
checkFromBeforeClientResponse = null;
}
+ if (checkCurrentInstancesBeforeResponse) {
+ UI currentUI = UI.getCurrent();
+ VaadinSession currentSession = VaadinSession.getCurrent();
+
+ log("Current UI matches in beforeResponse? " + (currentUI == this));
+ log("Current session matches in beforeResponse? "
+ + (currentSession == getSession()));
+ checkCurrentInstancesBeforeResponse = false;
+ }
}
@Override