incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1388777 - in /incubator/ooo/trunk/test/testuno/source: testcase/uno/sc/chart/ testlib/uno/
Date Sat, 22 Sep 2012 11:40:01 GMT
Author: liuzhe
Date: Sat Sep 22 11:40:01 2012
New Revision: 1388777

URL: http://svn.apache.org/viewvc?rev=1388777&view=rev
Log:
#120973 - [testUNO]Refine chart utility methond, add test cases for Chart title, DataLabel, Grid, Trendline, MeanValue, Y Error Bar.
Patch By: Zhu Shan <shanzhu33@gmail.com>
Review By: Liu Zhe <aliuzhe@gmail.com>

Added:
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartDataLabel.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartGrid.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartMeanValueLine.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTitle.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTrendline.java   (with props)
    incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartYErrorBar.java   (with props)
Modified:
    incubator/ooo/trunk/test/testuno/source/testlib/uno/SCUtil.java

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartDataLabel.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartDataLabel.java?rev=1388777&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartDataLabel.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartDataLabel.java Sat Sep 22 11:40:01 2012
@@ -0,0 +1,180 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+package testcase.uno.sc.chart;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SCUtil;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.CellRangeAddress;
+
+/**
+ *  Check different types of chart data labels can be applied and saved
+ * 
+ */
+@RunWith(value = Parameterized.class)
+public class ChartDataLabel {
+
+	private int labelType;
+	private String inputType;
+	private double[][] numberData;	
+	private String fileType;
+	
+	private static final UnoApp unoApp = new UnoApp();
+	
+	XComponent scComponent = null;
+	XSpreadsheetDocument scDocument = null;
+	
+	@Parameters
+	public static Collection<Object[]> data() throws Exception {
+		double[][] numberData1 = {
+				{1, 2, 3, 4},
+				{2, 4.3, 5, 8},
+				{4, 2, 3, 1},
+				{1, -1, 0, -3}
+		};
+
+		return Arrays.asList(new Object[][] {
+			{0, "com.sun.star.chart.XYDiagram", numberData1, "ods"}, // no label
+			{1, "com.sun.star.chart.PieDiagram", numberData1, "ods"}, // show number
+			{2, "com.sun.star.chart.BarDiagram", numberData1, "ods"}, // show percentage
+			{4, "com.sun.star.chart.LineDiagram", numberData1, "ods"}, // show category name
+			{16, "com.sun.star.chart.BarDiagram", numberData1, "ods"}, // check legend symbol (won't shown on UI)
+			{3, "com.sun.star.chart.DonutDiagram", numberData1, "ods"}, // show number & percentage
+			{5, "com.sun.star.chart.BubbleDiagram", numberData1, "ods"}, // show number & category name
+			{6, "com.sun.star.chart.NetDiagram", numberData1, "ods"}, // show percentage & category name
+			{7, "com.sun.star.chart.BarDiagram", numberData1, "ods"}, // show number & percentage & category name
+			{17, "com.sun.star.chart.LineDiagram", numberData1, "ods"}, // show number & legend symbol
+			{18, "com.sun.star.chart.XYDiagram", numberData1, "ods"}, // show percentage & legend symbol
+			{19, "com.sun.star.chart.BarDiagram", numberData1, "ods"}, // show number & percentage & legend symbol
+			{20, "com.sun.star.chart.NetDiagram", numberData1, "ods"}, // show category name & legend symbol
+			{21, "com.sun.star.chart.AreaDiagram", numberData1, "ods"}, // show number & Category name & legend symbol
+			{22, "com.sun.star.chart.BarDiagram", numberData1, "ods"}, // show percentage & Category name & legend symbol
+			{23, "com.sun.star.chart.BarDiagram", numberData1, "ods"}, // show number & percentage & & Category name & legend symbol
+			{0, "com.sun.star.chart.BarDiagram", numberData1, "xls"}, 
+			{1, "com.sun.star.chart.PieDiagram", numberData1, "xls"}, 
+			{4, "com.sun.star.chart.LineDiagram", numberData1, "xls"},
+			{5, "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+			{17, "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+			{20, "com.sun.star.chart.BubbleDiagram", numberData1, "xls"},
+			{21, "com.sun.star.chart.BarDiagram", numberData1, "xls"}
+		});
+	}
+	
+	public ChartDataLabel(int labelType, String inputType, double[][] numberData, String fileType) {
+		this.labelType = labelType;
+		this.inputType = inputType;
+		this.numberData = numberData;
+		this.fileType = fileType;
+	}
+	
+	
+	@Before
+	public void setUp() throws Exception {
+		scComponent = unoApp.newDocument("scalc");
+		scDocument = SCUtil.getSCDocument(scComponent);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.closeDocument(scComponent);
+		
+	}
+	
+	@BeforeClass
+	public static void setUpConnection() throws Exception {
+		unoApp.start();
+	}
+
+	@AfterClass
+	public static void tearDownConnection() throws InterruptedException, Exception {
+		unoApp.close();
+		SCUtil.clearTempDir();	
+	}
+	
+	/**
+	 * Enable different types of data labels in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a chart.
+	 * 3. Enable different types of data labels for all data series in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the chart data label setting.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateDataLabel() throws Exception {
+		String fileName = "testCreateDataLabel";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		int result = 0;	
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		
+		SCUtil.setProperties(xChartDocument.getDiagram(), "DataCaption", labelType);
+
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		result = ((Integer) SCUtil.getProperties(xChartDocument.getDiagram(), "DataCaption")).intValue();
+		SCUtil.closeFile(scDocument);
+		
+		assertEquals("Incorrect chart data label types got in ." + fileType + " file.", labelType, result, 0);
+
+	}
+	
+}
\ No newline at end of file

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartDataLabel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartGrid.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartGrid.java?rev=1388777&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartGrid.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartGrid.java Sat Sep 22 11:40:01 2012
@@ -0,0 +1,286 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+package testcase.uno.sc.chart;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SCUtil;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.chart.XDiagram;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.CellRangeAddress;
+
+/**
+ *  Check Grids in chart can be applied and saved
+ * 
+ */
+@RunWith(value = Parameterized.class)
+public class ChartGrid {
+
+	private Boolean[] majorGrids;
+	private Boolean[] minorGrids;
+	private String inputType;
+	private double[][] numberData;	
+	private String fileType;
+	
+	private static final UnoApp unoApp = new UnoApp();
+	
+	XComponent scComponent = null;
+	XSpreadsheetDocument scDocument = null;
+	
+	@Parameters
+	public static Collection<Object[]> data() throws Exception {
+		double[][] numberData1 = {
+				{10, 20, 30, 40},
+				{20, 40.3, 50, 80},
+				{40, 20, 30, 10},
+				{10, -10, 0, -30}
+		};
+		Boolean[][] gridsList = {
+				{false, false, false}, //[0] no grid
+				{true, false, false}, // [1] X 
+				{false, true, false}, // [2] Y
+				{true, true, false}, // [3] X & Y
+				{true, true, true}, // [4] X & Y & Z
+				{false, false, true}, // [5] Z
+				{false, true, true}, // [6] Y & Z
+				{true, false, true} // [7] X & Z
+		};
+
+		return Arrays.asList(new Object[][] {
+			{gridsList[0], null, "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{gridsList[2], gridsList[3], "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{gridsList[2], gridsList[4], "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{gridsList[6], gridsList[7], "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{gridsList[1], gridsList[5], "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{gridsList[4], gridsList[4], "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			
+			{gridsList[0], null, "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+			{gridsList[2], gridsList[3], "com.sun.star.chart.BarDiagram", numberData1, "xls"}
+//			{null, gridsList[4], "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+//			{gridsList[6], gridsList[7], "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+//			{gridsList[1], gridsList[5], "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+//			{gridsList[4], gridsList[4], "com.sun.star.chart.BarDiagram", numberData1, "xls"}
+		
+		});
+	}
+	
+	public ChartGrid(Boolean[] majorGrids, Boolean[] minorGrids, String inputType, double[][] numberData, String fileType) {
+		this.majorGrids = majorGrids;
+		this.minorGrids = minorGrids;
+		this.inputType = inputType;
+		this.numberData = numberData;
+		this.fileType = fileType;
+	}
+		
+	@Before
+	public void setUp() throws Exception {
+		scComponent = unoApp.newDocument("scalc");
+		scDocument = SCUtil.getSCDocument(scComponent);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.closeDocument(scComponent);
+		
+	}
+	
+	@BeforeClass
+	public static void setUpConnection() throws Exception {
+		unoApp.start();
+	}
+
+	@AfterClass
+	public static void tearDownConnection() throws InterruptedException, Exception {
+		unoApp.close();
+		SCUtil.clearTempDir();	
+	}
+	
+	/**
+	 * Enable different types of grids in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a 2D chart.
+	 * 3. Enable grids of X/Y axis in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the grid setting.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateXYGrid() throws Exception {
+		String fileName = "testCreateXYGrid";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		Boolean[][] expected = {
+				{false, true, false},
+				{false, false, false}
+		};
+		Boolean[][] results = {
+				{false, false, false},
+				{false, false, false}
+		};	
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		XDiagram xDiagram = xChartDocument.getDiagram(); 
+		
+		if (majorGrids != null) {
+			SCUtil.setProperties(xDiagram, "HasXAxisGrid", majorGrids[0]);
+			SCUtil.setProperties(xDiagram, "HasYAxisGrid", majorGrids[1]);
+			expected[0][0] = majorGrids[0];
+			expected[0][1] = majorGrids[1];
+		}
+		if (minorGrids != null) {
+			SCUtil.setProperties(xDiagram, "HasXAxisHelpGrid", minorGrids[0]);
+			SCUtil.setProperties(xDiagram, "HasYAxisHelpGrid", minorGrids[1]);
+			expected[1][0] = minorGrids[0];
+			expected[1][1] = minorGrids[1];
+		}
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		xDiagram = xChartDocument.getDiagram(); 
+		results[0][0] = (Boolean) SCUtil.getProperties(xDiagram, "HasXAxisGrid");
+		results[0][1] = (Boolean) SCUtil.getProperties(xDiagram, "HasYAxisGrid");
+		results[1][0] = (Boolean) SCUtil.getProperties(xDiagram, "HasXAxisHelpGrid");
+		results[1][1] = (Boolean) SCUtil.getProperties(xDiagram, "HasYAxisHelpGrid");
+		
+		SCUtil.closeFile(scDocument);
+		
+		assertArrayEquals("Incorrect chart grids got in ." + fileType + " file.", expected, results);
+
+	}
+	
+	/** 
+	 * Enable different types of grids in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a 3D chart.
+	 * 3. Enable grids of X/Y/Z axes in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the grid setting.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateXYZGrid() throws Exception {
+		String fileName = "testCreateXYZGrid";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		Boolean[][] expected = {
+				{false, true, false},
+				{false, false, false}
+		};
+		Boolean[][] results = {
+				{false, false, false},
+				{false, false, false}
+		};	
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		SCUtil.setProperties(xChartDocument.getDiagram(), "Dim3D", true);
+		XDiagram xDiagram = xChartDocument.getDiagram();
+		
+		if (majorGrids != null) {
+			SCUtil.setProperties(xDiagram, "HasXAxisGrid", majorGrids[0]);
+			SCUtil.setProperties(xDiagram, "HasYAxisGrid", majorGrids[1]);
+			SCUtil.setProperties(xDiagram, "HasZAxisGrid", majorGrids[2]);
+			expected[0][0] = majorGrids[0];
+			expected[0][1] = majorGrids[1];
+			expected[0][2] = majorGrids[2];
+		}
+		if (minorGrids != null) {
+			SCUtil.setProperties(xDiagram, "HasXAxisHelpGrid", minorGrids[0]);
+			SCUtil.setProperties(xDiagram, "HasYAxisHelpGrid", minorGrids[1]);
+			SCUtil.setProperties(xDiagram, "HasZAxisHelpGrid", minorGrids[2]);
+			expected[1][0] = minorGrids[0];
+			expected[1][1] = minorGrids[1];
+			expected[1][2] = minorGrids[2];
+		}
+
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		xDiagram = xChartDocument.getDiagram(); 
+		results[0][0] = (Boolean) SCUtil.getProperties(xDiagram, "HasXAxisGrid");
+		results[0][1] = (Boolean) SCUtil.getProperties(xDiagram, "HasYAxisGrid");
+		results[0][2] = (Boolean) SCUtil.getProperties(xDiagram, "HasZAxisGrid");
+		results[1][0] = (Boolean) SCUtil.getProperties(xDiagram, "HasXAxisHelpGrid");
+		results[1][1] = (Boolean) SCUtil.getProperties(xDiagram, "HasYAxisHelpGrid");
+		results[1][2] = (Boolean) SCUtil.getProperties(xDiagram, "HasZAxisHelpGrid");
+
+		SCUtil.closeFile(scDocument);
+		
+		assertArrayEquals("Incorrect chart grids got in ." + fileType + " file.", expected, results);
+
+	}
+	
+}
\ No newline at end of file

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartGrid.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartMeanValueLine.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartMeanValueLine.java?rev=1388777&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartMeanValueLine.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartMeanValueLine.java Sat Sep 22 11:40:01 2012
@@ -0,0 +1,177 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+package testcase.uno.sc.chart;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SCUtil;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.chart.XDiagram;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.CellRangeAddress;
+
+/**
+ *  Check mean value line in chart can be applied and saved
+ * 
+ */
+@RunWith(value = Parameterized.class)
+public class ChartMeanValueLine {
+
+	private Boolean expected;
+	private Boolean meanValueLine;
+	private String inputType;
+	private double[][] numberData;	
+	private String fileType;
+	
+	private static final UnoApp unoApp = new UnoApp();
+	
+	XComponent scComponent = null;
+	XSpreadsheetDocument scDocument = null;
+	
+	@Parameters
+	public static Collection<Object[]> data() throws Exception {
+		double[][] numberData1 = {
+				{10, 20, 30, 40},
+				{20, 40.3, 50, 80},
+				{40, 20, 30, 10},
+				{10, -10, 0, -30}
+		};
+
+		return Arrays.asList(new Object[][] {
+			{true, true, "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{true, true, "com.sun.star.chart.LineDiagram", numberData1, "ods"},
+			{true, true, "com.sun.star.chart.AreaDiagram", numberData1, "ods"},
+			{true, true, "com.sun.star.chart.XYDiagram", numberData1, "ods"},
+			
+			{false, true, "com.sun.star.chart.BarDiagram", numberData1, "xls"}, //Excel does not support this property, save as .xls, the setting will be lost.
+			{false, true, "com.sun.star.chart.LineDiagram", numberData1, "xls"},
+			{false, true, "com.sun.star.chart.AreaDiagram", numberData1, "xls"},
+			{false, true, "com.sun.star.chart.XYDiagram", numberData1, "xls"}		
+		});
+	}
+	
+	public ChartMeanValueLine(Boolean expected, Boolean meanValueLine, String inputType, double[][] numberData, String fileType) {
+		this.expected = expected;
+		this.meanValueLine = meanValueLine;
+		this.inputType = inputType;
+		this.numberData = numberData;
+		this.fileType = fileType;
+	}
+		
+	@Before
+	public void setUp() throws Exception {
+		scComponent = unoApp.newDocument("scalc");
+		scDocument = SCUtil.getSCDocument(scComponent);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.closeDocument(scComponent);
+		
+	}
+	
+	@BeforeClass
+	public static void setUpConnection() throws Exception {
+		unoApp.start();
+	}
+
+	@AfterClass
+	public static void tearDownConnection() throws InterruptedException, Exception {
+		unoApp.close();
+		SCUtil.clearTempDir();	
+	}
+	
+	/**
+	 * Enable different types of mean value line in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a 2D chart.
+	 * 3. Enable mean value line in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the mean value line setting.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateTrendline() throws Exception {
+		String fileName = "testCreateMeanValueline";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		Boolean result = null;
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		XDiagram xDiagram = xChartDocument.getDiagram(); 
+		
+		SCUtil.setProperties(xDiagram, "MeanValue", meanValueLine);
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		xDiagram = xChartDocument.getDiagram(); 
+		result = (Boolean) SCUtil.getProperties(xDiagram, "MeanValue");
+
+		SCUtil.closeFile(scDocument);
+		
+		if (expected) {
+			assertTrue("Incorrect chart trendline got in ." + fileType + " file.", result);
+		}
+		else {
+			assertFalse("Incorrect chart trendline got in ." + fileType + " file.", result);
+		}
+		
+	}
+	
+}
\ No newline at end of file

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartMeanValueLine.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTitle.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTitle.java?rev=1388777&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTitle.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTitle.java Sat Sep 22 11:40:01 2012
@@ -0,0 +1,305 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+package testcase.uno.sc.chart;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SCUtil;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.drawing.XShape;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.CellRangeAddress;
+
+/**
+ *  Check the chart title/subtitle can be created, modified and saved
+ * 
+ */
+@RunWith(value = Parameterized.class)
+public class ChartTitle {
+
+	private String[] titles;
+	private String inputType;
+	private double[][] numberData;
+	private String fileType;
+	
+	private static final UnoApp unoApp = new UnoApp();
+	
+	XComponent scComponent = null;
+	XSpreadsheetDocument scDocument = null;
+	
+	@Parameters
+	public static Collection<Object[]> data() throws Exception {
+		double[][] numberData1 = {
+				{1, 2, 3, 4},
+				{2, 4.3, 5, 8},
+				{4, 2, 3, 1},
+				{1, -1, 0, -3}
+		};
+		String[][] titles = {
+				{"MyMainTitle", "MySubTitle"},
+				{"A Main Title With Space", "   Sub Title "},
+				{"  ", "      "}			
+		};
+
+		return Arrays.asList(new Object[][] {
+			{titles[0], "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{titles[1], "com.sun.star.chart.NetDiagram", numberData1, "ods"},
+			{titles[2], "com.sun.star.chart.AreaDiagram", numberData1, "ods"},
+			{titles[0], "com.sun.star.chart.PieDiagram", numberData1, "xls"},
+			{titles[1], "com.sun.star.chart.NetDiagram", numberData1, "xls"},
+			{titles[2], "com.sun.star.chart.XYDiagram", numberData1, "xls"}
+		});
+	}
+	
+	public ChartTitle(String[] titles, String inputType, double[][] numberData, String fileType) {
+		this.titles = titles;
+		this.inputType = inputType;
+		this.numberData = numberData;
+		this.fileType = fileType;
+	}
+	
+	
+	@Before
+	public void setUp() throws Exception {
+		scComponent = unoApp.newDocument("scalc");
+		scDocument = SCUtil.getSCDocument(scComponent);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.closeDocument(scComponent);
+		
+	}
+	
+	@BeforeClass
+	public static void setUpConnection() throws Exception {
+		unoApp.start();
+	}
+
+	@AfterClass
+	public static void tearDownConnection() throws InterruptedException, Exception {
+		unoApp.close();
+		SCUtil.clearTempDir();	
+	}
+	
+	/**
+	 * Create main title in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a chart.
+	 * 3. Create main title in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the chart main title.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateMainTitle() throws Exception {
+		String fileName = "testCreateMainTitle";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		Boolean result = null;	
+		String resultTitle = null;
+		String defaultTitle = null;
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		
+		result = (Boolean) SCUtil.getProperties(xChartDocument, "HasMainTitle");
+		if (!result) {
+			SCUtil.setProperties(xChartDocument, "HasMainTitle", true);
+		}
+		XShape aTitle = xChartDocument.getTitle();
+		defaultTitle = (String) SCUtil.getProperties(aTitle, "String");
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		result = (Boolean) SCUtil.getProperties(xChartDocument, "HasMainTitle");
+		resultTitle = (String) SCUtil.getProperties(xChartDocument.getTitle(), "String");		
+		SCUtil.closeFile(scDocument);
+		
+		assertTrue("Chart title has not be created in ." + fileType + " file.", result);
+		assertEquals("Incorrect chart title got in ." + fileType + " file.", defaultTitle, resultTitle);
+
+	}
+	
+	/**
+	 * Create sub title in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a chart.
+	 * 3. Create subtitle in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the chart main title.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateSubTitle() throws Exception {
+		String fileName = "testCreateSubTitle";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		Boolean result = null;	
+		String resultTitle = null;
+		String defaultTitle = null;
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		result = (Boolean) SCUtil.getProperties(xChartDocument, "HasSubTitle");
+		if (!result) {
+			SCUtil.setProperties(xChartDocument, "HasSubTitle", true);
+		}
+		XShape aSubTitle = xChartDocument.getSubTitle();
+		defaultTitle = (String) SCUtil.getProperties(aSubTitle, "String");
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		result = (Boolean) SCUtil.getProperties(xChartDocument, "HasSubTitle");
+		resultTitle = (String) SCUtil.getProperties(xChartDocument.getSubTitle(), "String");		
+		SCUtil.closeFile(scDocument);
+		
+		
+		if (fileType.equalsIgnoreCase("xls")) {
+			assertFalse("Chart subtitle should not be saved in ." + fileType + " file.", result);
+		}
+		else {
+			assertTrue("Chart subtitle has not be created in ." + fileType + " file.", result);
+			assertEquals("Incorrect chart subtitle got in ." + fileType + " file.", defaultTitle, resultTitle);
+		}	
+
+	}
+	
+	/**
+	 * Create titles in chart and change title string.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a chart.
+	 * 3. Create main title and subtitle in chart, input customized string in title box.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the chart titles.
+	 * @throws Exception
+	 */
+	@Test
+	public void testInputTitles() throws Exception {
+		String fileName = "testInputTitles";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		Boolean[] result = new Boolean[2];	
+		String[] resultTitle = new String[2];
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		SCUtil.setProperties(xChartDocument, "HasMainTitle", true);
+		SCUtil.setProperties(xChartDocument, "HasSubTitle", true);
+		
+		SCUtil.setProperties(xChartDocument.getTitle(), "String", titles[0]);
+		SCUtil.setProperties(xChartDocument.getSubTitle(), "String", titles[1]);
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		result[0] = (Boolean) SCUtil.getProperties(xChartDocument, "HasMainTitle");
+		result[1] = (Boolean) SCUtil.getProperties(xChartDocument, "HasSubTitle");
+		resultTitle[0] = (String) SCUtil.getProperties(xChartDocument.getTitle(), "String");	
+		resultTitle[1] = (String) SCUtil.getProperties(xChartDocument.getSubTitle(), "String");		
+		SCUtil.closeFile(scDocument);
+		
+		assertTrue("Chart main title has not be created in ." + fileType + " file.", result[0]);
+		assertEquals("Incorrect chart title got in ." + fileType + " file.", titles[0], resultTitle[0]);
+		if (fileType.equalsIgnoreCase("xls")) {
+			assertFalse("Chart subtitle should not be saved in ." + fileType + " file.", result[1]);
+		}
+		else {
+			assertTrue("Chart subtitle has not be created in ." + fileType + " file.", result[1]);
+			assertEquals("Incorrect chart subtitle got in ." + fileType + " file.", titles[1], resultTitle[1]);
+		}	
+
+	}
+	
+}
\ No newline at end of file

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTitle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTrendline.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTrendline.java?rev=1388777&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTrendline.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTrendline.java Sat Sep 22 11:40:01 2012
@@ -0,0 +1,175 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+package testcase.uno.sc.chart;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SCUtil;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.chart.ChartRegressionCurveType;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.chart.XDiagram;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.CellRangeAddress;
+
+/**
+ *  Check trend line in chart can be applied and saved
+ * 
+ */
+@RunWith(value = Parameterized.class)
+public class ChartTrendline {
+
+	private ChartRegressionCurveType expected;
+	private ChartRegressionCurveType trendlineType;
+	private String inputType;
+	private double[][] numberData;	
+	private String fileType;
+	
+	private static final UnoApp unoApp = new UnoApp();
+	
+	XComponent scComponent = null;
+	XSpreadsheetDocument scDocument = null;
+	
+	@Parameters
+	public static Collection<Object[]> data() throws Exception {
+		double[][] numberData1 = {
+				{10, 20, 30, 40},
+				{20, 40.3, 50, 80},
+				{40, 20, 30, 10},
+				{10, -10, 0, -30}
+		};
+
+		return Arrays.asList(new Object[][] {
+			{ChartRegressionCurveType.NONE, ChartRegressionCurveType.NONE, "com.sun.star.chart.LineDiagram", numberData1, "ods"},
+			{ChartRegressionCurveType.LINEAR, ChartRegressionCurveType.LINEAR, "com.sun.star.chart.LineDiagram", numberData1, "ods"},
+			{ChartRegressionCurveType.LOGARITHM, ChartRegressionCurveType.LOGARITHM, "com.sun.star.chart.AreaDiagram", numberData1, "ods"},
+			{ChartRegressionCurveType.EXPONENTIAL, ChartRegressionCurveType.EXPONENTIAL, "com.sun.star.chart.XYDiagram", numberData1, "ods"},
+			{ChartRegressionCurveType.POWER, ChartRegressionCurveType.POWER, "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			
+			{ChartRegressionCurveType.NONE, ChartRegressionCurveType.NONE, "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+			{ChartRegressionCurveType.LINEAR, ChartRegressionCurveType.LINEAR, "com.sun.star.chart.XYDiagram", numberData1, "xls"},
+			{ChartRegressionCurveType.LOGARITHM, ChartRegressionCurveType.LOGARITHM, "com.sun.star.chart.LineDiagram", numberData1, "xls"},
+			{ChartRegressionCurveType.EXPONENTIAL, ChartRegressionCurveType.EXPONENTIAL, "com.sun.star.chart.AreaDiagram", numberData1, "xls"},
+			{ChartRegressionCurveType.POWER, ChartRegressionCurveType.POWER, "com.sun.star.chart.BarDiagram", numberData1, "xls"}
+		
+		});
+	}
+	
+	public ChartTrendline(ChartRegressionCurveType expected, ChartRegressionCurveType trendlineType, String inputType, double[][] numberData, String fileType) {
+		this.expected = expected;
+		this.trendlineType = trendlineType;
+		this.inputType = inputType;
+		this.numberData = numberData;
+		this.fileType = fileType;
+	}
+		
+	@Before
+	public void setUp() throws Exception {
+		scComponent = unoApp.newDocument("scalc");
+		scDocument = SCUtil.getSCDocument(scComponent);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.closeDocument(scComponent);
+		
+	}
+	
+	@BeforeClass
+	public static void setUpConnection() throws Exception {
+		unoApp.start();
+	}
+
+	@AfterClass
+	public static void tearDownConnection() throws InterruptedException, Exception {
+		unoApp.close();
+		SCUtil.clearTempDir();	
+	}
+	
+	/**
+	 * Enable different types of trend line in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a 2D chart.
+	 * 3. Enable trend line in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the trend line setting.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateTrendline() throws Exception {
+		String fileName = "testCreateTrendline";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		ChartRegressionCurveType result = null;
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		XDiagram xDiagram = xChartDocument.getDiagram(); 
+		
+		SCUtil.setProperties(xDiagram, "RegressionCurves", trendlineType);
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		xDiagram = xChartDocument.getDiagram(); 
+		result = (ChartRegressionCurveType) SCUtil.getProperties(xDiagram, "RegressionCurves");
+
+		SCUtil.closeFile(scDocument);
+		
+		assertEquals("Incorrect chart trendline got in ." + fileType + " file.", expected, result);
+
+	}
+	
+}
\ No newline at end of file

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartTrendline.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartYErrorBar.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartYErrorBar.java?rev=1388777&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartYErrorBar.java (added)
+++ incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartYErrorBar.java Sat Sep 22 11:40:01 2012
@@ -0,0 +1,186 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+package testcase.uno.sc.chart;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openoffice.test.uno.UnoApp;
+
+import testlib.uno.SCUtil;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.chart.ChartErrorCategory;
+import com.sun.star.chart.ChartErrorIndicatorType;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.chart.XDiagram;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.CellRangeAddress;
+
+/**
+ *  Check Y error bar in chart can be applied and saved
+ * 
+ */
+@RunWith(value = Parameterized.class)
+public class ChartYErrorBar {
+
+	private ChartErrorCategory expCategory;
+	private ChartErrorIndicatorType expIndicator;
+	private ChartErrorCategory inputCategory;
+	private ChartErrorIndicatorType inputIndicator;
+	private String inputType;
+	private double[][] numberData;	
+	private String fileType;
+	
+	private static final UnoApp unoApp = new UnoApp();
+	
+	XComponent scComponent = null;
+	XSpreadsheetDocument scDocument = null;
+	
+	@Parameters
+	public static Collection<Object[]> data() throws Exception {
+		double[][] numberData1 = {
+				{10, 20, 30, 40},
+				{20, 40.3, 50, 80},
+				{40, 20, 30, 10},
+				{10, -10, 0, -30}
+		};
+
+		return Arrays.asList(new Object[][] {
+			{ChartErrorCategory.NONE, ChartErrorIndicatorType.NONE, ChartErrorCategory.NONE, ChartErrorIndicatorType.NONE, "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{ChartErrorCategory.VARIANCE, ChartErrorIndicatorType.TOP_AND_BOTTOM, ChartErrorCategory.VARIANCE, ChartErrorIndicatorType.TOP_AND_BOTTOM, "com.sun.star.chart.LineDiagram", numberData1, "ods"},
+			{ChartErrorCategory.STANDARD_DEVIATION, ChartErrorIndicatorType.UPPER, ChartErrorCategory.STANDARD_DEVIATION, ChartErrorIndicatorType.UPPER, "com.sun.star.chart.AreaDiagram", numberData1, "ods"},
+			{ChartErrorCategory.PERCENT, ChartErrorIndicatorType.LOWER, ChartErrorCategory.PERCENT, ChartErrorIndicatorType.LOWER, "com.sun.star.chart.BarDiagram", numberData1, "ods"},
+			{ChartErrorCategory.ERROR_MARGIN, ChartErrorIndicatorType.TOP_AND_BOTTOM, ChartErrorCategory.ERROR_MARGIN, ChartErrorIndicatorType.TOP_AND_BOTTOM, "com.sun.star.chart.LineDiagram", numberData1, "ods"},
+			{ChartErrorCategory.CONSTANT_VALUE, ChartErrorIndicatorType.UPPER, ChartErrorCategory.CONSTANT_VALUE, ChartErrorIndicatorType.UPPER, "com.sun.star.chart.AreaDiagram", numberData1, "ods"},
+			
+			{ChartErrorCategory.NONE, ChartErrorIndicatorType.NONE, ChartErrorCategory.NONE, ChartErrorIndicatorType.NONE, "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+//			{ChartErrorCategory.VARIANCE, ChartErrorIndicatorType.TOP_AND_BOTTOM, ChartErrorCategory.VARIANCE, ChartErrorIndicatorType.TOP_AND_BOTTOM, "com.sun.star.chart.LineDiagram", numberData1, "xls"},
+			{ChartErrorCategory.STANDARD_DEVIATION, ChartErrorIndicatorType.UPPER, ChartErrorCategory.STANDARD_DEVIATION, ChartErrorIndicatorType.UPPER, "com.sun.star.chart.AreaDiagram", numberData1, "xls"},
+			{ChartErrorCategory.PERCENT, ChartErrorIndicatorType.LOWER, ChartErrorCategory.PERCENT, ChartErrorIndicatorType.LOWER, "com.sun.star.chart.BarDiagram", numberData1, "xls"},
+//			{ChartErrorCategory.ERROR_MARGIN, ChartErrorIndicatorType.TOP_AND_BOTTOM, ChartErrorCategory.ERROR_MARGIN, ChartErrorIndicatorType.TOP_AND_BOTTOM, "com.sun.star.chart.AreaDiagram", numberData1, "xls"},
+			{ChartErrorCategory.CONSTANT_VALUE, ChartErrorIndicatorType.UPPER, ChartErrorCategory.CONSTANT_VALUE, ChartErrorIndicatorType.UPPER, "com.sun.star.chart.LineDiagram", numberData1, "xls"}
+		
+		});
+	}
+	
+	public ChartYErrorBar(ChartErrorCategory expCategory, ChartErrorIndicatorType expIndicator, ChartErrorCategory inputCategory, ChartErrorIndicatorType inputIndicator, String inputType, double[][] numberData, String fileType) {
+		this.expCategory = expCategory;
+		this.expIndicator = expIndicator;
+		this.inputCategory = inputCategory;
+		this.inputIndicator = inputIndicator;
+		this.inputType = inputType;
+		this.numberData = numberData;
+		this.fileType = fileType;
+	}
+		
+	@Before
+	public void setUp() throws Exception {
+		scComponent = unoApp.newDocument("scalc");
+		scDocument = SCUtil.getSCDocument(scComponent);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		unoApp.closeDocument(scComponent);
+		
+	}
+	
+	@BeforeClass
+	public static void setUpConnection() throws Exception {
+		unoApp.start();
+	}
+
+	@AfterClass
+	public static void tearDownConnection() throws InterruptedException, Exception {
+		unoApp.close();
+		SCUtil.clearTempDir();	
+	}
+	
+	/**
+	 * Enable different types of Y error bar in chart.
+	 * 1. Create a spreadsheet file.
+	 * 2. Input number in a cell range and create a chart.
+	 * 3. Enable Y error bar in chart.
+	 * 4. Save file as ODF/MSBinary format.
+	 * 5. Close and reopen file.  -> Check the Y error bar setting.
+	 * @throws Exception
+	 */
+	@Test
+	public void testCreateYErrorBar() throws Exception {
+		String fileName = "testCreateYErrorBar";
+		String chartName = "testChart";
+		String cellRangeName = "A1:D4";
+		ChartErrorCategory result1 = null;
+		ChartErrorIndicatorType result2 = null;
+		
+		if (inputType.equals("com.sun.star.chart.StockDiagram")) {
+			cellRangeName = "A1:C4";
+		}	
+		if (fileType.equalsIgnoreCase("xls")) {
+			chartName = "Object 1";			
+		}
+		
+		XSpreadsheet sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		SCUtil.setValueToCellRange(sheet, 0, 0, numberData);
+
+		CellRangeAddress[] cellAddress = new CellRangeAddress[1];
+		cellAddress[0] = SCUtil.getChartDataRangeByName(sheet, cellRangeName);
+		Rectangle rectangle = new Rectangle(1000, 1000, 15000, 9500);
+		XChartDocument xChartDocument = null; 		
+		xChartDocument = SCUtil.createChart(sheet, rectangle, cellAddress, chartName);
+		SCUtil.setChartType(xChartDocument, inputType);
+		XDiagram xDiagram = xChartDocument.getDiagram(); 
+		
+		SCUtil.setProperties(xDiagram, "ErrorCategory", inputCategory);
+		SCUtil.setProperties(xDiagram, "ErrorIndicator", inputIndicator);
+		
+		SCUtil.saveFileAs(scComponent, fileName, fileType);
+		scDocument = SCUtil.reloadFile(unoApp, scDocument, fileName + "." + fileType);
+		sheet = SCUtil.getCurrentSheet(scDocument);
+		
+		xChartDocument = SCUtil.getChartByName(sheet, chartName);
+		xDiagram = xChartDocument.getDiagram(); 
+		result1 = (ChartErrorCategory) SCUtil.getProperties(xDiagram, "ErrorCategory");
+		result2 = (ChartErrorIndicatorType) SCUtil.getProperties(xDiagram, "ErrorIndicator");
+		
+		SCUtil.closeFile(scDocument);
+		
+		assertEquals("Incorrect chart Y error bar category got in ." + fileType + " file.", expCategory, result1);
+		assertEquals("Incorrect chart Y error bar indicator got in ." + fileType + " file.", expIndicator, result2);
+
+	}
+	
+}
\ No newline at end of file

Propchange: incubator/ooo/trunk/test/testuno/source/testcase/uno/sc/chart/ChartYErrorBar.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/ooo/trunk/test/testuno/source/testlib/uno/SCUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testlib/uno/SCUtil.java?rev=1388777&r1=1388776&r2=1388777&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testuno/source/testlib/uno/SCUtil.java (original)
+++ incubator/ooo/trunk/test/testuno/source/testlib/uno/SCUtil.java Sat Sep 22 11:40:01 2012
@@ -640,6 +640,22 @@ public class SCUtil {
 	 * @throws Exception
 	 */
 	public static XChartDocument createChart(XSpreadsheet xSpreadsheet, Rectangle rec, CellRangeAddress[] dataRangeAddress, String chartName) throws Exception {
+		
+		return createChart(xSpreadsheet, rec, dataRangeAddress, chartName, true, false);
+	}
+	
+	/**
+	 * Create a spreadsheet chart with data in a specific cell range with column/row label enable/not.
+	 * @param xSpreadsheet
+	 * @param rec    a rectangle shape object
+	 * @param dataRangeAddress    the CellRangeAddress array of chart data source
+	 * @param chartName
+	 * @param hasColumnLabel  
+	 * @param hasRowLabel
+	 * @return
+	 * @throws Exception
+	 */
+	public static XChartDocument createChart(XSpreadsheet xSpreadsheet, Rectangle rec, CellRangeAddress[] dataRangeAddress, String chartName, Boolean hasColumnLabel, Boolean hasRowLabel) throws Exception {
 		XChartDocument xChartDocument = null;
 		XTableChartsSupplier xTChartSupplier = 
 				(XTableChartsSupplier) UnoRuntime.queryInterface(XTableChartsSupplier.class, xSpreadsheet);
@@ -648,7 +664,7 @@ public class SCUtil {
 				(XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xTableCharts);
 		if (xNameAccess != null && !xNameAccess.hasByName(chartName)) {
 			
-			xTableCharts.addNewByName(chartName, rec, dataRangeAddress, true, false);
+			xTableCharts.addNewByName(chartName, rec, dataRangeAddress, hasColumnLabel, hasRowLabel);
 			XTableChart xTableChart = (XTableChart) UnoRuntime.queryInterface(
 					XTableChart.class, xNameAccess.getByName(chartName));
 			XEmbeddedObjectSupplier xEmbeddedObjectSupplier = (XEmbeddedObjectSupplier) UnoRuntime.queryInterface(
@@ -718,7 +734,6 @@ public class SCUtil {
 	 * @throws Exception
 	 */
 	public static String[] getChartNameList(XSpreadsheet xSpreadsheet) throws Exception {
-		XChartDocument xChartDocument = null;
 		XTableChartsSupplier xTChartSupplier = 
 				(XTableChartsSupplier) UnoRuntime.queryInterface(XTableChartsSupplier.class, xSpreadsheet);
 		XTableCharts xTableCharts = xTChartSupplier.getCharts();



Mime
View raw message