001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.test.theme;
023:
024: import org.jboss.portal.test.framework.driver.DriverResponse;
025: import org.jboss.portal.test.theme.model.PageObject;
026: import org.jboss.portal.test.theme.model.RegionObject;
027: import org.jboss.portal.test.theme.model.RenderedObject;
028: import org.jboss.portal.test.theme.model.WindowObject;
029: import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
030:
031: import java.util.Collections;
032:
033: /**
034: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
035: * @version $Revision: 8784 $
036: */
037: public class MyTest extends DynaTest {
038:
039: /** . */
040: private DynaTestContext dynaTestContext;
041:
042: public MyTest(String id) {
043: super (id);
044: }
045:
046: public void init(DynaTestContext dynaTestContext) {
047: PageObject page = dynaTestContext.getPage();
048:
049: //
050: RegionObject regionA = page.createRegion("RegionA");
051: regionA.setRenderOptions(DynaRenderOptions.getOptions(
052: Boolean.FALSE, Boolean.FALSE));
053:
054: //
055: RegionObject regionB = page.createRegion("RegionB");
056: regionB.setRenderOptions(DynaRenderOptions.getOptions(
057: Boolean.FALSE, Boolean.TRUE));
058:
059: //
060: RegionObject regionC = page.createRegion("RegionC");
061: regionC.setRenderOptions(DynaRenderOptions.getOptions(
062: Boolean.TRUE, Boolean.FALSE));
063:
064: //
065: RegionObject regionD = page.createRegion("RegionD");
066: regionD.setRenderOptions(DynaRenderOptions.getOptions(
067: Boolean.TRUE, Boolean.TRUE));
068:
069: //
070: regionA.addWindow("0");
071: regionA.addWindow("1");
072: regionB.addWindow("2");
073: regionB.addWindow("3");
074: regionC.addWindow("4");
075: regionC.addWindow("5");
076: regionD.addWindow("6");
077: regionD.addWindow("7");
078:
079: //
080: this .dynaTestContext = dynaTestContext;
081: }
082:
083: public DriverResponse invoke(RequestContext requestContext) {
084: TestPhase phase = requestContext.getPhase();
085: if (phase.getLifeCycle() == TestPhase.RENDER_LIFE_CYCLE) {
086: switch (phase.getCount()) {
087: case 0:
088: WindowObject window = dynaTestContext.getPage()
089: .getWindow("7");
090: ObjectURL url = requestContext.createURL(window);
091: url.setParameter("abc", "def");
092: String markup = "<a id=\"bilto\" href=\"" + url
093: + "\">Click Me</a>";
094: window.setMarkup(markup);
095: break;
096: case 1:
097: window = dynaTestContext.getPage().getWindow("7");
098: url = requestContext.createURL(window);
099: url.setParameter("abc", "ghi");
100: markup = "<a id=\"bilto\" href=\"" + url
101: + "\">Click Me</a>";
102: window.setMarkup(markup);
103: break;
104: case 2:
105: break;
106: default:
107: fail();
108: }
109: } else {
110: switch (phase.getCount()) {
111: case 1:
112: RenderedObject target = requestContext.getTarget();
113: assertNotNull(target);
114: assertTrue(target instanceof WindowObject);
115: WindowObject window = (WindowObject) target;
116: assertEquals("7", window.getId());
117: assertTrue(requestContext.isAsync());
118: assertEquals(Collections.singletonMap("abc", "def"),
119: requestContext.getParameterMap());
120: break;
121: case 2:
122: target = requestContext.getTarget();
123: assertNotNull(target);
124: assertTrue(target instanceof WindowObject);
125: window = (WindowObject) target;
126: assertEquals("7", window.getId());
127: assertTrue(requestContext.isAsync());
128: assertEquals(Collections.singletonMap("abc", "ghi"),
129: requestContext.getParameterMap());
130: break;
131: default:
132: fail();
133: }
134: }
135:
136: //
137: return null;
138: }
139: }
|