001    /**
002     * Copyright 2005-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package edu.samplu.krad.library.controls;
017    
018    import org.junit.Test;
019    import org.kuali.rice.testtools.selenium.SmokeTestBase;
020    
021    /**
022     * @author Kuali Rice Team (rice.collab@kuali.org)
023     */
024    public class DemoLibraryControlTextAreaSmokeTest extends SmokeTestBase {
025    
026        /**
027         * /kr-krad/kradsampleapp?viewId=Demo-TextAreaControl-View
028         */
029        public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-TextAreaControl-View";
030    
031        @Override
032        protected String getBookmarkUrl() {
033            return BOOKMARK_URL;
034        }
035    
036        @Override
037        protected void navigate() throws Exception {
038            waitAndClickById("Demo-LibraryLink", "");
039            waitAndClickByLinkText("Controls");
040            waitAndClickByLinkText("Text Area");
041        }
042    
043        protected void testLibraryControlTextAreaDefault() throws Exception {
044            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example1']/textarea[@name='inputField2' and @rows='3' and @cols='40']");
045        }
046        
047        protected void testLibraryControlTextAreaColsAndRowsSet() throws Exception {
048            waitAndClickByLinkText("Cols and Rows set");
049            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example2']/textarea[@name='inputField2' and @rows='5' and @cols='60']");
050        }
051        
052        protected void testLibraryControlTextAreaTextExpand() throws Exception {
053            waitAndClickByLinkText("Text expand");
054            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example3']/textarea[@name='inputField2' and @rows='3' and @cols='40']");
055            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example3']/a[@title='Expand']");
056        }
057        
058        protected void testLibraryControlTextAreaDisabled() throws Exception {
059            waitAndClickByLinkText("Disabled");
060            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example4']/textarea[@name='inputField2' and @rows='3' and @cols='40' and @disabled]");
061        }
062        
063        protected void testLibraryControlTextAreaWatermarkText() throws Exception {
064            waitAndClickByLinkText("WatermarkText");
065            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example7']/textarea[@name='inputField2' and @rows='3' and @cols='40' and @placeholder='watermark text ']");
066        }
067        
068        protected void testLibraryControlTextAreaDisableOnKeyEvent() throws Exception {
069            waitAndClickByLinkText("Disable on Key event");
070            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example8']/textarea[@name='inputField2' and @rows='3' and @cols='40' and @disabled]");
071            waitAndTypeByXpath("//div[@data-parent='Demo-TextAreaControl-Example8']/textarea[@name='inputField1']","a");
072            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example8']/textarea[@name='inputField2' and @rows='3' and @cols='40']");
073        }
074        
075        protected void testLibraryControlTextAreaEnableWhenChanged() throws Exception {
076            waitAndClickByLinkText("Enable when changed");
077            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example9']/textarea[@name='inputField4' and @rows='3' and @cols='40' and @disabled]");
078            waitAndTypeByXpath("//div[@data-parent='Demo-TextAreaControl-Example9']/textarea[@name='inputField3']","a");
079            waitAndClickByLinkText("Usage");
080            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example9']/textarea[@name='inputField4' and @rows='3' and @cols='40']");
081        }
082        
083        protected void testLibraryControlTextAreaDisableWhenChanged() throws Exception {
084            waitAndClickByLinkText("Disable when changed");
085            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example10']/textarea[@name='inputField6' and @rows='3' and @cols='40']");
086            waitAndTypeByXpath("//div[@data-parent='Demo-TextAreaControl-Example10']/textarea[@name='inputField5']","a");
087            waitAndClickByLinkText("Usage");
088            assertElementPresentByXpath("//div[@data-parent='Demo-TextAreaControl-Example10']/textarea[@name='inputField6' and @rows='3' and @cols='40' and @disabled]");
089        }
090        
091        @Test
092        public void testControlTextAreaBookmark() throws Exception {
093            testLibraryControlTextAreaDefault();
094            testLibraryControlTextAreaColsAndRowsSet();
095            testLibraryControlTextAreaTextExpand();
096            testLibraryControlTextAreaDisabled();
097            testLibraryControlTextAreaWatermarkText();
098            testLibraryControlTextAreaDisableOnKeyEvent();
099            testLibraryControlTextAreaEnableWhenChanged();
100            testLibraryControlTextAreaDisableWhenChanged();
101            passed();
102        }
103    
104        @Test
105        public void testControlTextAreaNav() throws Exception {
106            testLibraryControlTextAreaDefault();
107            testLibraryControlTextAreaColsAndRowsSet();
108            testLibraryControlTextAreaTextExpand();
109            testLibraryControlTextAreaDisabled();
110            testLibraryControlTextAreaWatermarkText();
111            testLibraryControlTextAreaDisableOnKeyEvent();
112            testLibraryControlTextAreaEnableWhenChanged();
113            testLibraryControlTextAreaDisableWhenChanged();
114            passed();
115        }  
116    }