/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package com.xpn.xwiki.it.selenium;

import junit.framework.Test;

import com.xpn.xwiki.it.selenium.framework.AbstractXWikiTestCase;
import com.xpn.xwiki.it.selenium.framework.AlbatrossSkinExecutor;
import com.xpn.xwiki.it.selenium.framework.XWikiTestSuite;

/**
 * Test the Panel feature. Note that some panels tests are also done by the
 * {@link com.xpn.xwiki.it.selenium.PanelWizardTest} test case class.
 *
 * @version $Id: $
 * @since 1.6M1
 */
public class PanelsTest extends AbstractXWikiTestCase
{
    public static Test suite()
    {
        XWikiTestSuite suite = new XWikiTestSuite("Verify the XWiki Panel feature");
        suite.addTestSuite(PanelsTest.class, AlbatrossSkinExecutor.class);
        return suite;
    }

    @Override
    public void setUp() throws Exception
    {
        super.setUp();
        loginAsAdmin();
    }

    /**
     * This method makes the following tests:
     * 
     * <ul>
     * <li>Opens the Panels page for XWiki instance.</li>
     * <li>Creates a panel - setting the title.</li>
     * <li>Completes the form with details for the newly created panel.</li>
     * <li>Goes to preview and pushes the button save and continue.</li>
     * <li>Completes the form and pushes the save&view button.</li>
     * <li>Goes back to panels list and check for the presence of the newly created panel.</li>
     * </ul>
     */
    public void testCreatePanel()
    {
        open("Panels", "WebHome");
        setFieldValue("title", "Thesecondpaneltobecreated");
        clickLinkWithXPath("//input[@value='Create']");
        setFieldValue("Panels.PanelClass_0_description", "Tester panel");
        setFieldValue("Panels.PanelClass_0_content", "#panelheader(\"Test panel\")\nTest Panel\n#panelfooter()");
        clickLinkWithLocator("formactionsave");
        open("Panels", "WebHome");
        assertElementPresent("//a[text()='Thesecondpaneltobecreated']");
    }
}

@@ -1297,17 +1297,18 @@
 lass.%0A *
+ 
 %0A
-
  * @vers
@@ -1793,16 +1793,8 @@
 ts:%0A
-     * %0A
     
@@ -2279,32 +2279,50 @@
 tePanel()%0A    %7B%0A
+        try %7B%0A    
         open(%22Pa
@@ -2340,32 +2340,36 @@
 Home%22);%0A        
+    
 setFieldValue(%22t
@@ -2367,17 +2367,22 @@
 dValue(%22
-t
+panelT
 itle%22, %22
@@ -2406,24 +2406,28 @@
 ecreated%22);%0A
+    
         clic
@@ -2470,32 +2470,36 @@
 te'%5D%22);%0A        
+    
 setFieldValue(%22P
@@ -2544,24 +2544,28 @@
 er panel%22);%0A
+    
         setF
@@ -2666,32 +2666,36 @@
 er()%22);%0A        
+    
 clickLinkWithLoc
@@ -2714,24 +2714,28 @@
 tionsave%22);%0A
+    
         open
@@ -2765,16 +2765,20 @@
         
+    
 assertEl
@@ -2830,20 +2830,995 @@
 reated'%5D%22);%0A
+        %7D finally %7B%0A            deletePage(%22Panels%22, %22Thesecondpaneltobecreated%22);%0A        %7D%0A    %7D%0A%0A    /**%0A     * This method makes the following tests:%0A     * %3Cul%3E%0A     * %3Cli%3EOpens the Panels page for XWiki instance.%3C/li%3E%0A     * %3Cli%3ECreates a panel - setting a title with special characters ('$&/%5C?#).%3C/li%3E%0A     * %3Cli%3E...Checking that no error occurred%3C/li%3E%0A     * %3Cli%3EGoes back to panels list and check for the presence of the newly created panel.%3C/li%3E%0A     * %3C/ul%3E%0A     */%0A    public void testCreatePanelWithSpecialSymbols()%0A    %7B%0A        String title = %22Is # & %5Cu0163 'triky%5C%22? c:%5C%5Cwindows /root $util%22;%0A        try %7B%0A            open(%22Panels%22, %22WebHome%22);%0A            getSelenium().setSpeed(%224000%22);%0A            setFieldValue(%22panelTitle%22, title);%0A            clickLinkWithXPath(%22//input%5B@value='Create'%5D%22);%0A            clickLinkWithLocator(%22formactionsave%22);%0A            assertTextPresent(title);%0A        %7D finally %7B%0A            deletePage(%22Panels%22, title);%0A        %7D%0A
     %7D%0A%7D%0A

Create Panel should not depend on a skin file Adapting test