Search in sources :

Example 1 with ViewThemePage

use of org.xwiki.flamingo.test.po.ViewThemePage in project xwiki-platform by xwiki.

the class FlamingoThemeTest method createNewTheme.

/**
 * @since 6.3RC1
 */
@Test
public void createNewTheme() throws Exception {
    // Go to the presentation section of the administration
    AdministrationPage administrationPage = AdministrationPage.gotoPage();
    ThemesAdministrationSectionPage presentationAdministrationSectionPage = administrationPage.clickThemesSection();
    // Click on "manage color theme"
    presentationAdministrationSectionPage.manageColorThemes();
    ThemeApplicationWebHomePage themeApplicationWebHomePage = new ThemeApplicationWebHomePage();
    // Ensure the current theme is correct
    assertEquals("Charcoal", themeApplicationWebHomePage.getCurrentTheme());
    // Ensure the other themes are correct
    List<String> otherThemes = themeApplicationWebHomePage.getOtherThemes();
    assertTrue(otherThemes.contains("Marina"));
    assertTrue(otherThemes.contains("Garden"));
    assertTrue(otherThemes.contains("Kitty"));
    assertFalse(otherThemes.contains("Charcoal"));
    // Create a new theme
    EditThemePage editThemePage = themeApplicationWebHomePage.createNewTheme("Test");
    editThemePage.waitUntilPreviewIsLoaded();
    // First, disable auto refresh because it slows down the test
    // (and can even make it fails if the computer is slow)
    editThemePage.setAutoRefresh(false);
    // Set variables
    editThemePage.selectVariableCategory("Base colors");
    editThemePage.setVariableValue("xwiki-page-content-bg", "#ff0000");
    editThemePage.selectVariableCategory("Typography");
    editThemePage.setVariableValue("font-family-base", "Monospace");
    editThemePage.selectVariableCategory("Advanced");
    // Insert lessCode too
    editThemePage.setTextareaValue("lessCode", ".main{ color: #0000ff; }");
    // Save the theme
    editThemePage.clickSaveAndView();
    // Go back to the theme application
    themeApplicationWebHomePage = ThemeApplicationWebHomePage.gotoPage();
    // Set the new theme as current
    themeApplicationWebHomePage.useTheme("Test");
    // Verify that the new theme is used
    assertEquals("Test", themeApplicationWebHomePage.getCurrentTheme());
    // Look at the values
    assertEquals("rgba(255, 0, 0, 1)", themeApplicationWebHomePage.getPageBackgroundColor());
    assertEquals("monospace", themeApplicationWebHomePage.getFontFamily().toLowerCase());
    // Test 'lessCode' is correctly handled
    assertEquals("rgba(0, 0, 255, 1)", themeApplicationWebHomePage.getTextColor());
    // Switch back to Charcoal
    themeApplicationWebHomePage.useTheme("Charcoal");
    // Remove the theme
    ViewThemePage themePage = themeApplicationWebHomePage.seeTheme("Test");
    themePage.waitUntilPreviewIsLoaded();
    ConfirmationPage confirmationPage = themePage.delete();
    confirmationPage.confirmDeletePage().waitUntilIsTerminated();
}
Also used : ThemesAdministrationSectionPage(org.xwiki.administration.test.po.ThemesAdministrationSectionPage) AdministrationPage(org.xwiki.administration.test.po.AdministrationPage) ThemeApplicationWebHomePage(org.xwiki.flamingo.test.po.ThemeApplicationWebHomePage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) ViewThemePage(org.xwiki.flamingo.test.po.ViewThemePage) EditThemePage(org.xwiki.flamingo.test.po.EditThemePage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Aggregations

Test (org.junit.Test)1 AdministrationPage (org.xwiki.administration.test.po.AdministrationPage)1 ThemesAdministrationSectionPage (org.xwiki.administration.test.po.ThemesAdministrationSectionPage)1 EditThemePage (org.xwiki.flamingo.test.po.EditThemePage)1 ThemeApplicationWebHomePage (org.xwiki.flamingo.test.po.ThemeApplicationWebHomePage)1 ViewThemePage (org.xwiki.flamingo.test.po.ViewThemePage)1 AbstractTest (org.xwiki.test.ui.AbstractTest)1 ConfirmationPage (org.xwiki.test.ui.po.ConfirmationPage)1