/portal-web/test/com/liferay/portalweb/portlet/helloworld/portlet/addportlethwduplicate/AddPortletHWDuplicateTest.java

https://github.com/azzazzel/liferay-portal · Java · 91 lines · 60 code · 15 blank · 16 comment · 9 complexity · e1fa6a665c80a2a3a806903845f5a0d2 MD5 · raw file

  1. /**
  2. * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.portalweb.portlet.helloworld.portlet.addportlethwduplicate;
  15. import com.liferay.portalweb.portal.BaseTestCase;
  16. import com.liferay.portalweb.portal.util.RuntimeVariables;
  17. /**
  18. * @author Brian Wing Shun Chan
  19. */
  20. public class AddPortletHWDuplicateTest extends BaseTestCase {
  21. public void testAddPortletHWDuplicate() throws Exception {
  22. selenium.open("/web/guest/home/");
  23. loadRequiredJavaScriptModules();
  24. for (int second = 0;; second++) {
  25. if (second >= 90) {
  26. fail("timeout");
  27. }
  28. try {
  29. if (selenium.isVisible("link=Hello World Test Page")) {
  30. break;
  31. }
  32. }
  33. catch (Exception e) {
  34. }
  35. Thread.sleep(1000);
  36. }
  37. selenium.clickAt("link=Hello World Test Page",
  38. RuntimeVariables.replace("Hello World Test Page"));
  39. selenium.waitForPageToLoad("30000");
  40. loadRequiredJavaScriptModules();
  41. assertEquals(RuntimeVariables.replace("More\u2026"),
  42. selenium.getText("//a[@id='_145_addApplication']"));
  43. selenium.clickAt("//a[@id='_145_addApplication']",
  44. RuntimeVariables.replace("More\u2026"));
  45. for (int second = 0;; second++) {
  46. if (second >= 90) {
  47. fail("timeout");
  48. }
  49. try {
  50. if (selenium.isVisible(
  51. "//input[@id='layout_configuration_content']")) {
  52. break;
  53. }
  54. }
  55. catch (Exception e) {
  56. }
  57. Thread.sleep(1000);
  58. }
  59. selenium.typeKeys("//input[@id='layout_configuration_content']",
  60. RuntimeVariables.replace("h"));
  61. for (int second = 0;; second++) {
  62. if (second >= 90) {
  63. fail("timeout");
  64. }
  65. try {
  66. if (selenium.isVisible("//div[@title='Hello World']")) {
  67. break;
  68. }
  69. }
  70. catch (Exception e) {
  71. }
  72. Thread.sleep(1000);
  73. }
  74. assertFalse(selenium.isVisible("//div[@title='Hello World']/p/a"));
  75. }
  76. }