/portal-web/test/com/liferay/portalweb/portlet/sitemap/portlet/viewportletsitemap/ViewPortletSiteMapTest.java

https://github.com/monicali/liferay-portal · Java · 123 lines · 92 code · 15 blank · 16 comment · 9 complexity · f25bd2087f3a216ec78d60f61d829eef 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.sitemap.portlet.viewportletsitemap;
  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 ViewPortletSiteMapTest extends BaseTestCase {
  21. public void testViewPortletSiteMap() 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=Site Map Test Page")) {
  30. break;
  31. }
  32. }
  33. catch (Exception e) {
  34. }
  35. Thread.sleep(1000);
  36. }
  37. selenium.clickAt("link=Site Map Test Page",
  38. RuntimeVariables.replace("Site Map Test Page"));
  39. selenium.waitForPageToLoad("30000");
  40. loadRequiredJavaScriptModules();
  41. assertEquals(RuntimeVariables.replace("Welcome"),
  42. selenium.getText("xPath=(//div[@class='portlet-body']/ul/li/a)[1]"));
  43. selenium.clickAt("xPath=(//div[@class='portlet-body']/ul/li/a)[1]",
  44. RuntimeVariables.replace("Welcome"));
  45. selenium.waitForPageToLoad("30000");
  46. loadRequiredJavaScriptModules();
  47. assertEquals(RuntimeVariables.replace("Sign In"),
  48. selenium.getText("xPath=(//h1[@class='portlet-title'])[1]"));
  49. assertEquals(RuntimeVariables.replace("Hello World"),
  50. selenium.getText("xPath=(//h1[@class='portlet-title'])[2]"));
  51. assertTrue(selenium.isVisible("xPath=(//section[@class='portlet'])[1]"));
  52. assertTrue(selenium.isVisible("xPath=(//section[@class='portlet'])[2]"));
  53. selenium.open("/web/guest/home/");
  54. loadRequiredJavaScriptModules();
  55. for (int second = 0;; second++) {
  56. if (second >= 90) {
  57. fail("timeout");
  58. }
  59. try {
  60. if (selenium.isVisible("link=Site Map Test Page")) {
  61. break;
  62. }
  63. }
  64. catch (Exception e) {
  65. }
  66. Thread.sleep(1000);
  67. }
  68. selenium.clickAt("link=Site Map Test Page",
  69. RuntimeVariables.replace("Site Map Test Page"));
  70. selenium.waitForPageToLoad("30000");
  71. loadRequiredJavaScriptModules();
  72. assertEquals(RuntimeVariables.replace("Site Map Test Page"),
  73. selenium.getText("xPath=(//div[@class='portlet-body']/ul/li/a)[2]"));
  74. selenium.clickAt("xPath=(//div[@class='portlet-body']/ul/li/a)[2]",
  75. RuntimeVariables.replace("Site Map Test Page"));
  76. selenium.waitForPageToLoad("30000");
  77. loadRequiredJavaScriptModules();
  78. assertEquals(RuntimeVariables.replace("Site Map"),
  79. selenium.getText("//h1[@class='portlet-title']"));
  80. assertTrue(selenium.isVisible("//section[@class='portlet']"));
  81. selenium.open("/web/guest/home/");
  82. loadRequiredJavaScriptModules();
  83. for (int second = 0;; second++) {
  84. if (second >= 90) {
  85. fail("timeout");
  86. }
  87. try {
  88. if (selenium.isVisible("link=Site Map Test Page")) {
  89. break;
  90. }
  91. }
  92. catch (Exception e) {
  93. }
  94. Thread.sleep(1000);
  95. }
  96. selenium.clickAt("link=Site Map Test Page",
  97. RuntimeVariables.replace("Site Map Test Page"));
  98. selenium.waitForPageToLoad("30000");
  99. loadRequiredJavaScriptModules();
  100. assertEquals(RuntimeVariables.replace("Site Map Test Child Page"),
  101. selenium.getText("//div[@class='portlet-body']/ul/li/ul/li/a"));
  102. selenium.clickAt("//div[@class='portlet-body']/ul/li/ul/li/a",
  103. RuntimeVariables.replace("Site Map Test Child Page"));
  104. selenium.waitForPageToLoad("30000");
  105. loadRequiredJavaScriptModules();
  106. assertFalse(selenium.isElementPresent("//section[@class='portlet']"));
  107. }
  108. }