Kaydet (Commit) 24f7c154 authored tarafından Liu Zhe's avatar Liu Zhe

#120321# - Automated Test: Refactor the test code under testcase.sc.*

Patch by: Li Lin Yi
Review by: Liu Zhe
üst 512863f0
/**************************************************************
*
* 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.sc.chart;
import static testlib.UIMap.*;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import testlib.Log;
/**
* Test the setting about chart dialog in spreadsheet
*/
public class ChartDialogSetting {
@Rule
public Log LOG = new Log();
@Before
public void setUp() throws Exception {
app.start();
// Create a new spreadsheet document
startcenter.menuItem("File->New->Spreadsheet").select();
}
@After
public void tearDown() throws Exception {
app.close();
}
/**
* Test cancel and back button in chart wizard dialog
*
* @throws java.lang.Exception
*/
@Test
public void testChartDialogCancelBack() {
calc.menuItem("Insert->Chart...").select();
WizardNextButton.click();
assertTrue(ChartRangeChooseTabPage.isEnabled());
WizardBackButton.click();
assertTrue(ChartTypeChooseTabPage.isEnabled());
Chart_Wizard.cancel();
assertFalse(Chart_Wizard.exists());
}
/**
* Verify Chart Wizard dialog title words
*/
@Test
public void testChartWizardTitle() {
calc.menuItem("Insert->Chart...").select();
assertEquals("Chart Wizard",Chart_Wizard.getText());
Chart_Wizard.cancel();
}
}
/**************************************************************
*
* 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.sc.filter;
import static testlib.AppUtil.*;
import static testlib.UIMap.*;
import org.junit.After;
import static org.junit.Assert.*;
import static org.openoffice.test.vcl.Tester.*;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import testlib.CalcUtil;
import testlib.Log;
/**
* Test cases about Data->Filter in spreadsheet
*/
public class Fitler {
@Rule
public Log LOG = new Log();
@Before
public void setUp() throws Exception {
app.start();
// Create a new spreadsheet document
startcenter.menuItem("File->New->Spreadsheet").select();
}
@After
public void tearDown() throws Exception {
app.close();
}
/**
*
* Verify Chart Wizard dialog title words
*/
@Ignore("Bug 120076")
public void testAutoFilterWithPlusSign() {
String expect ="2+";
CalcUtil.selectRange("A1");
typeKeys(expect + "<enter>");
assertEquals(expect,CalcUtil.getCellText("A1"));
}
}
/**************************************************************
*
* 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.sc.validity;
import static testlib.UIMap.*;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import testlib.Log;
public class ValidityDialogDefaultValue {
@Rule
public Log LOG = new Log();
@Before
public void setUp() throws Exception {
app.start();
// New a spreadsheet, open Validity dialog
startcenter.menuItem("File->New->Spreadsheet").select();
calc.menuItem("Data->Validity...").select();
}
@After
public void tearDown() throws Exception {
app.close();
}
/**
* test Data -> Validity - UI(Criteria: Cell range).
*/
@Test
public void testValidityUICellRange() {
SC_ValidityCriteriaTabpage.select();
SC_ValidityCriteriaAllowList.select("Cell range");
assertEquals(true,SC_ValidityAllowBlankCells.isChecked());
assertEquals(true,SC_ValidityShowSelectionList.isChecked());
assertEquals(false,SC_ValiditySortEntriesAscending.isChecked());
assertEquals(true,SC_ValidityAllowBlankCells.isEnabled());
assertEquals(true,SC_ValiditySortEntriesAscending.isEnabled());
assertEquals(true,SC_ValiditySortEntriesAscending.isEnabled());
assertEquals(true,SC_ValiditySourcePicker.isEnabled());
}
/**
* test Data -> Validity - UI(Error Alert: Default status)
*/
@Test
public void testValidityUIErrorAlert() {
SC_ValidityErrorAlertTabPage.select();
assertEquals(true,SC_ValidityErrorAlertActionList.isEnabled());
assertEquals("Stop",SC_ValidityErrorAlertActionList.getSelText());
assertEquals(true,SC_ValidityErrorMessageTitle.isEnabled());
assertEquals("",SC_ValidityErrorMessageTitle.getText());
assertEquals(true,SC_ValidityErrorMessage.isEnabled());
assertEquals("",SC_ValidityErrorMessage.getText());
SC_ValidityErrorAlertActionList.select("Macro");
assertEquals(true,SC_ValidityErrorBrowseButton.isEnabled());
}
}
/**************************************************************
*
* 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.sc.validity;
import static testlib.AppUtil.submitOpenDlg;
import static testlib.AppUtil.testFile;
import static testlib.AppUtil.typeKeys;
import static testlib.UIMap.*;
import static org.junit.Assert.*;
import static org.openoffice.test.vcl.Tester.typeKeys;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import testlib.CalcUtil;
import testlib.Log;
public class ValiditySampleFile {
@Rule
public Log LOG = new Log();
@Before
public void setUp() throws Exception {
app.start();
}
@After
public void tearDown() throws Exception {
app.close();
}
/**
* Test open MS 2003 spreadsheet with ignore blank validity.
*
* @throws Exception
*/
@Test
public void testFFCIgnoreBlank() throws Exception{
// Open sample file
String file = testFile("sc/FFC252FFCSC_XML_Datarange0235.xls");
app.dispatch(".uno:Open", 3);
submitOpenDlg(file);
calc.waitForExistence(10, 2);
CalcUtil.selectRange("D5");
SC_InputBar_Input.activate();
for(int i=1;i<=10;i++)
typeKeys("<backspace>");
typeKeys("<enter>");
assertEquals("",CalcUtil.getCellText("D5"));
}
/**
* Test open MS 2003 spreadsheet with ignore blank validity.
*
* @throws Exception
*/
@Test
public void testFFCNotIgnoreBlank() throws Exception{
//open sample file
String file = testFile("sc/FFC252FFCSC_XML_Datarange0205.xls");
app.dispatch(".uno:Open", 3);
submitOpenDlg(file);
calc.waitForExistence(10, 2);
CalcUtil.selectRange("F5");
SC_InputBar_Input.activate();
typeKeys("<backspace><enter>");
assertEquals("Invalid value.",ActiveMsgBox.getMessage());
ActiveMsgBox.ok();
assertEquals("8",CalcUtil.getCellText("F5"));
}
/**
* test Cell is not locked after switch from validity cell to source cells
*/
@Test
public void testNotLockCellFromValidityCell() {
//open sample file on data path
String file = testFile("sc/sampledata.ods");
app.dispatch(".uno:Open", 3);
submitOpenDlg(file);
calc.waitForExistence(10, 2);
CalcUtil.selectRange("Sheet1.F19");
typeKeys("d<enter>");
CalcUtil.selectRange("Sheet1.F17");
typeKeys("Test<enter>");
assertEquals("Test",CalcUtil.getCellText("F17"));
}
}
/**************************************************************
*
* 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.sd.headerandfooter;
import static testlib.AppUtil.fullPath;
import static testlib.AppUtil.openStartcenter;
import static testlib.AppUtil.submitSaveDlg;
import static testlib.AppUtil.submitOpenDlg;
import static testlib.AppUtil.testFile;
import static testlib.UIMap.*;
import static org.junit.Assert.*;
import static org.openoffice.test.vcl.Tester.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openoffice.test.common.FileUtil;
import testlib.Log;
public class OpenDocumentWithHeaderFooter {
@Rule
public Log LOG = new Log();
@Before
public void setUp() throws Exception {
app.start();
}
@After
public void tearDown() throws Exception {
app.close();
}
/**
* Test open AOO3.4 presentation with header and footer.
* edit and save to ODP
* @throws Exception
*/
@Test
public void testOpenAOO34WithHeaderFooter() throws Exception{
//open sample file
String file = testFile("sd/AOO3.4HeaderFooter.odp");
app.dispatch(".uno:Open");
submitOpenDlg(file);
//check after reopen
impress.menuItem("View->Header and Footer...").select();
sleep(1);
assertEquals(true,SD_DateAndTimeFooterOnSlide.isChecked());
assertEquals("fixed date",SD_FixedDateAndTimeOnSlideInput.getText());
assertEquals(true,SD_FooterTextOnSlide.isChecked());
assertEquals("footer test",SD_FooterTextOnSlideInput.getText());
assertEquals(true,SD_SlideNumAsFooterOnSlide.isChecked());
SD_SlideNumAsFooterOnSlide.uncheck();
SD_ApplyToAllButtonOnSlideFooter.click();
//save to odp and reopen
impress.menuItem("File->Save As...").select();
String saveTo2 = fullPath("temp/" + "AOO3.4HeaderFooter.odp");
FileUtil.deleteFile(saveTo2);
submitSaveDlg(saveTo2);
impress.menuItem("File->Close").select();
sleep(1);
openStartcenter();
app.dispatch(".uno:Open");
String openFrom2=fullPath("temp/" + "AOO3.4HeaderFooter.odp");
submitOpenDlg(openFrom2);
impress.menuItem("View->Header and Footer...").select();
sleep(1);
assertEquals(false,SD_SlideNumAsFooterOnSlide.isChecked());
//end-save to odp and reopen
}
/**
* Test open ppt file with header and footer.
* edit and save to PPT/ODP
* @throws Exception
*/
@Test
public void testOpenPPTWithHeaderFooter() throws Exception{
//open sample file
String file = testFile("sd/gfdd.ppt");
app.dispatch(".uno:Open");
submitOpenDlg(file);
//check after reopen
impress.menuItem("View->Header and Footer...").select();
sleep(1);
assertEquals(true,SD_DateAndTimeFooterOnSlide.isChecked());
assertEquals("testdte",SD_FixedDateAndTimeOnSlideInput.getText());
assertEquals(true,SD_FooterTextOnSlide.isChecked());
assertEquals("yesy",SD_FooterTextOnSlideInput.getText());
assertEquals(true,SD_SlideNumAsFooterOnSlide.isChecked());
SD_SlideNumAsFooterOnSlide.uncheck();
SD_ApplyToAllButtonOnSlideFooter.click();
//save to ppt and reopen
impress.menuItem("File->Save As...").select();
String saveTo = fullPath("temp/" + "gfdd.ppt");
FileUtil.deleteFile(saveTo);
submitSaveDlg(saveTo);
if (AlienFormatDlg.exists(3))
AlienFormatDlg.ok();
sleep(1);
impress.menuItem("File->Close").select();
sleep(1);
openStartcenter();
app.dispatch(".uno:Open");
String openFrom=fullPath("temp/" + "gfdd.ppt");
submitOpenDlg(openFrom);
impress.menuItem("View->Header and Footer...").select();
sleep(1);
assertEquals(false,SD_SlideNumAsFooterOnSlide.isChecked());
//end-save to ppt and reopen
//close Header and Footer dialog.
SD_ApplyButtonOnSlideFooter.focus();
typeKeys("<tab>");
typeKeys("<enter>");
//end
//save to odp and reopen
impress.menuItem("File->Save As...").select();
String saveTo2 = fullPath("temp/" + "gfdd.odp");
FileUtil.deleteFile(saveTo2);
submitSaveDlg(saveTo2);
impress.menuItem("File->Close").select();
sleep(1);
openStartcenter();
app.dispatch(".uno:Open");
String openFrom2=fullPath("temp/" + "gfdd.odp");
submitOpenDlg(openFrom2);
impress.menuItem("View->Header and Footer...").select();
sleep(1);
assertEquals(false,SD_SlideNumAsFooterOnSlide.isChecked());
//end-save to odp and reopen
}
}
/**************************************************************
*
* 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.sw.table;
import static testlib.AppUtil.*;
import static testlib.UIMap.*;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openoffice.test.common.SystemUtil;
import testlib.Log;
/**
*
*/
public class Table {
@Rule
public Log LOG = new Log();
@Before
public void setUp() throws Exception {
app.start();
}
@After
public void tearDown() throws Exception {
app.close();
}
/**
* Test convert table to text in text document
* @throws Exception
*/
@Test
public void testConvertTableToText() throws Exception{
//Create a new text document
startcenter.menuItem("File->New->Text Document").select();
sleep(3);
// Insert a table and input some data
writer.menuItem("Insert->Table...").select();
writer_InsertTable.ok();
writer.focus();
typeKeys("1<right>2<right>3<right>4");
sleep(1);
// Convert table to text
writer.menuItem("Table->Convert->Table to Text...").select();
assertTrue("Convert Table to Text dialog pop up", writer_ConvertTableToTextDlg.exists());
typeKeys("<enter>");
sleep(1);
// Verify if text is converted successfully
writer.menuItem("Edit->Select All").select();
app.dispatch(".uno:Copy");
if (SystemUtil.isWindows())
assertEquals("Converted text", "1\t2\r\n3\t4\r\n", app.getClipboard()); // windows�лس�������\r\n
else
assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment