001 // Copyright 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.html; 016 017 import org.apache.tapestry.BaseComponentTestCase; 018 import org.apache.tapestry.IBinding; 019 import org.apache.tapestry.IMarkupWriter; 020 import org.apache.tapestry.IRequestCycle; 021 import org.apache.tapestry.engine.IEngineService; 022 import org.apache.tapestry.engine.ILink; 023 import org.apache.tapestry.spec.ComponentSpecification; 024 import org.testng.annotations.Test; 025 026 /** 027 * Tests for the {@link org.apache.tapestry.html.Frame} component. 028 * 029 * @author Howard M. Lewis Ship 030 * @since 4.0 031 */ 032 @Test 033 public class FrameTest extends BaseComponentTestCase 034 { 035 036 public void testRender() 037 { 038 IEngineService pageService = newEngineService(); 039 ILink link = newLink(); 040 041 IMarkupWriter writer = newWriter(); 042 IRequestCycle cycle = newCycle(); 043 044 trainGetLink(pageService, cycle, false, "FramePage", link); 045 046 writer.beginEmpty("frame"); 047 048 trainGetURL(link, "<LinkURL>"); 049 050 writer.attribute("src", "<LinkURL>"); 051 052 writer.closeTag(); 053 054 replay(); 055 056 Frame frame = newInstance(Frame.class, new Object[] 057 { "pageService", pageService, "targetPage", "FramePage" }); 058 059 frame.renderComponent(writer, cycle); 060 061 verify(); 062 } 063 064 public void testRenderWithInformal() 065 { 066 IEngineService pageService = newEngineService(); 067 ILink link = newLink(); 068 069 IMarkupWriter writer = newWriter(); 070 IRequestCycle cycle = newCycle(); 071 072 trainGetLink(pageService, cycle, false, "FramePage", link); 073 074 writer.beginEmpty("frame"); 075 076 trainGetURL(link, "<LinkURL>"); 077 078 writer.attribute("src", "<LinkURL>"); 079 080 IBinding binding = newBinding("informal"); 081 082 writer.attribute("class", "informal"); 083 084 writer.closeTag(); 085 086 replay(); 087 088 Frame frame = newInstance(Frame.class, new Object[] 089 { "pageService", pageService, "targetPage", "FramePage", "specification", 090 new ComponentSpecification() }); 091 frame.setBinding("class", binding); 092 093 frame.renderComponent(writer, cycle); 094 095 verify(); 096 } 097 }