/portal-web/test/com/liferay/portalweb/portlet/webcontentdisplay/webcontent/localizewcwebcontenttemplatewcd/LocalizeWCWebContentTemplateWCDTest.java

https://github.com/lululiferay/liferay-portal · Java · 217 lines · 166 code · 35 blank · 16 comment · 19 complexity · 32a931c931becf1e850f716802914bf5 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.webcontentdisplay.webcontent.localizewcwebcontenttemplatewcd;
  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 LocalizeWCWebContentTemplateWCDTest extends BaseTestCase {
  21. public void testLocalizeWCWebContentTemplateWCD() throws Exception {
  22. int label = 1;
  23. while (label >= 1) {
  24. switch (label) {
  25. case 1:
  26. selenium.open("/web/guest/home/");
  27. for (int second = 0;; second++) {
  28. if (second >= 90) {
  29. fail("timeout");
  30. }
  31. try {
  32. if (selenium.isVisible(
  33. "link=Web Content Display Test Page")) {
  34. break;
  35. }
  36. }
  37. catch (Exception e) {
  38. }
  39. Thread.sleep(1000);
  40. }
  41. selenium.clickAt("link=Web Content Display Test Page",
  42. RuntimeVariables.replace("Web Content Display Test Page"));
  43. selenium.waitForPageToLoad("30000");
  44. for (int second = 0;; second++) {
  45. if (second >= 90) {
  46. fail("timeout");
  47. }
  48. try {
  49. if (selenium.isVisible("//img[@alt='Edit Web Content']")) {
  50. break;
  51. }
  52. }
  53. catch (Exception e) {
  54. }
  55. Thread.sleep(1000);
  56. }
  57. selenium.clickAt("//img[@alt='Edit Web Content']",
  58. RuntimeVariables.replace("Edit Web Content"));
  59. selenium.waitForPageToLoad("30000");
  60. assertEquals(RuntimeVariables.replace(
  61. "Hello World Localized Article"),
  62. selenium.getText("//h1[@class='header-title']"));
  63. assertEquals(RuntimeVariables.replace(
  64. "Web Content Localized Structure Name"),
  65. selenium.getText("//span[@class='structure-name-label']"));
  66. assertEquals(RuntimeVariables.replace(
  67. "Web Content Localized Template Name"),
  68. selenium.getText("//span[@class='template-name-label']"));
  69. assertTrue(selenium.isElementPresent(
  70. "//span[2]/div/span/span/span/input[2]"));
  71. boolean localizablePageNameChecked = selenium.isChecked(
  72. "//span[2]/div/span/span/span/input[2]");
  73. if (localizablePageNameChecked) {
  74. label = 2;
  75. continue;
  76. }
  77. selenium.clickAt("//span[2]/div/span/span/span/input[2]",
  78. RuntimeVariables.replace(""));
  79. case 2:
  80. assertTrue(selenium.isElementPresent(
  81. "//li[2]/span[2]/div/span/span/span/input[2]"));
  82. boolean localizablePageDescriptionChecked = selenium.isChecked(
  83. "//li[2]/span[2]/div/span/span/span/input[2]");
  84. if (localizablePageDescriptionChecked) {
  85. label = 3;
  86. continue;
  87. }
  88. selenium.clickAt("//li[2]/span[2]/div/span/span/span/input[2]",
  89. RuntimeVariables.replace(""));
  90. case 3:
  91. assertTrue(selenium.isChecked(
  92. "//span[2]/div/span/span/span/input[2]"));
  93. assertTrue(selenium.isChecked(
  94. "//li[2]/span[2]/div/span/span/span/input[2]"));
  95. Thread.sleep(5000);
  96. selenium.clickAt("//input[@value='Save as Draft']",
  97. RuntimeVariables.replace("Save as Draft"));
  98. selenium.waitForPageToLoad("30000");
  99. assertEquals(RuntimeVariables.replace("Status: Draft"),
  100. selenium.getText("//span[@class='workflow-status']"));
  101. assertEquals("Hello World Page Name",
  102. selenium.getValue("//input[@id='page-name']"));
  103. assertEquals("Hello World Page Description",
  104. selenium.getValue("//input[@id='page-description']"));
  105. assertEquals(RuntimeVariables.replace("Add Translation"),
  106. selenium.getText("//strong/a/span"));
  107. selenium.clickAt("//strong/a/span",
  108. RuntimeVariables.replace("Add Translation"));
  109. for (int second = 0;; second++) {
  110. if (second >= 90) {
  111. fail("timeout");
  112. }
  113. try {
  114. if (selenium.isVisible(
  115. "//div[@class='lfr-component lfr-menu-list']/ul/li[6]/a")) {
  116. break;
  117. }
  118. }
  119. catch (Exception e) {
  120. }
  121. Thread.sleep(1000);
  122. }
  123. assertEquals(RuntimeVariables.replace("Chinese (China)"),
  124. selenium.getText(
  125. "//div[@class='lfr-component lfr-menu-list']/ul/li[6]/a"));
  126. selenium.click(
  127. "//div[@class='lfr-component lfr-menu-list']/ul/li[6]/a");
  128. for (int second = 0;; second++) {
  129. if (second >= 90) {
  130. fail("timeout");
  131. }
  132. try {
  133. if (selenium.isVisible("//iframe[@id='_15_zh_CN']")) {
  134. break;
  135. }
  136. }
  137. catch (Exception e) {
  138. }
  139. Thread.sleep(1000);
  140. }
  141. selenium.selectFrame("//iframe[@id='_15_zh_CN']");
  142. for (int second = 0;; second++) {
  143. if (second >= 90) {
  144. fail("timeout");
  145. }
  146. try {
  147. if (selenium.isVisible("//input[@id='page-name']")) {
  148. break;
  149. }
  150. }
  151. catch (Exception e) {
  152. }
  153. Thread.sleep(1000);
  154. }
  155. selenium.type("//input[@id='page-name']",
  156. RuntimeVariables.replace(
  157. "\u4e16\u754c\u60a8\u597d Page Name"));
  158. selenium.type("//input[@id='page-description']",
  159. RuntimeVariables.replace(
  160. "\u4e16\u754c\u60a8\u597d Page Description"));
  161. selenium.clickAt("//input[@value='Save']",
  162. RuntimeVariables.replace("Save"));
  163. selenium.waitForPageToLoad("30000");
  164. selenium.selectFrame("relative=top");
  165. assertEquals(RuntimeVariables.replace("Chinese (China)"),
  166. selenium.getText(
  167. "//a[@class='lfr-token journal-article-translation-zh_CN']"));
  168. Thread.sleep(5000);
  169. selenium.clickAt("//input[@value='Publish']",
  170. RuntimeVariables.replace("Publish"));
  171. selenium.waitForPageToLoad("30000");
  172. assertEquals(RuntimeVariables.replace("Hello World Page Name"),
  173. selenium.getText("//td[@class='page-name']"));
  174. assertEquals(RuntimeVariables.replace(
  175. "Hello World Page Description"),
  176. selenium.getText("//td[@class='page-description']"));
  177. case 100:
  178. label = -1;
  179. }
  180. }
  181. }
  182. }