1*eba4d44aSLiu Zhe /************************************************************** 2*eba4d44aSLiu Zhe * 3*eba4d44aSLiu Zhe * Licensed to the Apache Software Foundation (ASF) under one 4*eba4d44aSLiu Zhe * or more contributor license agreements. See the NOTICE file 5*eba4d44aSLiu Zhe * distributed with this work for additional information 6*eba4d44aSLiu Zhe * regarding copyright ownership. The ASF licenses this file 7*eba4d44aSLiu Zhe * to you under the Apache License, Version 2.0 (the 8*eba4d44aSLiu Zhe * "License"); you may not use this file except in compliance 9*eba4d44aSLiu Zhe * with the License. You may obtain a copy of the License at 10*eba4d44aSLiu Zhe * 11*eba4d44aSLiu Zhe * http://www.apache.org/licenses/LICENSE-2.0 12*eba4d44aSLiu Zhe * 13*eba4d44aSLiu Zhe * Unless required by applicable law or agreed to in writing, 14*eba4d44aSLiu Zhe * software distributed under the License is distributed on an 15*eba4d44aSLiu Zhe * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*eba4d44aSLiu Zhe * KIND, either express or implied. See the License for the 17*eba4d44aSLiu Zhe * specific language governing permissions and limitations 18*eba4d44aSLiu Zhe * under the License. 19*eba4d44aSLiu Zhe * 20*eba4d44aSLiu Zhe *************************************************************/ 21*eba4d44aSLiu Zhe package fvt.uno.sw.page; 22*eba4d44aSLiu Zhe 23*eba4d44aSLiu Zhe import static org.openoffice.test.common.Testspace.*; 24*eba4d44aSLiu Zhe 25*eba4d44aSLiu Zhe import java.io.File; 26*eba4d44aSLiu Zhe import java.util.Arrays; 27*eba4d44aSLiu Zhe import java.util.Collection; 28*eba4d44aSLiu Zhe 29*eba4d44aSLiu Zhe import org.junit.After; 30*eba4d44aSLiu Zhe import org.junit.Before; 31*eba4d44aSLiu Zhe import org.junit.Test; 32*eba4d44aSLiu Zhe import org.junit.Ignore; 33*eba4d44aSLiu Zhe import org.junit.Assert; 34*eba4d44aSLiu Zhe import org.junit.runner.RunWith; 35*eba4d44aSLiu Zhe import org.junit.runners.Parameterized; 36*eba4d44aSLiu Zhe import org.junit.runners.Parameterized.Parameters; 37*eba4d44aSLiu Zhe 38*eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil; 39*eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp; 40*eba4d44aSLiu Zhe 41*eba4d44aSLiu Zhe import testlib.uno.SWUtil; 42*eba4d44aSLiu Zhe import com.sun.star.text.XTextDocument; 43*eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 44*eba4d44aSLiu Zhe import com.sun.star.lang.XComponent; 45*eba4d44aSLiu Zhe import com.sun.star.table.BorderLine; 46*eba4d44aSLiu Zhe 47*eba4d44aSLiu Zhe /** 48*eba4d44aSLiu Zhe * test page's back graphic, 49*eba4d44aSLiu Zhe * test page footer/header's back graphic. 50*eba4d44aSLiu Zhe * 51*eba4d44aSLiu Zhe */ 52*eba4d44aSLiu Zhe @RunWith(Parameterized.class) 53*eba4d44aSLiu Zhe public class CheckBackGraphic { 54*eba4d44aSLiu Zhe UnoApp unoApp = new UnoApp(); 55*eba4d44aSLiu Zhe XTextDocument textDocument = null; 56*eba4d44aSLiu Zhe File temp = null; 57*eba4d44aSLiu Zhe String tempFilePathODT = ""; 58*eba4d44aSLiu Zhe String tempFilePathDOC = ""; 59*eba4d44aSLiu Zhe 60*eba4d44aSLiu Zhe private String onProperty = ""; 61*eba4d44aSLiu Zhe private String backGraphicURLProperty = ""; 62*eba4d44aSLiu Zhe 63*eba4d44aSLiu Zhe private String backGraphicPath = ""; 64*eba4d44aSLiu Zhe private String backGraphicURL = ""; 65*eba4d44aSLiu Zhe 66*eba4d44aSLiu Zhe CheckBackGraphic(String onProperty, String backGraphicURLProperty, String backGraphicPath)67*eba4d44aSLiu Zhe public CheckBackGraphic(String onProperty, String backGraphicURLProperty, String backGraphicPath){ 68*eba4d44aSLiu Zhe this.onProperty = onProperty; 69*eba4d44aSLiu Zhe this.backGraphicURLProperty = backGraphicURLProperty; 70*eba4d44aSLiu Zhe 71*eba4d44aSLiu Zhe this.backGraphicPath = backGraphicPath; 72*eba4d44aSLiu Zhe } 73*eba4d44aSLiu Zhe 74*eba4d44aSLiu Zhe @Parameters data()75*eba4d44aSLiu Zhe public static Collection<Object[]> data(){ 76*eba4d44aSLiu Zhe Object[][] params = new Object[][]{ 77*eba4d44aSLiu Zhe {"FooterIsOn", "BackGraphicURL", "uno/sw/page/BackGraphic1.jpg"}, 78*eba4d44aSLiu Zhe {"FooterIsOn", "BackGraphicURL", "uno/sw/page/BackGraphic2.jpg"}, 79*eba4d44aSLiu Zhe {"FooterIsOn", "FooterBackGraphicURL", "uno/sw/page/BackGraphic1.jpg"}, 80*eba4d44aSLiu Zhe {"FooterIsOn", "FooterBackGraphicURL", "uno/sw/page/BackGraphic2.jpg"}, 81*eba4d44aSLiu Zhe {"HeaderIsOn", "HeaderBackGraphicURL", "uno/sw/page/BackGraphic1.jpg"}, 82*eba4d44aSLiu Zhe {"HeaderIsOn", "HeaderBackGraphicURL", "uno/sw/page/BackGraphic2.jpg"} 83*eba4d44aSLiu Zhe }; 84*eba4d44aSLiu Zhe return Arrays.asList(params); 85*eba4d44aSLiu Zhe } 86*eba4d44aSLiu Zhe 87*eba4d44aSLiu Zhe /** 88*eba4d44aSLiu Zhe * test header/footer's back color and back graphic. 89*eba4d44aSLiu Zhe * @throws Exception 90*eba4d44aSLiu Zhe */ 91*eba4d44aSLiu Zhe @Test testFooterHeaderBackground()92*eba4d44aSLiu Zhe public void testFooterHeaderBackground() throws Exception 93*eba4d44aSLiu Zhe { 94*eba4d44aSLiu Zhe String graphicUrl = FileUtil.getUrl(prepareData(backGraphicPath)); 95*eba4d44aSLiu Zhe backGraphicURL = graphicUrl; 96*eba4d44aSLiu Zhe XComponent xComponent = unoApp.newDocument("swriter"); 97*eba4d44aSLiu Zhe //turn on header/footer 98*eba4d44aSLiu Zhe SWUtil.setDefaultPageStyleProperty(xComponent, onProperty, new Boolean(true)); 99*eba4d44aSLiu Zhe SWUtil.setDefaultPageStyleProperty(xComponent, backGraphicURLProperty, backGraphicURL); 100*eba4d44aSLiu Zhe 101*eba4d44aSLiu Zhe //save as ODT and reopen, get back color and back graphic 102*eba4d44aSLiu Zhe unoApp.saveDocument(xComponent, tempFilePathODT); 103*eba4d44aSLiu Zhe unoApp.closeDocument(xComponent); 104*eba4d44aSLiu Zhe xComponent = unoApp.loadDocument(tempFilePathODT); 105*eba4d44aSLiu Zhe 106*eba4d44aSLiu Zhe String graphic = (String)SWUtil.getDefaultPageStyleProperty(xComponent, backGraphicURLProperty); 107*eba4d44aSLiu Zhe 108*eba4d44aSLiu Zhe 109*eba4d44aSLiu Zhe Assert.assertEquals("ODT:" + backGraphicURLProperty, backGraphicURL, graphic); 110*eba4d44aSLiu Zhe 111*eba4d44aSLiu Zhe unoApp.closeDocument(xComponent); 112*eba4d44aSLiu Zhe } 113*eba4d44aSLiu Zhe 114*eba4d44aSLiu Zhe 115*eba4d44aSLiu Zhe 116*eba4d44aSLiu Zhe /** 117*eba4d44aSLiu Zhe * @throws java.lang.Exception 118*eba4d44aSLiu Zhe */ 119*eba4d44aSLiu Zhe @Before setUp()120*eba4d44aSLiu Zhe public void setUp() throws Exception { 121*eba4d44aSLiu Zhe unoApp.start(); 122*eba4d44aSLiu Zhe 123*eba4d44aSLiu Zhe FileUtil.deleteFile(getPath("temp")); 124*eba4d44aSLiu Zhe temp = new File(getPath("temp")); 125*eba4d44aSLiu Zhe temp.mkdirs(); 126*eba4d44aSLiu Zhe 127*eba4d44aSLiu Zhe tempFilePathODT = temp + "/tempFilePathODT.odt"; 128*eba4d44aSLiu Zhe tempFilePathDOC = temp + "/tempFilePathDOC.doc"; 129*eba4d44aSLiu Zhe } 130*eba4d44aSLiu Zhe 131*eba4d44aSLiu Zhe @After tearDown()132*eba4d44aSLiu Zhe public void tearDown() throws Exception { 133*eba4d44aSLiu Zhe unoApp.close(); 134*eba4d44aSLiu Zhe } 135*eba4d44aSLiu Zhe 136*eba4d44aSLiu Zhe 137*eba4d44aSLiu Zhe } 138