You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CriticalNotificationsTest.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.application;
  17. import org.junit.Test;
  18. import com.vaadin.testbench.elements.ButtonElement;
  19. import com.vaadin.testbench.elements.CheckBoxElement;
  20. import com.vaadin.testbench.elements.NotificationElement;
  21. import com.vaadin.testbench.parallel.BrowserUtil;
  22. import com.vaadin.tests.tb3.MultiBrowserThemeTest;
  23. public class CriticalNotificationsTest extends MultiBrowserThemeTest {
  24. @Override
  25. protected boolean useNativeEventsForIE() {
  26. if (BrowserUtil.isIE(getDesiredCapabilities(), 11)) {
  27. // Use JavaScript events only for IE11
  28. return false;
  29. } else {
  30. return true;
  31. }
  32. }
  33. @Test
  34. public void internalError() throws Exception {
  35. testCriticalNotification("Internal error");
  36. }
  37. @Test
  38. public void internalErrorDetails() throws Exception {
  39. testCriticalNotification("Internal error", true);
  40. }
  41. @Test
  42. public void custom() throws Exception {
  43. testCriticalNotification("Custom");
  44. }
  45. @Test
  46. public void sessionExpired() throws Exception {
  47. testCriticalNotification("Session expired");
  48. }
  49. @Test
  50. public void sessionExpiredDetails() throws Exception {
  51. testCriticalNotification("Session expired", true);
  52. }
  53. private void testCriticalNotification(String buttonCaption)
  54. throws Exception {
  55. testCriticalNotification(buttonCaption, false);
  56. }
  57. private void testCriticalNotification(String buttonCaption,
  58. boolean withDetails) throws Exception {
  59. openTestURL(); // "theme=" + getTheme());
  60. if (withDetails) {
  61. click($(CheckBoxElement.class).caption("Include details").first());
  62. }
  63. $(ButtonElement.class).caption(buttonCaption).first().click();
  64. // Give the notification some time to animate
  65. sleep(1000);
  66. compareScreen($(NotificationElement.class).first(),
  67. "systemnotification");
  68. }
  69. @Override
  70. protected Class<?> getUIClass() {
  71. return CriticalNotifications.class;
  72. }
  73. }