def test_tdf117879(self): self.ui_test.create_doc_in_start_center("calc") calcDoc = self.xUITest.getTopFocusWindow() gridwin = calcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) type_text(gridwin, "=SUM({A1},2,3,4,5}") # Without the fix in place, this dialog wouldn't have been displayed self.ui_test.execute_blocking_action(gridwin.executeAction, args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), dialog_element="yes") document = self.ui_test.get_component() self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5)") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) type_text(gridwin, "=SUM({A1},2,3,4,5}") self.ui_test.execute_blocking_action(gridwin.executeAction, args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), dialog_element="no") document = self.ui_test.get_component() self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5})") self.ui_test.close_doc()
def test_tdf88735(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf88735.ods")) XcalcDoc = self.xUITest.getTopFocusWindow() document = self.ui_test.get_component() gridwin = XcalcDoc.getChild("grid_window") # 1 select all cells self.xUITest.executeCommand( ".uno:SelectAll") #use uno command Menu Edit->Select All # 2 invoke sub-total menu and select none self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") xDialog = self.xUITest.getTopFocusWindow() xGroupBy = xDialog.getChild("group_by") props = {"TEXT": "- none -"} actionProps = mkPropertyValues(props) xGroupBy.executeAction("SELECT", actionProps) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) # 2 invoke sort menu and... crash self.ui_test.execute_dialog_through_command(".uno:DataSort") xDialog = self.xUITest.getTopFocusWindow() xCancelBtn = xDialog.getChild("cancel") self.ui_test.close_dialog_through_button(xCancelBtn) self.assertEqual( get_cell_by_position(document, 0, 0, 8).getString(), "z") self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 8) self.ui_test.close_doc()
def test_multiple_operations_one_variable(self): self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #enter data enter_text_to_cell(xGridWindow, "B1", "10") enter_text_to_cell(xGridWindow, "B2", "2") enter_text_to_cell(xGridWindow, "B3", "10000") enter_text_to_cell(xGridWindow, "B4", "2000") enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") enter_text_to_cell(xGridWindow, "D2", "500") enter_text_to_cell(xGridWindow, "D3", "1000") enter_text_to_cell(xGridWindow, "D4", "1500") enter_text_to_cell(xGridWindow, "D5", "2000") enter_text_to_cell(xGridWindow, "D6", "2500") enter_text_to_cell(xGridWindow, "D7", "3000") enter_text_to_cell(xGridWindow, "D8", "3500") enter_text_to_cell(xGridWindow, "D9", "4000") enter_text_to_cell(xGridWindow, "D10", "4500") enter_text_to_cell(xGridWindow, "D11", "5000") #Select the range D2:E11 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"})) #Choose Data > Multiple Operations. self.ui_test.execute_modeless_dialog_through_command( ".uno:TableOperationDialog") xDialog = self.xUITest.getTopFocusWindow() #Formulas = B5 ; Column input cell = B4 formulas = xDialog.getChild("formulas") col = xDialog.getChild("col") formulas.executeAction("TYPE", mkPropertyValues({"TEXT": "$B$5"})) col.executeAction("TYPE", mkPropertyValues({"TEXT": "$B$4"})) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #verify self.assertEqual( get_cell_by_position(document, 0, 4, 1).getValue(), -6000) self.assertEqual( get_cell_by_position(document, 0, 4, 2).getValue(), -2000) self.assertEqual( get_cell_by_position(document, 0, 4, 3).getValue(), 2000) self.assertEqual( get_cell_by_position(document, 0, 4, 4).getValue(), 6000) self.assertEqual( get_cell_by_position(document, 0, 4, 5).getValue(), 10000) self.assertEqual( get_cell_by_position(document, 0, 4, 6).getValue(), 14000) self.assertEqual( get_cell_by_position(document, 0, 4, 7).getValue(), 18000) self.assertEqual( get_cell_by_position(document, 0, 4, 8).getValue(), 22000) self.assertEqual( get_cell_by_position(document, 0, 4, 9).getValue(), 26000) self.assertEqual( get_cell_by_position(document, 0, 4, 10).getValue(), 30000) self.ui_test.close_doc()
def test_tdf39959_find_replace_all_sheets(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf35020.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") xDialog = self.xUITest.getTopFocusWindow() searchterm = xDialog.getChild("searchterm") searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"X6"})) replaceterm = xDialog.getChild("replaceterm") replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A6"})) #replace textbox allsheets = xDialog.getChild("allsheets") allsheets.executeAction("CLICK", tuple()) calcsearchin = xDialog.getChild("calcsearchin") props = {"TEXT": "Formulas"} actionProps = mkPropertyValues(props) calcsearchin.executeAction("SELECT", actionProps) replaceall = xDialog.getChild("replaceall") replaceall.executeAction("CLICK", tuple()) xcloseBtn = xDialog.getChild("close") self.ui_test.close_dialog_through_button(xcloseBtn) #verify Sheet1.A13 A14 = 2 self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 2) #Undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 1) self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 1) self.ui_test.close_doc()
def test_tdf91217_crash_deleting_rows(self): # FIXME disable this will it's clear what existing problem did this test uncover. return calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf91217.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Select rows 76-1125 in sheet 3 (Daily), right click, Delete Rows. Instant crash. gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A76:A1125"})) self.xUITest.executeCommand(".uno:SelectRow") #delete rows self.xUITest.executeCommand(".uno:DeleteRows") #A1 should be "Dist" self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "Dist") #- Undo-redo self.xUITest.executeCommand(".uno:Undo") self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "Dist") self.xUITest.executeCommand(".uno:Redo") self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "Dist") self.ui_test.close_doc()
def test_tdf67346_undo_paste_text_input_line(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() # type 'Apple' in A1 enter_text_to_cell(gridwin, "A1", "Apple") # input line: copy the text from there xInputWin = xCalcDoc.getChild("sc_input_window") xInputWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) # Ctrl-V self.xUITest.executeCommand(".uno:Paste") self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "Apple") self.assertEqual( get_cell_by_position(document, 0, 0, 1).getString(), "Apple") self.assertEqual(get_state_as_dict(xInputWin)["Text"], "Apple") #Ctrl-Z self.xUITest.executeCommand(".uno:Undo") self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "Apple") self.assertEqual( get_cell_by_position(document, 0, 0, 1).getString(), "") self.assertEqual(get_state_as_dict(xInputWin)["Text"], "") self.ui_test.close_doc()
def test_tdf73006_text_to_columns(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Add data enter_text_to_cell(gridwin, "A2", "A B") #select column A gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") # Data - Text to Columns self.ui_test.execute_dialog_through_command(".uno:TextToColumns") xDialog = self.xUITest.getTopFocusWindow() xspace = xDialog.getChild("space") if (get_state_as_dict(xspace)["Selected"]) == "false": xspace.executeAction("CLICK", tuple()) # Click Ok xOK = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOK) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf53482_Range_contains_column_headings_file(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf53482.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #1. Highlight cells to be sorted A8:J124 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"})) #2. Click Data menu, Sort self.ui_test.execute_dialog_through_command(".uno:DataSort") xDialog = self.xUITest.getTopFocusWindow() xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "1") #3. On Options tab, tick 'Range contains column labels' xHeader = xDialog.getChild("header") xHeader.executeAction("CLICK", tuple()) if (get_state_as_dict(xHeader)["Selected"]) == "false": xHeader.executeAction("CLICK", tuple()) #4. On Sort Criteria tab, set appropriate criteria select_pos(xTabs, "0") xDown = xDialog.getChild("down") xDown.executeAction("CLICK", tuple()) xSortKey1 = xDialog.getChild("sortlb") props = {"TEXT": "Occupation"} actionProps = mkPropertyValues(props) xSortKey1.executeAction("SELECT", actionProps) #5. Click Ok xOK = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOK) #6. Expected behavior: Ignore column labels when sorting self.assertEqual(get_cell_by_position(document, 0, 6, 7).getString(), "Occupation") self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "Travel Industry") self.assertEqual(get_cell_by_position(document, 0, 6, 123).getString(), "13") self.ui_test.close_doc()
def test_tdf46138(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Choose a column, gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") #select 'edit'>'fill'>'series'>Starting Value '1' then "OK", self.ui_test.execute_dialog_through_command(".uno:FillSeries") xDialog = self.xUITest.getTopFocusWindow() xStart = xDialog.getChild("startValue") xStart.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) xOK = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOK) self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "1") #then "Ctrl+Z"/ undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf125440(self): # In order to simulate copy&paste from external source, # import the text in Writer, copy it and paste it in Calc writer_doc = self.ui_test.load_file( get_url_for_data_file("tdf125440.odt")) self.xUITest.executeCommand(".uno:SelectAll") self.xUITest.executeCommand(".uno:Copy") # Close the document self.xUITest.executeCommand(".uno:CloseDoc") calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:PasteUnformatted") # Without the fix in place, this test would have failed with # AssertionError: 'Row' != '"Row"' self.assertEqual("Row", get_cell_by_position(document, 0, 0, 0).getString()) self.assertEqual("", get_cell_by_position(document, 0, 1, 0).getString()) self.assertEqual("", get_cell_by_position(document, 0, 2, 0).getString()) self.assertEqual("50", get_cell_by_position(document, 0, 3, 0).getString()) self.ui_test.close_doc()
def test_tdf57274_tdf116385_row_only(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf57274.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #* Source Cells, range B6..E6 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B6:E6"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B11"})) self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") xDialog = self.xUITest.getTopFocusWindow() #We paste here using Paste Special with 'Link' Checkbox activated xLink = xDialog.getChild("link") xLink.executeAction("CLICK", tuple()) xOkBtn = xDialog.getChild("ok") # self.ui_test.close_dialog_through_button(xOkBtn) def handle_confirm_dlg(dialog): xOKBtn = dialog.getChild("yes") self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ()), dialog_handler=handle_confirm_dlg) #we would expect a reference to cell E6 here and a zero being displayed, but the cell is also simply blank. self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 0) self.assertEqual(get_cell_by_position(document, 0, 4, 10).getFormula(), "=$Sheet1.$E$6") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_clear_cells_all(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A1", "aa") enter_text_to_cell(gridwin, "A2", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) self.xUITest.executeCommand(".uno:Bold") self.ui_test.execute_dialog_through_command(".uno:Delete") xDialog = self.xUITest.getTopFocusWindow() xdeleteall = xDialog.getChild("deleteall") xtext = xDialog.getChild("text") xdatetime = xDialog.getChild("datetime") xcomments = xDialog.getChild("comments") xobjects = xDialog.getChild("objects") xnumbers = xDialog.getChild("numbers") xformulas = xDialog.getChild("formulas") xformats = xDialog.getChild("formats") if (get_state_as_dict(xdeleteall)["Selected"]) == "false": xdeleteall.executeAction("CLICK", tuple()) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") self.ui_test.close_doc()
def test_tdf31805_delete_column_merged(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf31805.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #1. open "sample.ods" #2. click 'G1' #3. Menu 'edit -> Delete Cell - Delete entire Column' #expected: Column with cell containing "g" will be deleted, # a merged cell range will remainlect row 1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) self.xUITest.executeCommand(".uno:DeleteColumns") #verify. C5:F11 should be merged #isMerged returns true if this cell is merged with another cell. self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 self.assertEqual(get_cell_by_position(document, 0, 6, 4).getIsMerged(), False) #G5 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A11"})) self.xUITest.executeCommand(".uno:DeleteRows") self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) self.xUITest.executeCommand(".uno:DeleteColumns") self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 self.ui_test.close_doc()
def test_tdf57274_tdf116385_row_only(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf57274.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #* Source Cells, range B6..E6 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B6:E6"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B11"})) self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") xDialog = self.xUITest.getTopFocusWindow() #We paste here using Paste Special with 'Link' Checkbox activated xLink = xDialog.getChild("link") xLink.executeAction("CLICK", tuple()) xOkBtn = xDialog.getChild("ok") # self.ui_test.close_dialog_through_button(xOkBtn) def handle_confirm_dlg(dialog): xOKBtn = dialog.getChild("yes") self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ()), dialog_handler=handle_confirm_dlg) #we would expect a reference to cell E6 here and a zero being displayed, but the cell is also simply blank. self.assertEqual( get_cell_by_position(document, 0, 4, 10).getValue(), 0) self.assertEqual( get_cell_by_position(document, 0, 4, 10).getFormula(), "=$Sheet1.$E$6") self.ui_test.close_doc()
def test_tdf39959_find_replace_all_sheets(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf35020.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") xDialog = self.xUITest.getTopFocusWindow() searchterm = xDialog.getChild("searchterm") searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"X6"})) replaceterm = xDialog.getChild("replaceterm") replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A6"})) #replace textbox allsheets = xDialog.getChild("allsheets") allsheets.executeAction("CLICK", tuple()) calcsearchin = xDialog.getChild("calcsearchin") select_by_text(calcsearchin, "Formulas") replaceall = xDialog.getChild("replaceall") replaceall.executeAction("CLICK", tuple()) xcloseBtn = xDialog.getChild("close") self.ui_test.close_dialog_through_button(xcloseBtn) #verify Sheet1.A13 A14 = 2 self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 2) #Undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 1) self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 1) self.ui_test.close_doc()
def _regression_check(self, data_groupedby_column=True): calc_doc = self.ui_test.load_file( get_url_for_data_file("regression.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() # Initially the final check status is "FALSE" (failed). self.assertEqual( get_cell_by_position(document, 14, 1, 6).getString(), "FALSE", "Check status must be FALSE before the test") self._do_regression(regression_type="LINEAR", data_groupedby_column=data_groupedby_column, calc_intercept=True) self._do_regression(regression_type="LINEAR", data_groupedby_column=data_groupedby_column, calc_intercept=False) self._do_regression(regression_type="LOG", data_groupedby_column=data_groupedby_column) self._do_regression(regression_type="POWER", data_groupedby_column=data_groupedby_column) self.assertEqual( get_cell_by_position(document, 14, 1, 6).getString(), "TRUE", "One of more of the checks failed for data_groupedby_column = {}, manually try with the document" .format(data_groupedby_column)) self.ui_test.close_doc()
def test_tdf31805_delete_column_merged(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf31805.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #1. open "sample.ods" #2. click 'G1' #3. Menu 'edit -> Celete Cell - Delete entire Column' #expected: Column with cell containing "g" will be deleted, # a merged cell range will remainlect row 1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) self.xUITest.executeCommand(".uno:DeleteColumns") #verify. C5:F11 should be merged #isMerged returns true if this cell is merged with another cell. self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 self.assertEqual(get_cell_by_position(document, 0, 6, 4).getIsMerged(), False) #G5 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A11"})) self.xUITest.executeCommand(".uno:DeleteRows") self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) self.xUITest.executeCommand(".uno:DeleteColumns") self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 self.ui_test.close_doc()
def test_td99627_natural_sort(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99627.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #Open sort dialog by DATA - SORT self.ui_test.execute_dialog_through_command(".uno:DataSort") xDialog = self.xUITest.getTopFocusWindow() xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "1") xNatural = xDialog.getChild("naturalsort") xdown = xDialog.getChild("down") xNatural.executeAction("CLICK", tuple()) select_pos(xTabs, "0") xdown.executeAction("CLICK", tuple()) xOk = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOk) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2998") self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "1") #UNDO self.xUITest.executeCommand(".uno:Undo") #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "1") self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "2998") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf104117(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") xDialog = self.xUITest.getTopFocusWindow() xcellrangeedit = xDialog.getChild("cell-range-edit") xdistributioncombo = xDialog.getChild("distribution-combo") xparameter1spin = xDialog.getChild("parameter1-spin") xparameter2spin = xDialog.getChild("parameter2-spin") xenableseedcheck = xDialog.getChild("enable-seed-check") xseedspin = xDialog.getChild("seed-spin") xenableroundingcheck = xDialog.getChild("enable-rounding-check") xdecimalplacesspin = xDialog.getChild("decimal-places-spin") xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) select_by_text(xdistributioncombo, "Uniform Integer") xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"1000000000000000000000000000000000000000000000"})) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #Verify self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), True) self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), True) #undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) self.ui_test.close_doc()
def test_tdf73006_text_to_columns(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Add data enter_text_to_cell(gridwin, "A2", "A B") #select column A gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") # Data - Text to Columns self.ui_test.execute_dialog_through_command(".uno:TextToColumns") xDialog = self.xUITest.getTopFocusWindow() xspace = xDialog.getChild("space") if (get_state_as_dict(xspace)["Selected"]) == "false": xspace.executeAction("CLICK", tuple()) # Click Ok xOK = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOK) #Verify self.assertEqual( get_cell_by_position(document, 0, 0, 1).getString(), "A") self.assertEqual( get_cell_by_position(document, 0, 1, 1).getString(), "B") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf39959_find_replace_all_sheets(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf39959.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() # 1. Open a new document # 2. Enter "asdf" in A1 # 3. Activate Sheet2 # 4. Try Find-and-replace (Ctrl+Alt+F) to search for "asdf" # Whether the checkbox "in allen Tabellen suchen" is activated or not: LibO Calc never seems to find the text self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") xDialog = self.xUITest.getTopFocusWindow() searchterm = xDialog.getChild("searchterm") searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"asdf"})) replaceterm = xDialog.getChild("replaceterm") replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"bbb"})) #replace textbox allsheets = xDialog.getChild("allsheets") allsheets.executeAction("CLICK", tuple()) replaceall = xDialog.getChild("replaceall") replaceall.executeAction("CLICK", tuple()) # print(xDialog.getChildren()) xcloseBtn = xDialog.getChild("close") self.ui_test.close_dialog_through_button(xcloseBtn) #verify Sheet2.A1 = "bbb" self.assertEqual(get_cell_by_position(document, 1, 0, 0).getString(), "bbb ") self.assertEqual(get_cell_by_position(document, 1, 0, 2).getString(), "abc") #Undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual(get_cell_by_position(document, 1, 0, 0).getString(), "asdf ") self.ui_test.close_doc()
def test_tdf88735(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88735.ods")) XcalcDoc = self.xUITest.getTopFocusWindow() document = self.ui_test.get_component() gridwin = XcalcDoc.getChild("grid_window") # 1 select all cells self.xUITest.executeCommand(".uno:SelectAll")#use uno command Menu Edit->Select All # 2 invoke sub-total menu and select none self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") xDialog = self.xUITest.getTopFocusWindow() xGroupBy = xDialog.getChild("group_by") props = {"TEXT": "- none -"} actionProps = mkPropertyValues(props) xGroupBy.executeAction("SELECT", actionProps) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) # 2 invoke sort menu and... crash self.ui_test.execute_dialog_through_command(".uno:DataSort") xDialog = self.xUITest.getTopFocusWindow() xCancelBtn = xDialog.getChild("cancel") self.ui_test.close_dialog_through_button(xCancelBtn) self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "z") self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 8) self.ui_test.close_doc()
def test_tdf126577(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A20"})) self.ui_test.execute_dialog_through_command(".uno:FillSeries") xDialog = self.xUITest.getTopFocusWindow() self.assertEqual("true", get_state_as_dict(xDialog.getChild("down"))['Checked']) self.assertEqual("true", get_state_as_dict(xDialog.getChild("linear"))['Checked']) xStart = xDialog.getChild("startValue") xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) xEnd = xDialog.getChild("endValue") xEnd.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) xOK = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOK) for i in range(10): self.assertEqual(str(i + 1), get_cell_by_position(document, 0, 0, i).getString()) for i in range(10, 20): # Without the fix in place, this test would have failed with # AssertionError: '' != '#NUM!' self.assertEqual("", get_cell_by_position(document, 0, 0, i).getString()) self.ui_test.close_doc()
def test_Sorting_default_to_selected_TAB_B_column(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g enter_text_to_cell(gridwin, "A1", "Number") enter_text_to_cell(gridwin, "A2", "3") enter_text_to_cell(gridwin, "A3", "4") enter_text_to_cell(gridwin, "A4", "6") enter_text_to_cell(gridwin, "A5", "2") enter_text_to_cell(gridwin, "B1", "Misc") enter_text_to_cell(gridwin, "B2", "s") enter_text_to_cell(gridwin, "B3", "d") enter_text_to_cell(gridwin, "B4", "f") enter_text_to_cell(gridwin, "B5", "g") #Select Range A1:B5 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) #Move the active cell inside the range to column B by using the TAB key gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #Press toolbar button for ascending sorting self.xUITest.executeCommand(".uno:SortAscending") #Verify that the sortorder was determined for column B (Misc;d;f;g;s) self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") self.ui_test.close_doc()
def test_tdf114720(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") XcalcDoc = self.xUITest.getTopFocusWindow() document = self.ui_test.get_component() gridwin = XcalcDoc.getChild("grid_window") enter_text_to_cell(gridwin, "A1", "1") enter_text_to_cell(gridwin, "A2", "1") enter_text_to_cell(gridwin, "A3", "1") enter_text_to_cell(gridwin, "A4", "1") enter_text_to_cell(gridwin, "A5", "1") enter_text_to_cell(gridwin, "A6", "1") enter_text_to_cell(gridwin, "A7", "1") enter_text_to_cell(gridwin, "A8", "1") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A9"})) self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") xDialog = self.xUITest.getTopFocusWindow() xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) self.assertEqual( get_cell_by_position(document, 0, 0, 8).getString(), "") # check cancel button self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") xDialog = self.xUITest.getTopFocusWindow() xCancelBtn = xDialog.getChild("cancel") self.ui_test.close_dialog_through_button(xCancelBtn) self.ui_test.close_doc()
def test_natural_sorting_columns(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #enter data enter_text_to_cell(gridwin, "A1", "MW-2") enter_text_to_cell(gridwin, "B1", "MW-20") enter_text_to_cell(gridwin, "C1", "MW-1") enter_text_to_cell(gridwin, "D1", "MW-18") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D1"})) #Open sort dialog by DATA - SORT self.ui_test.execute_dialog_through_command(".uno:DataSort") xDialog = self.xUITest.getTopFocusWindow() xTabs = xDialog.getChild("tabcontrol") xleftright = xDialog.getChild("leftright") select_pos(xTabs, "1") xNatural = xDialog.getChild("naturalsort") xleftright.executeAction("CLICK", tuple()) if (get_state_as_dict(xNatural)["Selected"]) == "false": xNatural.executeAction("CLICK", tuple()) xOk = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOk) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1") self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "MW-2") self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "MW-18") self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-20") self.ui_test.close_doc()
def test_transpose(self): self.ui_test.create_doc_in_start_center("calc") xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") enter_text_to_cell(xGridWin, "B3", "abcd") enter_text_to_cell(xGridWin, "B4", "edfg") enter_text_to_cell(xGridWin, "C3", "35") enter_text_to_cell(xGridWin, "C4", "5678") xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"})) self.xUITest.executeCommand(".uno:Cut") xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") xPasteSpecialDlg = self.xUITest.getTopFocusWindow() xAllChkBox = xPasteSpecialDlg.getChild("paste_all") xAllChkBox.executeAction("CLICK", tuple()) xTransposeChkBox = xPasteSpecialDlg.getChild("transpose") xTransposeChkBox.executeAction("CLICK", tuple()) xOkBtn = xPasteSpecialDlg.getChild("ok") self.ui_test.close_dialog_through_button(xOkBtn) document = self.ui_test.get_component() self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "abcd") self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 35) self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "edfg") self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 5678) self.ui_test.close_doc()
def test_goalSeek(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("goalSeek.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B4"})) self.ui_test.execute_modeless_dialog_through_command( ".uno:GoalSeekDialog") xDialog = self.xUITest.getTopFocusWindow() xformulaedit = xDialog.getChild("formulaedit") xtarget = xDialog.getChild("target") xvaredit = xDialog.getChild("varedit") xtarget.executeAction("TYPE", mkPropertyValues({"TEXT": "15000"})) xvaredit.executeAction("TYPE", mkPropertyValues({"TEXT": "B1"})) xOKBtn = xDialog.getChild("ok") def handle_OK_dlg(dialog): print(dialog.getChildren()) xYesButn = dialog.getChild("yes") self.ui_test.close_dialog_through_button(xYesButn) self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), dialog_handler=handle_OK_dlg) #verify self.assertEqual( get_cell_by_position(document, 0, 1, 0).getValue(), 200000) self.assertEqual( get_cell_by_position(document, 0, 1, 3).getValue(), 15000) self.ui_test.close_doc()
def test_create_range_name_from_ui(self): self.ui_test.create_doc_in_start_center("calc") calcDoc = self.xUITest.getTopFocusWindow() gridwin = calcDoc.getChild("grid_window") enter_text_to_cell(gridwin, "A1", "1") enter_text_to_cell(gridwin, "B1", "1") enter_text_to_cell(gridwin, "C1", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) xPosWindow = calcDoc.getChild('pos_window') self.assertEqual('A1:C1', get_state_as_dict(xPosWindow)['Text']) xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) xPosWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "RANGE1"})) xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) self.assertEqual('RANGE1', get_state_as_dict(xPosWindow)['Text']) calcDoc = self.xUITest.getTopFocusWindow() gridwin = calcDoc.getChild("grid_window") document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A2", "=SUM(RANGE1)") self.assertEqual(3.0, get_cell_by_position(document, 0, 0, 1).getValue()) # Change the name self.ui_test.execute_dialog_through_command(".uno:DefineName") xDialog = self.xUITest.getTopFocusWindow() xNamesList = xDialog.getChild('names') self.assertEqual(1, len(xNamesList.getChildren())) xName = xDialog.getChild('name') self.assertEqual('RANGE1', get_state_as_dict(xName)["Text"]) xName.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) xName.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) xName.executeAction("TYPE", mkPropertyValues({"TEXT": "RANGE2"})) xOkBtn = xDialog.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) # tdf#87474 check the formula is updated after changing the name self.assertEqual("=SUM(RANGE2)", get_cell_by_position(document, 0, 0, 1).getFormula()) self.xUITest.executeCommand(".uno:Undo") self.assertEqual("=SUM(RANGE1)", get_cell_by_position(document, 0, 0, 1).getFormula()) self.ui_test.close_doc()
def test_tdf39650_F4_R1C1(self): #Bug 39650 - Shift+F4 conversion from relative to absolute does not work for R1C1 syntax calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog xDialogOpt = self.xUITest.getTopFocusWindow() xPages = xDialogOpt.getChild("pages") xCalcEntry = xPages.getChild('3') # Calc xCalcEntry.executeAction("EXPAND", tuple()) xCalcFormulaEntry = xCalcEntry.getChild('4') xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula formulasyntax = xDialogOpt.getChild("formulasyntax") #Excel R1C1 props = {"TEXT": "Excel R1C1"} actionProps = mkPropertyValues(props) formulasyntax.executeAction("SELECT", actionProps) xOKBtn = xDialogOpt.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #In cell R3C3 enter "xxx". enter_text_to_cell(gridwin, "C3", "xxx") # In cell R2C2 type = and then click on the xxx in R3C3. enter_text_to_cell(gridwin, "B2", "=R[1]C[1]") # With cell R2C2 still selected, type Shift-F4. gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) #F4 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) #This should change the formula in R2C2 from =R[1]C[1] to =R3C3. self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "xxx") enter_text_to_cell(gridwin, "A1", "=FORMULA(R[1]C[1])") self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=R3C3") #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog xDialogOpt = self.xUITest.getTopFocusWindow() xPages = xDialogOpt.getChild("pages") xCalcEntry = xPages.getChild('3') # Calc xCalcEntry.executeAction("EXPAND", tuple()) xCalcFormulaEntry = xCalcEntry.getChild('4') xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula formulasyntax = xDialogOpt.getChild("formulasyntax") #Excel R1C1 props = {"TEXT": "Calc A1"} actionProps = mkPropertyValues(props) formulasyntax.executeAction("SELECT", actionProps) xOKBtn = xDialogOpt.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc()
def test_tdf118206(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf118206.xlsx")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) self.xUITest.executeCommand(".uno:SelectColumn") self.xUITest.executeCommand(".uno:Paste") #verify self.assertEqual( get_cell_by_position(document, 0, 1, 0).getString(), "On Back Order") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 0) self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 1) #Undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual( get_cell_by_position(document, 0, 0, 0).getString(), "On Back Order") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 0) self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) self.assertEqual( get_cell_by_position(document, 0, 1, 0).getString(), "") self.assertEqual( get_cell_by_position(document, 0, 1, 1).getString(), "") self.assertEqual( get_cell_by_position(document, 0, 1, 7).getString(), "") self.ui_test.close_doc()
def test_tdf118206(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf118206.xlsx")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) self.xUITest.executeCommand(".uno:SelectColumn") self.xUITest.executeCommand(".uno:Paste") #verify self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "On Back Order") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 0) self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 1) #Undo self.xUITest.executeCommand(".uno:Undo") self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "On Back Order") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 0) self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "") self.assertEqual(get_cell_by_position(document, 0, 1, 7).getString(), "") self.ui_test.close_doc()
def test_tdf39650_F4_R1C1(self): #Bug 39650 - Shift+F4 conversion from relative to absolute does not work for R1C1 syntax calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog xDialogOpt = self.xUITest.getTopFocusWindow() xPages = xDialogOpt.getChild("pages") xCalcEntry = xPages.getChild('3') # Calc xCalcEntry.executeAction("EXPAND", tuple()) xCalcFormulaEntry = xCalcEntry.getChild('4') xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula formulasyntax = xDialogOpt.getChild("formulasyntax") #Excel R1C1 select_by_text(formulasyntax, "Excel R1C1") xOKBtn = xDialogOpt.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #In cell R3C3 enter "xxx". enter_text_to_cell(gridwin, "C3", "xxx") # In cell R2C2 type = and then click on the xxx in R3C3. enter_text_to_cell(gridwin, "B2", "=R[1]C[1]") # With cell R2C2 still selected, type Shift-F4. gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) #F4 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) #This should change the formula in R2C2 from =R[1]C[1] to =R3C3. self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "xxx") enter_text_to_cell(gridwin, "A1", "=FORMULA(R[1]C[1])") self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=R3C3") #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog xDialogOpt = self.xUITest.getTopFocusWindow() xPages = xDialogOpt.getChild("pages") xCalcEntry = xPages.getChild('3') # Calc xCalcEntry.executeAction("EXPAND", tuple()) xCalcFormulaEntry = xCalcEntry.getChild('4') xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula formulasyntax = xDialogOpt.getChild("formulasyntax") #Excel R1C1 select_by_text(formulasyntax, "Calc A1") xOKBtn = xDialogOpt.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc()
def test_tdf96432_chart_crash_transparency_error_bar_dialog(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf96432.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) gridwin.executeAction("ACTIVATE", tuple()) xChartMainTop = self.xUITest.getTopFocusWindow() xChartMain = xChartMainTop.getChild("chart_window") #Right-click on the chart; from the pop-up menu select "Format Y bars # The program presents dialog "Format Y bars", tab "Line". xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0") self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatYErrorBars"})) xDialog = self.xUITest.getTopFocusWindow() #Click on tab "Line". tabcontrol = xDialog.getChild("tabcontrol") select_pos(tabcontrol, "1") #Type a non-zero integer into the "Transparency:" Edit Field, or use the up arrow to select one xTransparency = xDialog.getChild("MTR_LINE_TRANSPARENT") xTransparency.executeAction("UP", tuple()) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #verify - we didn't crash gridwin.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 7) #reopen and try again gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) gridwin.executeAction("ACTIVATE", tuple()) xChartMainTop = self.xUITest.getTopFocusWindow() xChartMain = xChartMainTop.getChild("chart_window") #Right-click on the chart; from the pop-up menu select "Format Y bars # The program presents dialog "Format Y bars", tab "Line". xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0") self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatYErrorBars"})) xDialog = self.xUITest.getTopFocusWindow() #Click on tab "Line". tabcontrol = xDialog.getChild("tabcontrol") select_pos(tabcontrol, "1") #Type a non-zero integer into the "Transparency:" Edit Field, or use the up arrow to select one xTransparency = xDialog.getChild("MTR_LINE_TRANSPARENT") self.assertEqual(get_state_as_dict(xTransparency)["Text"][0], "5") xTransparency.executeAction("UP", tuple()) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #verify - we didn't crash gridwin.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 7) self.ui_test.close_doc()
def test_tdf77509_consolidate(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf77509.xls")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #1. Open attachment: Consolidate-test.xls #2. Select any empty cell, eg. cell D1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) #3. Tab: Data > Consolidate self.ui_test.execute_modeless_dialog_through_command( ".uno:DataConsolidate") xDialog = self.xUITest.getTopFocusWindow() xfunc = xDialog.getChild("func") xeddataarea = xDialog.getChild("eddataarea") xadd = xDialog.getChild("add") xbyrow = xDialog.getChild("byrow") xbycol = xDialog.getChild("bycol") xeddestarea = xDialog.getChild("eddestarea") props = {"TEXT": "Sum"} actionProps = mkPropertyValues(props) xfunc.executeAction("SELECT", actionProps) #4. Source data ranges: $Sheet1.$A$1:$B$7 #5. Click 'Add' so that ranges appear in "Consolidation ranges" xeddataarea.executeAction( "TYPE", mkPropertyValues({"TEXT": "$Sheet1.$A$1:$B$7"})) xadd.executeAction("CLICK", tuple()) #6. Click 'Options' > check 'Row labels' > click OK xbyrow.executeAction("CLICK", tuple()) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #verify self.assertEqual( get_cell_by_position(document, 0, 3, 0).getString(), "A 1") self.assertEqual( get_cell_by_position(document, 0, 3, 1).getString(), "AB 1") self.assertEqual( get_cell_by_position(document, 0, 3, 2).getString(), "AB 12") self.assertEqual( get_cell_by_position(document, 0, 3, 3).getString(), "AB 123") self.assertEqual( get_cell_by_position(document, 0, 3, 4).getString(), "ABC 1") self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 1) self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 1) self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 1) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf133855(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf133855.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() document = self.ui_test.get_component() results = ['A', 'B', 'C', 'D', 'E', 'F'] # Conditional formatted dropdown list for i in range(len(results)): gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction( "LAUNCH", mkPropertyValues({ "SELECTMENU": "", "COL": "6", "ROW": "5" })) #Select the TreeList UI Object xWin = self.xUITest.getTopFocusWindow() xlist = xWin.getChild("list") xListItem = xlist.getChild(str(i)) xListItem.executeAction("DOUBLECLICK", mkPropertyValues({})) self.assertEqual( get_cell_by_position(document, 0, 6, 5).getString(), results[i]) # normal dropdown list for i in range(len(results)): gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction( "LAUNCH", mkPropertyValues({ "SELECTMENU": "", "COL": "6", "ROW": "6" })) #Select the TreeList UI Object xWin = self.xUITest.getTopFocusWindow() xlist = xWin.getChild("list") xListItem = xlist.getChild(str(i)) xListItem.executeAction("DOUBLECLICK", mkPropertyValues({})) self.assertEqual( get_cell_by_position(document, 0, 6, 6).getString(), results[i]) self.ui_test.close_doc()
def test_tdf120660_undo_recalculate(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf120660.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Make sure that tools-options-LibreOffice Calc-General-Input settings-Show overwrite warning when pasting data is unselected #turn off message: You are pasting data into cells that already contain data self.ui_test.execute_dialog_through_command( ".uno:OptionsTreeDialog") #optionsdialog xDialogOpt = self.xUITest.getTopFocusWindow() xPages = xDialogOpt.getChild("pages") xWriterEntry = xPages.getChild('3') # Calc xWriterEntry.executeAction("EXPAND", tuple()) xWriterGeneralEntry = xWriterEntry.getChild('0') xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb xreplwarncb = xDialogOpt.getChild("replwarncb") if (get_state_as_dict(xreplwarncb)["Selected"]) == "true": xreplwarncb.executeAction("CLICK", tuple()) xOKBtn = xDialogOpt.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:E8"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:E4"})) self.xUITest.executeCommand(".uno:Paste") self.assertEqual( get_cell_by_position(document, 0, 4, 3).getValue(), 1200) self.xUITest.executeCommand(".uno:Undo") self.assertEqual( get_cell_by_position(document, 0, 4, 3).getValue(), 2200) gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:D8"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:D4"})) self.xUITest.executeCommand(".uno:Paste") self.assertEqual( get_cell_by_position(document, 0, 4, 3).getValue(), 1200) self.xUITest.executeCommand(".uno:Undo") self.assertEqual( get_cell_by_position(document, 0, 4, 3).getValue(), 2200) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_autosum_test3(self): #Subtotals on Autosum calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C49"})) self.xUITest.executeCommand(".uno:AutoSum") self.assertEqual(get_cell_by_position(document, 0, 2, 48).getValue(), 20) self.assertEqual(get_cell_by_position(document, 0, 2, 48).getFormula(), "=SUBTOTAL(9;C38:C48)") self.ui_test.close_doc()
def test_autosum_test1(self): #Sum on range and Sum on Sum's calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Place the cell cursor on the gray cells located under Point 1. #(Multiselection is not possible at this place) and press the Sum Icon in the formula bar. #Now hit the enter key and the result should be shown. Do so for each gray cell in this part of the document. gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B10"})) self.xUITest.executeCommand(".uno:AutoSum") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B13"})) self.xUITest.executeCommand(".uno:AutoSum") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B14"})) self.xUITest.executeCommand(".uno:AutoSum") self.assertEqual(get_cell_by_position(document, 0, 1, 9).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 1, 9).getFormula(), "=SUM(B8:B9)") self.assertEqual(get_cell_by_position(document, 0, 1, 12).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 1, 12).getFormula(), "=SUM(B11:B12)") self.assertEqual(get_cell_by_position(document, 0, 1, 13).getValue(), 4) self.assertEqual(get_cell_by_position(document, 0, 1, 13).getFormula(), "=SUM(B13:B13;B10:B10)") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "F8:F14"})) self.xUITest.executeCommand(".uno:AutoSum") self.assertEqual(get_cell_by_position(document, 0, 5, 13).getValue(), 4) self.assertEqual(get_cell_by_position(document, 0, 5, 13).getFormula(), "=SUM(F13:F13;F10:F10)") self.ui_test.close_doc()
def test_autosum_test9(self): #9.Subtotal on column without selected empty cell for result calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C142:C149"})) self.xUITest.executeCommand(".uno:AutoSum") self.assertEqual(get_cell_by_position(document, 0, 2, 150).getValue(), 19) self.assertEqual(get_cell_by_position(document, 0, 2, 150).getFormula(), "=SUBTOTAL(9;C142:C149)") self.ui_test.close_doc()
def test_autosum_test4(self): #Autosum on column with selected empty cell for result calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B59:B64"})) self.xUITest.executeCommand(".uno:AutoSum") self.assertEqual(get_cell_by_position(document, 0, 1, 63).getValue(), 150) self.assertEqual(get_cell_by_position(document, 0, 1, 63).getFormula(), "=SUM(B59:B63)") self.ui_test.close_doc()
def test_multiple_operations_one_variable(self): self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #enter data enter_text_to_cell(xGridWindow, "B1", "10") enter_text_to_cell(xGridWindow, "B2", "2") enter_text_to_cell(xGridWindow, "B3", "10000") enter_text_to_cell(xGridWindow, "B4", "2000") enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") enter_text_to_cell(xGridWindow, "D2", "500") enter_text_to_cell(xGridWindow, "D3", "1000") enter_text_to_cell(xGridWindow, "D4", "1500") enter_text_to_cell(xGridWindow, "D5", "2000") enter_text_to_cell(xGridWindow, "D6", "2500") enter_text_to_cell(xGridWindow, "D7", "3000") enter_text_to_cell(xGridWindow, "D8", "3500") enter_text_to_cell(xGridWindow, "D9", "4000") enter_text_to_cell(xGridWindow, "D10", "4500") enter_text_to_cell(xGridWindow, "D11", "5000") #Select the range D2:E11 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"})) #Choose Data > Multiple Operations. self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") xDialog = self.xUITest.getTopFocusWindow() #Formulas = B5 ; Column input cell = B4 formulas = xDialog.getChild("formulas") col = xDialog.getChild("col") formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5"})) col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #verify self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) self.ui_test.close_doc()
def test_tdf125051_crash_spelling_dialog(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A1", "text") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.ui_test.execute_dialog_through_command(".uno:SpellDialog") xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog xDialog2 = self.xUITest.getTopFocusWindow() # info dialog "The spellcheck of this sheet has been completed.-> OK" okBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(okBtn) xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog #open options optionsBtn = xDialog.getChild("options") def handle_options_dlg(dialog): #print(dialog.getChildren()) xCancelBtn = dialog.getChild("cancel") self.ui_test.close_dialog_through_button(xCancelBtn) self.ui_test.execute_blocking_action(optionsBtn.executeAction, args=('CLICK', ()), dialog_handler=handle_options_dlg) closeBtn = xDialog.getChild("close") #close Spelling dialog self.ui_test.close_dialog_through_button(closeBtn) #verify, we didn't crash self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "text") self.ui_test.close_doc()
def test_tdf123479_Crash_ScFormulaResult_GetMatrixFormulaCellToken(self): #numberingformatpage.ui calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf123479.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #Select D14:D16 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D14:D16"})) #Open Formula Wizard (Ctrl+F2) self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") xDialog = self.xUITest.getTopFocusWindow() edArg1 = xDialog.getChild("ED_ARG1") edArg2 = xDialog.getChild("ED_ARG2") formulaRes = xDialog.getChild("formula_result") #check formula wizard data self.assertEqual(get_state_as_dict(edArg1)["Text"], "CHAR(10)") self.assertEqual(get_state_as_dict(edArg2)["Text"], "OFFSET($Data.$A$2:$Data.$A$4,0,COLUMN()-3)") self.assertEqual(get_state_as_dict(formulaRes)["Text"], "{4;4;4}") xOk = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOk) #verify; no crashes self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Pass/Fail") self.ui_test.close_doc()
def test_tdf120174(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A1", "121") enter_text_to_cell(gridwin, "B1", "=A1") self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) # Delete contents of A1 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) # Before the fix the result would be still 121. self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) # B1 self.xUITest.executeCommand(".uno:Undo") self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 self.ui_test.close_doc()
def test_tdf118189(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf118189.xlsx")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #1. Open attached document #2. Copy Column A gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") self.xUITest.executeCommand(".uno:Copy") #3. New Spreadsheet calc_doc2 = self.ui_test.load_file(get_url_for_data_file("emptyFile.ods")) gridwin2 = xCalcDoc.getChild("grid_window") document2 = self.ui_test.get_component() frames = self.ui_test.get_frames() frames[1].activate() #4. Paste it gridwin2.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:Paste") #5. Cut it self.xUITest.executeCommand(".uno:Cut") #6. Undo self.xUITest.executeCommand(".uno:Undo") #-> CRASH self.assertEqual(get_cell_by_position(document2, 0, 0, 0).getString(), "") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf37341_goalSeek(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf37341.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F111"})) self.ui_test.execute_modeless_dialog_through_command(".uno:GoalSeekDialog") xDialog = self.xUITest.getTopFocusWindow() xformulaedit = xDialog.getChild("formulaedit") xtarget = xDialog.getChild("target") xvaredit = xDialog.getChild("varedit") xtarget.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) xvaredit.executeAction("TYPE", mkPropertyValues({"TEXT":"E7"})) xOKBtn = xDialog.getChild("ok") def handle_OK_dlg(dialog): xYesButn = dialog.getChild("yes") self.ui_test.close_dialog_through_button(xYesButn) self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), dialog_handler=handle_OK_dlg) #verify self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue() > 0, True) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_tdf44398_find_replace_regexp(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() # 1. A1 => 123456 enter_text_to_cell(gridwin, "A1", "123456") # 2. ctrl-h, in dialog # Search: ([0-9]) # Replace: $1 # check regular expression # hit replace all self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") xDialog = self.xUITest.getTopFocusWindow() searchterm = xDialog.getChild("searchterm") searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([0-9])"})) replaceterm = xDialog.getChild("replaceterm") replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) #replace textbox regexp = xDialog.getChild("regexp") regexp.executeAction("CLICK", tuple()) #regular expressions replaceall = xDialog.getChild("replaceall") replaceall.executeAction("CLICK", tuple()) xcloseBtn = xDialog.getChild("close") self.ui_test.close_dialog_through_button(xcloseBtn) #verify 3. A1 => 123456 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "123456") self.ui_test.close_doc()
def test_tdf88792(self): calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88792.ods")) XcalcDoc = self.xUITest.getTopFocusWindow() document = self.ui_test.get_component() gridwin = XcalcDoc.getChild("grid_window") # go to cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) # Select from the menu bar Data # Select option subtotal # Subtotal dialog displays self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") xDialog = self.xUITest.getTopFocusWindow() # Select group by: Category xGroupBy = xDialog.getChild("group_by") props = {"TEXT": "Category"} actionProps = mkPropertyValues(props) xGroupBy.executeAction("SELECT", actionProps) # Select calculate subtotals for the months - selected by default # Select tab options xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "3") # select option include formats xformats = xDialog.getChild("formats") xformats.executeAction("CLICK", tuple()) # apply with OK xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) self.assertEqual(get_cell_by_position(document, 0, 3, 5).getValue(), 28000) self.ui_test.close_doc()
def test_tdf71339_autosum_on_selected_range(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A2", "1") enter_text_to_cell(gridwin, "A3", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) self.xUITest.executeCommand(".uno:AutoSum") self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 0, 3).getFormula(), "=SUM(A1:A3)") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab:
def test_protect_sheet(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #enter password - lock self.ui_test.execute_dialog_through_command(".uno:Protect") xDialog = self.xUITest.getTopFocusWindow() xprotect = xDialog.getChild("protect") xpassword1 = xDialog.getChild("password1") xpassword2 = xDialog.getChild("password2") if (get_state_as_dict(xprotect)["Selected"]) == "false": xprotect.executeAction("CLICK", tuple()) xpassword1.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) xpassword2.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) xOKBtn = xDialog.getChild("ok") # self.ui_test.close_dialog_through_button(xOKBtn) xOKBtn.executeAction("CLICK", tuple()) #Unlock self.ui_test.execute_dialog_through_command(".uno:Protect") xDialog = self.xUITest.getTopFocusWindow() xpass1ed = xDialog.getChild("pass1ed") xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) #Verify - the sheet is unlocked enter_text_to_cell(gridwin, "B2", "A") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "A") self.ui_test.close_doc()
def test_paste_special(self): # EN-8:Paste special with options # This test is to check that paste special combined with some options and link is ok. # Refers to tdf#84810 self.ui_test.create_doc_in_start_center("calc") # Write text to cell A1 xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") enter_text_to_cell(xGridWin, "A1", "abcd") # Copy cell A1 to clipboard xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:Copy") # Set cursor to cell A3 xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) # Choose Paste Special Options and paste data self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") xPasteSpecialDlg = self.xUITest.getTopFocusWindow() xAllChkBox = xPasteSpecialDlg.getChild("paste_all") xAllChkBox.executeAction("CLICK", tuple()) xLinkChkBox = xPasteSpecialDlg.getChild("link") xLinkChkBox.executeAction("CLICK", tuple()) xOkBtn = xPasteSpecialDlg.getChild("ok") self.ui_test.close_dialog_through_button(xOkBtn) # Assert successful paste document = self.ui_test.get_component() self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "abcd") self.ui_test.close_doc()