Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 27261D0E2 for ; Mon, 23 Jul 2012 02:50:07 +0000 (UTC) Received: (qmail 93265 invoked by uid 500); 23 Jul 2012 02:50:06 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 93230 invoked by uid 500); 23 Jul 2012 02:50:06 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 93221 invoked by uid 99); 23 Jul 2012 02:50:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jul 2012 02:50:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jul 2012 02:49:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 70C57238897F; Mon, 23 Jul 2012 02:49:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1364479 [2/3] - in /incubator/ooo/trunk/main/test/testoo/src/testcase: sc/chart/ sc/datapilot/ sc/filter/ sc/sort/ sc/validity/ sd/headerandfooter/ sw/table/ Date: Mon, 23 Jul 2012 02:49:36 -0000 To: ooo-commits@incubator.apache.org From: liuzhe@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120723024937.70C57238897F@eris.apache.org> Added: incubator/ooo/trunk/main/test/testoo/src/testcase/sc/sort/SortDialogSetting.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testcase/sc/sort/SortDialogSetting.java?rev=1364479&view=auto ============================================================================== --- incubator/ooo/trunk/main/test/testoo/src/testcase/sc/sort/SortDialogSetting.java (added) +++ incubator/ooo/trunk/main/test/testoo/src/testcase/sc/sort/SortDialogSetting.java Mon Jul 23 02:49:36 2012 @@ -0,0 +1,1160 @@ +/************************************************************** + * + * 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.sort; + +import static testlib.AppUtil.*; +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.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.openoffice.test.common.FileUtil; +import testlib.CalcUtil; +import testlib.Log; + +/** + * Test Data->Sort dialog setting + */ +public class SortDialogSetting { + + @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 sort with options setting: case sensitive + * @throws Exception + */ + @Test + public void testSortOptionsCaseSensitive() throws Exception{ + + // Input some data: A1~A6: 1ColumnName,D,C,B,A,a + String[][] data = new String[][] { + {"D"}, + {"C"}, + {"B"}, + {"A"}, + {"a"}, + }; + String[][] expectedSortedResult = new String[][] { + {"a"}, + {"A"}, + {"B"}, + {"C"}, + {"D"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("1ColumnNameDCBAa"); + CalcUtil.selectRange("A6"); + app.dispatch(".uno:ChangeCaseToLower"); // In case SC capitalize first letter automatically + + // "Data->Sort...", choose "Ascending", check "Case sensitive" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_CaseSensitive.check(); + SortOptionsPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedSortedResult, CalcUtil.getCellTexts("A2:A6")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A2:A6")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult, CalcUtil.getCellTexts("A2:A6")); + + // Save and close document + String saveTo = fullPath("temp/" + "RowsSortWithOptionsCaseSensitive.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Saved sorted result", expectedSortedResult, CalcUtil.getCellTexts("A2:A6")); + } + + /** + * Test sort with options setting: copy sort result to + * @throws Exception + */ + @Ignore("Bug 119035") + public void testSortOptionsCopyResultTo() throws Exception{ + + // Input some data + // String[][] data = new String[][] { + // {"3", "D"}, + // {"5", "FLK"}, + // {"4", "E"}, + // {"2", "BC"}, + // {"6", "GE"}, + // {"1", "AB"}, + // }; + String[][] expectedSortedResult = new String[][] { + {"1", "AB"}, + {"2", "BC"}, + {"3", "D"}, + {"4", "E"}, + {"5", "FLK"}, + {"6", "GE"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("354261"); + CalcUtil.selectRange("B1"); + typeKeys("DFLKEBCGEAB"); + + // Data->Sort..., choose "Ascending", check "Copy sort results to:" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_CopyResultTo.check(); + SortOptionsPage_CopyResultToEdit.setText("$Sheet3.$A4"); + SortOptionsPage.ok(); + + // Verify sorted result + assertArrayEquals("Copy sorted result to", expectedSortedResult, CalcUtil.getCellTexts("$Sheet3.$A4:$B9")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertEquals("Undo sorted result", "", CalcUtil.getCellText("$Sheet3.$A4")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult, CalcUtil.getCellTexts("$Sheet3.$A4:$B9")); + + // Move focus to sheet2 then select a cell range, Insert->Names->Define... + CalcUtil.selectRange("$Sheet2.$A1:$B3"); + calc.menuItem("Insert->Names->Define...").select(); + DefineNamesDlg_NameEdit.setText("cellRange"); + DefineNamesDlg.ok(); + + // Set focus to the original data, Data->Sort... + CalcUtil.selectRange("$Sheet1.$B1"); + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_CopyResultTo.check(); + SortOptionsPage_CopyResultToCellRange.select("cellRange"); + SortOptionsPage.ok(); + + // Verify sorted result + assertArrayEquals("Copy sorted result to cell range", expectedSortedResult, CalcUtil.getCellTexts("$Sheet2.$A1:$B6")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertEquals("Undo sorted result", "", CalcUtil.getCellText("$Sheet2.$A1")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult, CalcUtil.getCellTexts("$Sheet2.$A1:$B6")); + + // Save and close document + String saveTo = fullPath("temp/" + "RowsSortWithOptionsCopyResultTo.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Saved sorted result", expectedSortedResult, CalcUtil.getCellTexts("$Sheet3.$A4:$B9")); + assertArrayEquals("Saved sorted result to cell range", expectedSortedResult, CalcUtil.getCellTexts("$Sheet2.$A1:$B6")); + } + + /** + * Test sort criteria: sort first by + * @throws Exception + */ + @Test + public void testSortCriteriaSortFirstBy() throws Exception{ + + // Input some data + String[][] data = new String[][] { + {"3", "D"}, + {"5", "FLK"}, + {"4", "E"}, + {"2", "BC"}, + {"6", "GE"}, + {"1", "AB"}, + }; + String[][] expectedResultSortByColumnBAscending = new String[][] { + {"1", "AB"}, + {"2", "BC"}, + {"3", "D"}, + {"4", "E"}, + {"5", "FLK"}, + {"6", "GE"}, + }; + String[][] expectedResultSortByColumnADescending = new String[][] { + {"6", "GE"}, + {"5", "FLK"}, + {"4", "E"}, + {"3", "D"}, + {"2", "BC"}, + {"1", "AB"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("354261"); + CalcUtil.selectRange("B1"); + typeKeys("DFLKEBCGEAB"); + + // "Data->Sort...", choose "Ascending", sort first by Column B + calc.menuItem("Data->Sort...").select(); + SortPage_Ascending1.check(); + SortPage_By1.select("Column B"); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedResultSortByColumnBAscending, CalcUtil.getCellTexts("A1:B6")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:B6")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultSortByColumnBAscending, CalcUtil.getCellTexts("A1:B6")); + calc.menuItem("Edit->Undo: Sort").select(); + + // Save and close document + String saveTo = fullPath("temp/" + "SortCriteriaSortFirstBy.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen, "Data->Sort...", choose "Descending", sort first by Column A + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + calc.menuItem("Data->Sort...").select(); + SortPage_Descending1.check(); + SortPage_By1.select("Column A"); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Saved sorted result", expectedResultSortByColumnADescending, CalcUtil.getCellTexts("A1:B6")); + } + + /** + * Test sort criteria: sort second by + * @throws Exception + */ + @Test + public void testSortCriteriaSortSecondBy() throws Exception{ + + // Input some data + String[][] data = new String[][] { + {"3", "D"}, + {"5", "FLK"}, + {"4", "E"}, + {"1", "AB"}, + {"6", "GE"}, + {"2", "AB"}, + }; + String[][] expectedResultSortFirstByB = new String[][] { + {"1", "AB"}, + {"2", "AB"}, + {"3", "D"}, + {"4", "E"}, + {"5", "FLK"}, + {"6", "GE"}, + }; + String[][] expectedResultSortSecondByA= new String[][] { + {"2", "AB"}, + {"1", "AB"}, + {"3", "D"}, + {"4", "E"}, + {"5", "FLK"}, + {"6", "GE"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("354162"); + CalcUtil.selectRange("B1"); + typeKeys("DFLKEABGEAB"); + + // "Data->Sort...", choose "Ascending", sort first by Column B + calc.menuItem("Data->Sort...").select(); + SortPage_Ascending1.check(); + SortPage_By1.select("Column B"); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedResultSortFirstByB, CalcUtil.getCellTexts("A1:B6")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:B6")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultSortFirstByB, CalcUtil.getCellTexts("A1:B6")); + calc.menuItem("Edit->Undo: Sort").select(); + + // Save and close document + String saveTo = fullPath("temp/" + "SortCriteriaSortSecondBy.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen, "Data->Sort...", sort first by Column B "Ascending", sort second by Column A "Descending" + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + calc.menuItem("Data->Sort...").select(); + SortPage_By1.select("Column B"); + SortPage_Ascending1.check(); + SortPage_By2.select("Column A"); + SortPage_Descending2.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Saved sorted result", expectedResultSortSecondByA, CalcUtil.getCellTexts("A1:B6")); + } + + /** + * Test sort criteria: sort third by + * @throws Exception + */ + @Test + public void testSortCriteriaSortThirdBy() throws Exception{ + + // Input some data + String[][] data = new String[][] { + {"3", "AB", "2"}, + {"8", "FLK", "5"}, + {"6", "E", "4"}, + {"1", "AB", "1"}, + {"9", "GE", "6"}, + {"2", "AB", "2"}, + {"7", "EFYU", "7"}, + {"5", "DS", "8"}, + {"4", "AB", "1"}, + }; + String[][] expectedResultSortFirstByB = new String[][] { + {"3", "AB", "2"}, + {"1", "AB", "1"}, + {"2", "AB", "2"}, + {"4", "AB", "1"}, + {"5", "DS", "8"}, + {"6", "E", "4"}, + {"7", "EFYU", "7"}, + {"8", "FLK", "5"}, + {"9", "GE", "6"}, + }; + String[][] expectedResultSortSecondByC= new String[][] { + {"3", "AB", "2"}, + {"2", "AB", "2"}, + {"1", "AB", "1"}, + {"4", "AB", "1"}, + {"5", "DS", "8"}, + {"6", "E", "4"}, + {"7", "EFYU", "7"}, + {"8", "FLK", "5"}, + {"9", "GE", "6"}, + }; + String[][] expectedResultSortThirdByA= new String[][] { + {"3", "AB", "2"}, + {"2", "AB", "2"}, + {"4", "AB", "1"}, + {"1", "AB", "1"}, + {"5", "DS", "8"}, + {"6", "E", "4"}, + {"7", "EFYU", "7"}, + {"8", "FLK", "5"}, + {"9", "GE", "6"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("386192754"); + CalcUtil.selectRange("B1"); + typeKeys("ABFLKEABGEABEFYUDSAB"); + CalcUtil.selectRange("C1"); + typeKeys("254162781"); + sleep(0.5); + + // "Data->Sort...", choose "Ascending", sort first by Column B + calc.menuItem("Data->Sort...").select(); + SortPage_By1.select("Column B"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedResultSortFirstByB, CalcUtil.getCellTexts("A1:C9")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:C9")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultSortFirstByB, CalcUtil.getCellTexts("A1:C9")); + calc.menuItem("Edit->Undo: Sort").select(); + + // Save and close document + String saveTo = fullPath("temp/" + "SortCriteriaSortThirdBy.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen, "Data->Sort...", sort first by Column B "Ascending", sort second by Column C "Descending" + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + calc.menuItem("Data->Sort...").select(); + SortPage_By1.select("Column B"); + SortPage_Ascending1.check(); + SortPage_By2.select("Column C"); + SortPage_Descending2.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedResultSortSecondByC, CalcUtil.getCellTexts("A1:C9")); + + // "Data->Sort...", sort first by Column B "Ascending", sort second by Column C "Descending", sort third by Column A "Descending" + calc.menuItem("Data->Sort...").select(); + SortPage_By1.select("Column B"); + SortPage_Ascending1.check(); + SortPage_By2.select("Column C"); + SortPage_Descending2.check(); + SortPage_By3.select("Column A"); + SortPage_Descending3.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedResultSortThirdByA, CalcUtil.getCellTexts("A1:C9")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", expectedResultSortSecondByC, CalcUtil.getCellTexts("A1:C9")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultSortThirdByA, CalcUtil.getCellTexts("A1:C9")); + + // Save and close document + saveTo = fullPath("temp/" + "SortCriteriaSortThirdBy1.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify data sort is not lost + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Saved sorted result", expectedResultSortThirdByA, CalcUtil.getCellTexts("A1:C9")); + } + + /** + * Test sort options: custom sort order, predefined in preferences from copy list + * @throws Exception + */ + @Test + public void testSortOptionsCustomSortOrderPredefineFromCopyList() throws Exception{ + + // Dependencies start + CalcUtil.selectRange("A1"); + typeKeys("redyellowbluegreenwhiteblack"); + CalcUtil.selectRange("A1:A6"); + app.dispatch(".uno:ChangeCaseToLower"); // In case SC capitalize first letter automatically + + // Select the cell range, "Tools->Options...->OpenOffice.org Spreadsheets->Sort Lists" + CalcUtil.selectRange("A1:A6"); + app.dispatch(".uno:OptionsTreeDialog"); + // Select "Sort Lists": start. Shrink the tree list and select + OptionsDlgList.select(0); + typeKeys(""); + for (int i=0; i<6; i++) { + typeKeys(""); + } + OptionsDlgList.select(3); + typeKeys(""); + OptionsDlgList.select(7); + // Select "Sort Lists": end + + // Click "Copy" button, "OK", close the document + OptionsDlg_SortListsTabCopy.click(); + OptionsDlg.ok(); + calc.menuItem("File->Close").select(); + MsgBox_AdditionalRowsNotSaved.no(); + // Dependencies end + + // Create a new spreadsheet document + startcenter.menuItem("File->New->Spreadsheet").select(); + + // Input some data + String[][] data = new String[][] { + {"Color"}, + {"black"}, + {"yellow"}, + {"blue"}, + {"black"}, + {"white"}, + {"red"}, + }; + String[][] expectedResultNoCustomSortOrder = new String[][] { + {"Color"}, + {"black"}, + {"black"}, + {"blue"}, + {"red"}, + {"white"}, + {"yellow"}, + }; + String[][] expectedResultCustomSortOrder = new String[][] { + {"Color"}, + {"red"}, + {"yellow"}, + {"blue"}, + {"white"}, + {"black"}, + {"black"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("Colorblackyellowblueblackwhitered"); + CalcUtil.selectRange("A2:A7"); + app.dispatch(".uno:ChangeCaseToLower"); // In case SC capitalize first letter automatically + + // "Data->Sort...", "Options" tab, check "Range contains column labels", no custom sort order, "Ascending", sort first by Color + CalcUtil.selectRange("A1:A7"); + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_CustomSortOrder.uncheck(); + SortPage.select(); + SortPage_By1.select("Color"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result without custom sort order", expectedResultNoCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultNoCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Undo: Sort").select(); + + // Copy original data to sheet2 + CalcUtil.selectRange("A1:A7"); + calc.menuItem("Edit->Copy").select(); + CalcUtil.selectRange("Sheet2.A1"); + calc.menuItem("Edit->Paste").select(); + + // "Data->Sort...", "Options" tab, check "Range contains column labels", choose custom sort order, "Ascending", sort first by Color + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_CustomSortOrder.check(); + SortOptionsPage_CustomSortOrderList.select("red,yellow,blue,green,white,black"); + SortPage.select(); + SortPage_By1.select("Color"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result with custom sort order", expectedResultCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + + // Save and close document + String saveTo = fullPath("temp/" + "SortOptionsCustomSortOrderPredefineFromCopyList.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Original data", data, CalcUtil.getCellTexts("$Sheet1.$A1:$A7")); + assertArrayEquals("Saved sorted result", expectedResultCustomSortOrder, CalcUtil.getCellTexts("$Sheet2.$A1:$A7")); + } + + /** + * Test sort options: custom sort order, predefined in preferences from new list + * @throws Exception + */ + @Test + public void testSortOptionsCustomSortOrderPredefineFromNewList() throws Exception{ + + // Dependencies start + // "Tools->Options...->OpenOffice.org Spreadsheets->Sort Lists" + app.dispatch(".uno:OptionsTreeDialog"); + // Select "Sort Lists": start. Shrink the tree list and select + OptionsDlgList.select(0); + typeKeys(""); + for (int i=0; i<6; i++) { + typeKeys(""); + } + OptionsDlgList.select(3); + typeKeys(""); + OptionsDlgList.select(7); + // Select "Sort Lists": end + + // Click "New" button, input "white,red,yellow,blue,green,black", press "Add" and "OK", close the document + OptionsDlg_SortListsTabNew.click(); + typeKeys("white,red,yellow,blue,green,black"); + OptionsDlg_SortListsTabAdd.click(); + sleep(0.5); + OptionsDlg.ok(); + calc.menuItem("File->Close").select(); + // Dependencies end + + // Create a new spreadsheet document + startcenter.menuItem("File->New->Spreadsheet").select(); + sleep(3); + + // Input some data + String[][] data = new String[][] { + {"Color"}, + {"black"}, + {"yellow"}, + {"blue"}, + {"black"}, + {"white"}, + {"red"}, + }; + String[][] expectedResultNoCustomSortOrder = new String[][] { + {"Color"}, + {"black"}, + {"black"}, + {"blue"}, + {"red"}, + {"white"}, + {"yellow"}, + }; + String[][] expectedResultCustomSortOrder = new String[][] { + {"Color"}, + {"white"}, + {"red"}, + {"yellow"}, + {"blue"}, + {"black"}, + {"black"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("Colorblackyellowblueblackwhitered"); + CalcUtil.selectRange("A2:A7"); + app.dispatch(".uno:ChangeCaseToLower"); // In case SC capitalize first letter automatically + + // "Data->Sort...", "Options" tab, check "Range contains column labels", no custom sort order, "Ascending", sort first by Color + CalcUtil.selectRange("A1:A7"); + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_CustomSortOrder.uncheck(); + SortPage.select(); + SortPage_By1.select("Color"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result without custom sort order", expectedResultNoCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultNoCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Undo: Sort").select(); + + // Copy original data to sheet2 + CalcUtil.selectRange("A1:A7"); + calc.menuItem("Edit->Copy").select(); + CalcUtil.selectRange("Sheet2.A1"); + calc.menuItem("Edit->Paste").select(); + + // "Data->Sort...", "Options" tab, check "Range contains column labels", choose custom sort order, "Ascending", sort first by Color + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_CustomSortOrder.check(); + SortOptionsPage_CustomSortOrderList.select("white,red,yellow,blue,green,black"); + SortPage.select(); + SortPage_By1.select("Color"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result with custom sort order", expectedResultCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedResultCustomSortOrder, CalcUtil.getCellTexts("A1:A7")); + + // Save and close document + String saveTo = fullPath("temp/" + "SortOptionsCustomSortOrderPredefineFromNewList.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Original data", data, CalcUtil.getCellTexts("$Sheet1.$A1:$A7")); + assertArrayEquals("Saved sorted result", expectedResultCustomSortOrder, CalcUtil.getCellTexts("$Sheet2.$A1:$A7")); + } + + /** + * Test sort options: sort columns, direction "Left to right" + * @throws Exception + */ + @Test + public void testSortOptionsDirectionSortColumns() throws Exception{ + + // Input some data + String[][] data = new String[][] { + {"Units", "7", "27", "4", "12", "3", "6"}, + }; + String[][] expectedSortedResult = new String[][] { + {"Units", "3", "4", "6", "7", "12", "27"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("Units72741236"); + + // "Data->Sort...", check "Range contains column labels", "Left to right", sort first by"Units", "Ascending" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_LeftToRight.check(); + SortPage.select(); + SortPage_By1.select("Units"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedSortedResult, CalcUtil.getCellTexts("A1:G1")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data, CalcUtil.getCellTexts("A1:G1")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult, CalcUtil.getCellTexts("A1:G1")); + + // Save and close document + String saveTo = fullPath("temp/" + "SortOptionsDirectionSortColumns.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Saved sorted result", expectedSortedResult, CalcUtil.getCellTexts("A1:G1")); + } + + /** + * Test sort options: "Include formats" + * @throws Exception + */ + @Test + public void testSortOptionsIncludeFormats() throws Exception{ + + // Create a new spreadsheet document + + String[][] dataWithCurrencyFormats = new String[][] { + {"Units"}, + {"$32.00"}, + {"57.00 \u20ac"}, + {"\u20a4 74"}, + {"R$ 50.00"}, + {"\u062c.\u0645. 27"}, + {"7.00 \u0440\u0443\u0431"}, + }; + String[][] expectedSortedResultIncludeFormat = new String[][] { + {"Units"}, + {"7.00 \u0440\u0443\u0431"}, + {"\u062c.\u0645. 27"}, + {"$32.00"}, + {"R$ 50.00"}, + {"57.00 \u20ac"}, + {"\u20a4 74"}, + }; + String[][] expectedSortedResultExcludeFormat = new String[][] { + {"Units"}, + {"$7.00"}, + {"27.00 \u20ac"}, + {"\u20a4 32"}, + {"R$ 50.00"}, + {"\u062c.\u0645. 57"}, + {"74.00 \u0440\u0443\u0431"}, + }; + + // Input source data + String file = testFile("sc/SortOptionsIncludeFormats.ods"); + // String file = testFile("sc/FFC252FFCSC_XML_Datarange0235.xls"); + app.dispatch(".uno:Open", 3); + submitOpenDlg(file); + calc.waitForExistence(10, 2); + + assertArrayEquals("source", dataWithCurrencyFormats, CalcUtil.getCellTexts("A1:A7")); + + // CalcUtil.selectRange("A1"); + // typeKeys("Units$32.0057.00 \u20ac\u20a4 74R$ 50.00\u062c.\u0645. 27.007.00 \u0440\u0443\u0431."); + + // // Set Currency formats + // CalcUtil.selectRange("A2"); + // typeKeys(""); + //// calc.menuItem("Fortmat->Cells...").select(); error: can not find item "Format" + // FormatCellsDlg_NumbersPage.select(); + // FormatCellsDlg_NumbersPageCategory.select("Currency"); + // FormatCellsDlg_NumbersPageCurrencyFormat.select("$ English (USA)"); + // FormatCellsDlg_NumbersPage.ok(); + // CalcUtil.selectRange("A3"); + // typeKeys(""); + // FormatCellsDlg_NumbersPage.select(); + // FormatCellsDlg_NumbersPageCategory.select("Currency"); + // FormatCellsDlg_NumbersPageCurrencyFormat.select("\u20ac Spanish (Spain)"); + // FormatCellsDlg_NumbersPage.ok(); + // CalcUtil.selectRange("A4"); + // typeKeys(""); + // FormatCellsDlg_NumbersPage.select(); + // FormatCellsDlg_NumbersPageCategory.select("Currency"); + // FormatCellsDlg_NumbersPageCurrencyFormat.select("\u20a4 Latin"); + // FormatCellsDlg_NumbersPage.ok(); + // CalcUtil.selectRange("A5"); + // typeKeys(""); + // FormatCellsDlg_NumbersPage.select(); + // FormatCellsDlg_NumbersPageCategory.select("Currency"); + // FormatCellsDlg_NumbersPageCurrencyFormat.select("R$ Portuguese (Brazil)"); + // FormatCellsDlg_NumbersPage.ok(); + // CalcUtil.selectRange("A6"); + // typeKeys(""); + // FormatCellsDlg_NumbersPage.select(); + // FormatCellsDlg_NumbersPageCategory.select("Currency"); + // FormatCellsDlg_NumbersPageCurrencyFormat.select("\u062c.\u0645. Arabic (Egypt)"); + // FormatCellsDlg_NumbersPage.ok(); + // CalcUtil.selectRange("A7"); + // typeKeys(""); + // FormatCellsDlg_NumbersPage.select(); + // FormatCellsDlg_NumbersPageCategory.select("Currency"); + // FormatCellsDlg_NumbersPageCurrencyFormat.select("\u0440\u0443\u0431. Russian"); + // FormatCellsDlg_NumbersPage.ok(); + + // "Data->Sort...", check "Range contains column labels", check "Include formats", sort first by "Units", "Ascending" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_IncludeFormats.check(); + SortPage.select(); + SortPage_By1.select("Units"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result include formats", expectedSortedResultIncludeFormat, CalcUtil.getCellTexts("A1:A7")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", dataWithCurrencyFormats, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResultIncludeFormat, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Undo: Sort").select(); + + // Copy the original data to sheet2 + CalcUtil.selectRange("A1:A7"); + calc.menuItem("Edit->Copy").select(); + CalcUtil.selectRange("Sheet2.A1"); + calc.menuItem("Edit->Paste").select(); + + // "Data->Sort...", check "Range contains column labels", uncheck "Include formats", sort first by "Units", "Ascending" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_IncludeFormats.uncheck(); + SortPage.select(); + SortPage_By1.select("Units"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result exclude formats", expectedSortedResultExcludeFormat, CalcUtil.getCellTexts("A1:A7")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", dataWithCurrencyFormats, CalcUtil.getCellTexts("A1:A7")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResultExcludeFormat, CalcUtil.getCellTexts("A1:A7")); + + // Save and close document + String saveTo = fullPath("temp/" + "SortOptionsIncludeFormats.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Original data", dataWithCurrencyFormats, CalcUtil.getCellTexts("$Sheet1.$A1:$A7")); + assertArrayEquals("Saved sorted result exclude format", expectedSortedResultExcludeFormat, CalcUtil.getCellTexts("$Sheet2.$A1:$A7")); + } + + /** + * Test sort options: multiple sort, data overlap + * @throws Exception + */ + @Test + public void testSortOptionsMultipleSortDataOverlap() throws Exception{ + + // Input some data + String[][] data1 = new String[][] { + {"D"}, + {"C"}, + {"B"}, + {"A"}, + {"E"}, + }; + String[][] expectedSortedResult1 = new String[][] { + {"A"}, + {"B"}, + {"C"}, + {"D"}, + {"E"}, + }; + String[][] data2 = new String[][] { + {"4"}, + {"2"}, + {"5"}, + {"1"}, + {"3"}, + }; + String[][] expectedSortedResultDataOverlap = new String[][] { + {"A"}, + {"B"}, + {"C"}, + {"1"}, + {"2"}, + {"3"}, + {"4"}, + {"5"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("DCBAE"); + + // "Data->Sort...", uncheck "Range contains column labels", sort first by "Column A", "Ascending" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.uncheck(); + SortPage.select(); + SortPage_By1.select("Column A"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result", expectedSortedResult1, CalcUtil.getCellTexts("A1:A5")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data1, CalcUtil.getCellTexts("A1:A5")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult1, CalcUtil.getCellTexts("A1:A5")); + + // Input data2 into same sheet, data1 and data2 are not overlapped + CalcUtil.selectRange("G10"); + typeKeys("42513"); + + // Focus on data2, "Data->Sort...", "Copy result to" partially overlap with data1, sort first by "Column G", "Ascending" + CalcUtil.selectRange("G10"); + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.uncheck(); + SortOptionsPage_CopyResultTo.check(); + SortOptionsPage_CopyResultToEdit.setText("A4"); + SortPage.select(); + SortPage_By1.select("Column G"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result data overlap", expectedSortedResultDataOverlap, CalcUtil.getCellTexts("A1:A8")); + + // Save and close document + String saveTo = fullPath("temp/" + "SortOptionsMultipleSortDataOverlap.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Saved sorted result", expectedSortedResultDataOverlap, CalcUtil.getCellTexts("A1:A8")); + assertArrayEquals("Original data2", data2, CalcUtil.getCellTexts("G10:G14")); + } + + /** + * Test sort options: multiple sort, no data overlap, sort parameter saved correctly + * @throws Exception + */ + @Test + public void testSortOptionsMultipleSortSortParameterSaved() throws Exception{ + + // Input some data + String[][] data1 = new String[][] { + {"D"}, + {"C"}, + {"B"}, + {"A"}, + {"E"}, + }; + String[][] expectedSortedResult1 = new String[][] { + {"A"}, + {"B"}, + {"C"}, + {"D"}, + {"E"}, + }; + String[][] data2 = new String[][] { + {"Numbers"}, + {"4"}, + {"2"}, + {"5"}, + {"1"}, + {"3"}, + }; + String[][] expectedSortedResult2 = new String[][] { + {"Numbers"}, + {"1"}, + {"2"}, + {"3"}, + {"4"}, + {"5"}, + }; + CalcUtil.selectRange("A1"); + typeKeys("DCBAE"); + + // "Data->Sort...", uncheck "Range contains column labels", check "Case sensitive" and "Include formats", sort first by "Column A", "Ascending" + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.uncheck(); + SortOptionsPage_CaseSensitive.check(); + SortOptionsPage_IncludeFormats.check(); + SortPage.select(); + SortPage_By1.select("Column A"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result1", expectedSortedResult1, CalcUtil.getCellTexts("A1:A5")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data1, CalcUtil.getCellTexts("A1:A5")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult1, CalcUtil.getCellTexts("A1:A5")); + + // Input data2 into same sheet, data1 and data2 are not overlapped + CalcUtil.selectRange("G10"); + typeKeys("Numbers42513"); + + // Focus on data2, "Data->Sort...", check "Range contains column labels", uncheck "Case sensitive" and "Include formats", sort first by "Numbers", "Ascending" + CalcUtil.selectRange("G10"); + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + SortOptionsPage_RangeContainsColumnLabels.check(); + SortOptionsPage_CaseSensitive.uncheck(); + SortOptionsPage_IncludeFormats.uncheck(); + SortPage.select(); + SortPage_By1.select("Numbers"); + SortPage_Ascending1.check(); + SortPage.ok(); + + // Verify sorted result + assertArrayEquals("Sorted result2", expectedSortedResult2, CalcUtil.getCellTexts("G10:G15")); + + // Uodo/redo + calc.menuItem("Edit->Undo: Sort").select(); + assertArrayEquals("Undo sorted result", data2, CalcUtil.getCellTexts("G10:G15")); + calc.menuItem("Edit->Redo: Sort").select(); + assertArrayEquals("Redo sorted result", expectedSortedResult2, CalcUtil.getCellTexts("G10:G15")); + + // Open sort dialog, check its setting + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + assertTrue("Range contains column labels should be checked", SortOptionsPage_RangeContainsColumnLabels.isChecked()); + assertFalse("Case sensitive should not be checked", SortOptionsPage_CaseSensitive.isChecked()); + assertFalse("Include formats should not be checked", SortOptionsPage_IncludeFormats.isChecked()); + SortOptionsPage.ok(); + + // Save and close document + String saveTo = fullPath("temp/" + "SortOptionsMultipleSortParameterSaved.ods"); + calc.menuItem("File->Save As...").select(); + FileUtil.deleteFile(saveTo); + submitSaveDlg(saveTo); + calc.menuItem("File->Close").select(); + openStartcenter(); + + // Reopen and verify sorted result and sort parameters + startcenter.menuItem("File->Open...").select(); + submitOpenDlg(saveTo); + calc.waitForExistence(10, 2); + assertArrayEquals("Saved sorted result1", expectedSortedResult1, CalcUtil.getCellTexts("A1:A5")); + assertArrayEquals("Saved sorted result2", expectedSortedResult2, CalcUtil.getCellTexts("G10:G15")); + calc.menuItem("Data->Sort...").select(); + SortOptionsPage.select(); + assertTrue("Range contains column labels should be checked", SortOptionsPage_RangeContainsColumnLabels.isChecked()); + assertFalse("Case sensitive should not be checked", SortOptionsPage_CaseSensitive.isChecked()); + assertFalse("Include formats should not be checked", SortOptionsPage_IncludeFormats.isChecked()); + SortOptionsPage.ok(); + } + +} Added: incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogDefaultValue.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogDefaultValue.java?rev=1364479&view=auto ============================================================================== --- incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogDefaultValue.java (added) +++ incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogDefaultValue.java Mon Jul 23 02:49:36 2012 @@ -0,0 +1,90 @@ +/************************************************************** + * + * 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()); + } + +} + Added: incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogSetting.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogSetting.java?rev=1364479&view=auto ============================================================================== --- incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogSetting.java (added) +++ incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValidityDialogSetting.java Mon Jul 23 02:49:36 2012 @@ -0,0 +1,639 @@ +/************************************************************** + * + * 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.*; +import static testlib.UIMap.*; + +import java.io.File; + +import org.junit.After; +import static org.junit.Assert.*; +import static org.openoffice.test.vcl.Tester.*; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Ignore; +import org.junit.Test; +import org.openoffice.test.vcl.IDList; +import org.openoffice.test.vcl.widgets.VclMessageBox; + +import testlib.CalcUtil; +import testlib.Log; + + +public class ValidityDialogSetting { + private static IDList idList = new IDList(new File("./ids")); + public static final VclMessageBox ActiveMsgBox = new VclMessageBox(idList.getId("UID_ACTIVE"), "Message on message box."); + + @Rule + public Log LOG = new Log(); + + @Before + public void setUp() throws Exception { + app.start(); + + // New a spreadsheet, select cell range, open Validity dialog + startcenter.menuItem("File->New->Spreadsheet").select(); + CalcUtil.selectRange("Sheet1.A1:C5"); + calc.menuItem("Data->Validity...").select(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + /** + * test Allow not between Date type in Validity. + */ + @Test + public void testAllowDateNotBetween() { + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Date"); + SC_ValidityDecimalCompareOperator.select("not between"); + SC_ValiditySourceInput.setText("01/01/08"); + SC_ValidityMaxValueInput.setText("03/01/08"); + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorMessageTitle.setText("Stop to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("12/31/07"); + typeKeys(""); + assertEquals("12/31/07",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("03/02/08"); + typeKeys(""); + assertEquals("03/02/08",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A3"); + SC_InputBar_Input.activate(); + typeKeys("01/01/08"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A3")); + + CalcUtil.selectRange("Sheet1.A4"); + SC_InputBar_Input.activate(); + typeKeys("03/01/08"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A4")); + + CalcUtil.selectRange("Sheet1.A5"); + SC_InputBar_Input.activate(); + typeKeys("01/02/08"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A5")); + + CalcUtil.selectRange("Sheet1.B1"); + SC_InputBar_Input.activate(); + typeKeys("02/29/08"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B1")); + + CalcUtil.selectRange("Sheet1.B2"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B2")); + + CalcUtil.selectRange("Sheet1.B3"); + SC_InputBar_Input.activate(); + typeKeys("39448"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B3")); + } + + /** + * test Allow Decimal equal in Validity. + */ + @Test + public void testAllowDecimalEqual() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Decimal"); + SC_ValidityDecimalCompareOperator.select("equal"); + SC_ValiditySourceInput.setText("0.33333333"); + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorMessageTitle.setText("Stop to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("0.33333333"); + typeKeys(""); + assertEquals("0.33333333",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("=1/3"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A3"); + SC_InputBar_Input.activate(); + typeKeys("0.3"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A3")); + + CalcUtil.selectRange("Sheet1.A4"); + SC_InputBar_Input.activate(); + typeKeys("0.333333333"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A4")); + + CalcUtil.selectRange("Sheet1.B2"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B2")); + } + + /** + * test Allow Text length, greater than or equal to in Validity. + */ + @Test + public void testAllowGreaterTextLength() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Text length"); + SC_ValidityDecimalCompareOperator.select("greater than or equal to"); + SC_ValiditySourceInput.setText("10"); + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorMessageTitle.setText("Stop to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("testtesttesttest"); + typeKeys(""); + assertEquals("testtesttesttest",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("test test "); + typeKeys(""); + assertEquals("test test ",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A4"); + SC_InputBar_Input.activate(); + typeKeys(" "); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A4")); + + CalcUtil.selectRange("Sheet1.A3"); + SC_InputBar_Input.activate(); + typeKeys("Testatest"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A3")); + } + + /** + * test Allow Text length, less than in Validity. + */ + @Ignore("Bug 93128") + public void testAllowLessThanTextLength() { + + calc.menuItem("Data->Validity...").select(); + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Text length"); + SC_ValidityDecimalCompareOperator.select("less than"); + SC_ValiditySourceInput.setText("10"); + + SC_ValidityInputHelpTabPage.select(); + SC_ValidityInputHelpCheckbox.check(); + SC_ValidityInputHelpTitle.setText("Help Info Title"); + SC_ValidityHelpMessage.setText("help info"); + + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorAlertActionList.select("Information"); + SC_ValidityErrorMessageTitle.setText("Notes to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("testtesttesttest"); + ActiveMsgBox.ok(); + assertEquals("testtesttesttest",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("sfsafsddddddd"); + ActiveMsgBox.cancel(); + assertEquals("",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("10"); + assertEquals("10",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A3"); + SC_InputBar_Input.activate(); + typeKeys("ok"); + assertEquals("ok",CalcUtil.getCellText("Sheet1.A3")); + } + + /** + * test Allow list. + */ + @Test + public void testAllowListSpecialChar() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("List"); + SC_ValidityEntries.focus(); + typeKeys("a"); + typeKeys(""); + typeKeys("b"); + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorMessageTitle.setText("Stop to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaTabpage.ok(); + + calc.rightClick(1, 1); + typeKeys(""); + typeKeys(""); // Choose a + assertEquals("a",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.B2"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B2")); + } + + /** + * test Allow time between in Validity. + */ + @Test + public void testAllowTimeBetween() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Time"); + SC_ValidityDecimalCompareOperator.select("between"); + SC_ValiditySourceInput.setText("27:00"); + SC_ValidityMaxValueInput.setText("21:00"); + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorMessageTitle.setText("Stop to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("21:00"); + typeKeys(""); + assertEquals("09:00:00 PM",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("27:00"); + typeKeys(""); + assertEquals("27:00:00",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A3"); + SC_InputBar_Input.activate(); + typeKeys("1.125"); + typeKeys(""); + assertEquals("1.125",CalcUtil.getCellText("Sheet1.A3")); + + CalcUtil.selectRange("Sheet1.A4"); + SC_InputBar_Input.activate(); + typeKeys("0.875"); + typeKeys(""); + assertEquals("0.875",CalcUtil.getCellText("Sheet1.A4")); + + CalcUtil.selectRange("Sheet1.B1"); + SC_InputBar_Input.activate(); + typeKeys("03:00:01"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B1")); + + CalcUtil.selectRange("Sheet1.B2"); + SC_InputBar_Input.activate(); + typeKeys("20:59:59"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B2")); + + CalcUtil.selectRange("Sheet1.B3"); + SC_InputBar_Input.activate(); + typeKeys("1.126"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B3")); + + CalcUtil.selectRange("Sheet1.B4"); + SC_InputBar_Input.activate(); + typeKeys("0.874"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B4")); + + CalcUtil.selectRange("Sheet1.C1"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.C1")); + + CalcUtil.selectRange("Sheet1.C2"); + SC_InputBar_Input.activate(); + typeKeys("24:00"); + typeKeys(""); + assertEquals("24:00:00",CalcUtil.getCellText("Sheet1.C2")); + + CalcUtil.selectRange("Sheet1.C3"); + SC_InputBar_Input.activate(); + typeKeys("12:00"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.C3")); + } + + /** + * test Allow time Greater than and equal to in Validity. + */ + @Test + public void testAllowTimeGreaterThan() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Time"); + SC_ValidityDecimalCompareOperator.select("greater than or equal to"); + SC_ValiditySourceInput.setText("8:00"); + + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorAlertActionList.select("Warning"); + + SC_ValidityErrorMessageTitle.setText("warning to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("7:30"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("07:30:00 AM",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("6:00"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.cancel(); + assertEquals("",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.A3"); + SC_InputBar_Input.activate(); + typeKeys("8:00"); + typeKeys(""); + assertEquals("08:00:00 AM",CalcUtil.getCellText("Sheet1.A3")); + } + + /** + * test Allow whole number, less than or equal to in Validity. + */ + @Test + public void testAllowWholeNumLessThan() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Whole Numbers"); + SC_ValidityDecimalCompareOperator.select("less than or equal"); + SC_ValiditySourceInput.setText("100"); + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorMessageTitle.setText("Stop to enter"); + SC_ValidityErrorMessage.setText("Invalid value"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("99"); + typeKeys(""); + assertEquals("99",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.A2"); + SC_InputBar_Input.activate(); + typeKeys("100"); + typeKeys(""); + assertEquals("100",CalcUtil.getCellText("Sheet1.A2")); + + CalcUtil.selectRange("Sheet1.B1"); + SC_InputBar_Input.activate(); + typeKeys("101"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B1")); + + CalcUtil.selectRange("Sheet1.B2"); + SC_InputBar_Input.activate(); + typeKeys("45.5"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.B2")); + + CalcUtil.selectRange("Sheet1.C1"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + assertEquals("Invalid value",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.C1")); + } + + /** + * test default message of Error Alert in Validity. + */ + @Test + public void testDefaultErrorAlertMessage() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Decimal"); + SC_ValidityDecimalCompareOperator.select("equal"); + SC_ValiditySourceInput.setText("1"); + + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorAlertActionList.select("Stop"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("13"); + typeKeys(""); + assertEquals("OpenOffice.org Calc",ActiveMsgBox.getCaption()); + assertEquals("Invalid value.",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A1")); + } + + /** + * test uncheck Error Alert in Validity. + */ + @Test + public void testUncheckErrorAlert() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Decimal"); + SC_ValidityDecimalCompareOperator.select("equal"); + SC_ValiditySourceInput.setText("1"); + + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.uncheck(); + SC_ValidityErrorAlertActionList.select("Stop"); + SC_ValidityErrorAlertTabPage.ok(); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("13"); + typeKeys(""); + assertEquals("13",CalcUtil.getCellText("Sheet1.A1")); + } + + /** + * test Cell range source picker in Validity. Input from Edit Box. + */ + @Test + public void testValidityCellRangeSourcePicker() { + + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Cell range"); + SC_ValiditySourcePicker.click(); + assertEquals(false,SC_ValidityCriteriaAllowList.exists()); + SC_ValiditySourceInput.setText("$Sheet1.$E$2:$G$5"); + SC_ValiditySourcePicker.click(); + assertEquals(true,SC_ValidityCriteriaAllowList.exists()); + + SC_ValidityErrorAlertTabPage.select(); + SC_ValidityShowErrorMessage.check(); + SC_ValidityErrorAlertActionList.select("Stop"); + SC_ValidityErrorAlertTabPage.ok(); + + // calc.focus(); + CalcUtil.selectRange("Sheet1.E2"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + + CalcUtil.selectRange("Sheet1.A1"); + SC_InputBar_Input.activate(); + typeKeys("test32"); + typeKeys(""); + assertEquals("Invalid value.",ActiveMsgBox.getMessage()); + ActiveMsgBox.ok(); + assertEquals("",CalcUtil.getCellText("Sheet1.A1")); + + CalcUtil.selectRange("Sheet1.B1"); + SC_InputBar_Input.activate(); + typeKeys("test"); + typeKeys(""); + assertEquals("test",CalcUtil.getCellText("Sheet1.B1")); + } + + /** + * test Allow Blank cell Checkbox in Validity. + */ + @Test + public void testAllowBlankCells() { + SC_ValidityCriteriaTabpage.select(); + SC_ValidityCriteriaAllowList.select("Cell range"); + SC_ValiditySourceInput.setText("$E$1:$E$5"); + SC_ValidityAllowBlankCells.check(); + SC_ValidityCriteriaTabpage.ok(); + + CalcUtil.selectRange("Sheet1.E1"); + typeKeys("AAAAA"); + + CalcUtil.selectRange("Sheet1.A1"); + typeKeys("A"); + CalcUtil.selectRange("Sheet1.D1"); + SC_InputBar_Input.activate(); + typeKeys(""); + assertEquals("",CalcUtil.getCellText("Sheet1.D1")); + + CalcUtil.selectRange("Sheet1.B1"); + calc.menuItem("Data->Validity...").select(); + SC_ValidityCriteriaTabpage.select(); + SC_ValidityAllowBlankCells.uncheck(); + typeKeys(""); + + CalcUtil.selectRange("Sheet1.B1"); + SC_InputBar_Input.activate(); + typeKeys(""); + typeKeys(""); + } +} + Added: incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValiditySampleFile.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValiditySampleFile.java?rev=1364479&view=auto ============================================================================== --- incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValiditySampleFile.java (added) +++ incubator/ooo/trunk/main/test/testoo/src/testcase/sc/validity/ValiditySampleFile.java Mon Jul 23 02:49:36 2012 @@ -0,0 +1,116 @@ +/************************************************************** + * + * 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(""); + typeKeys(""); + + 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(""); + + 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"); + CalcUtil.selectRange("Sheet1.F17"); + typeKeys("Test"); + + assertEquals("Test",CalcUtil.getCellText("F17")); + } +}