def test_filter_multiple_rows(self): doc = self.ui_test.load_file(get_url_for_data_file("autofilter.ods")) xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") xGridWin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "2", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") xFirstEntry = xTreeList.getChild("1") xFirstEntry.executeAction("CLICK", tuple()) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(doc, 0)) self.assertFalse(is_row_hidden(doc, 1)) self.assertTrue(is_row_hidden(doc, 2)) self.assertTrue(is_row_hidden(doc, 3)) self.assertFalse(is_row_hidden(doc, 4))
def test_tdf134351(self): doc = self.ui_test.load_file(get_url_for_data_file("autofilter.ods")) xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") xGridWin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_tree_box") self.assertEqual(2, len(xTreeList.getChildren())) self.assertTrue( get_state_as_dict(xTreeList.getChild('0'))['IsSelected']) self.assertTrue( get_state_as_dict(xTreeList.getChild('1'))['IsSelected']) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(doc, 0)) # Without the fix in place, this test would have failed here self.assertFalse(is_row_hidden(doc, 1)) self.assertFalse(is_row_hidden(doc, 2)) self.assertFalse(is_row_hidden(doc, 3)) self.assertFalse(is_row_hidden(doc, 4)) self.ui_test.close_doc()
def test_tdf141547(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf141547.xlsx")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.assertFalse(is_row_hidden(calc_doc, 0)) for i in range(1, 7): self.assertTrue(is_row_hidden(calc_doc, i)) # Without the fix in place, this test would have crashed here self.ui_test.execute_modeless_dialog_through_command( ".uno:DataFilterStandardFilter") xDialog = self.xUITest.getTopFocusWindow() self.assertEqual("0", get_state_as_dict(xDialog.getChild("val1"))['Text']) self.assertEqual( "过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) self.assertEqual("Empty", get_state_as_dict(xDialog.getChild("val2"))['Text']) self.assertEqual( "过帐日期", get_state_as_dict(xDialog.getChild("field2"))["DisplayText"]) xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) self.assertFalse(is_row_hidden(calc_doc, 0)) for i in range(1, 7): self.assertTrue(is_row_hidden(calc_doc, i)) self.ui_test.close_doc()
def test_tdf142350(self): self.ui_test.create_doc_in_start_center("calc") document = self.ui_test.get_component() calcDoc = self.xUITest.getTopFocusWindow() gridwin = calcDoc.getChild("grid_window") document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A1", "A") enter_text_to_cell(gridwin, "A2", "0") enter_text_to_cell(gridwin, "A3", "") enter_text_to_cell(gridwin, "A4", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) self.xUITest.executeCommand(".uno:DataFilterAutoFilter") gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xList = xCheckListMenu.getChild("check_list_box") xEntry = xList.getChild("2") xEntry.executeAction("CLICK", tuple()) xOkButton = xFloatWindow.getChild("ok") xOkButton.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(document, 1)) self.assertTrue(is_row_hidden(document, 2)) self.assertFalse(is_row_hidden(document, 3)) gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xList = xCheckListMenu.getChild("check_list_box") self.assertEqual(3, len(xList.getChildren())) self.assertEqual('true', get_state_as_dict(xList.getChild('0'))['IsChecked']) self.assertEqual('true', get_state_as_dict(xList.getChild('1'))['IsChecked']) self.assertEqual('false', get_state_as_dict(xList.getChild('2'))['IsChecked']) xCloseButton = xFloatWindow.getChild("cancel") xCloseButton.executeAction("CLICK", tuple()) self.ui_test.close_doc()
def test_tdf92767(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf92767.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() for i in range(0, 25): self.assertFalse(is_row_hidden(calc_doc, i)) gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xTreeList = xFloatWindow.getChild("check_tree_box") xFirstEntry = xTreeList.getChild("0") self.assertEqual('2015', get_state_as_dict(xFirstEntry)["Text"]) self.assertEqual('7', get_state_as_dict(xFirstEntry)["Children"]) # Deselect all the options but the last one for i in range(6): xChild = xFirstEntry.getChild(str(i)) xChild.executeAction("CLICK", tuple()) self.assertEqual('false', get_state_as_dict(xChild)['IsChecked']) xLastChild = xFirstEntry.getChild('6') self.assertEqual('true', get_state_as_dict(xLastChild)['IsChecked']) self.assertEqual('July', get_state_as_dict(xLastChild)['Text']) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) for i in range(1, 22): self.assertTrue(is_row_hidden(calc_doc, i)) # Without the fix in place, this test would have failed here self.assertFalse(is_row_hidden(calc_doc, 23)) self.assertFalse(is_row_hidden(calc_doc, 24)) self.assertFalse(is_row_hidden(calc_doc, 25)) self.ui_test.close_doc()
def check_state(self, document, xGridWindow): self.assertFalse(is_row_hidden(document, 0)) # column headers self.assertTrue(is_row_hidden(document, 1)) self.assertTrue(is_row_hidden(document, 2)) self.assertTrue(is_row_hidden(document, 3)) self.assertTrue(is_row_hidden(document, 4)) self.assertFalse(is_row_hidden(document, 5)) self.assertEqual(1, self.get_values_count_in_AutoFilter(xGridWindow, "0")) self.assertEqual(2, self.get_values_count_in_AutoFilter(xGridWindow, "1"))
def test_tdf140968(self): doc = self.ui_test.load_file(get_url_for_data_file("tdf140968.xlsx")) xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") xGridWin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") self.assertEqual(4, len(xTreeList.getChildren())) self.assertEqual("0.000", get_state_as_dict(xTreeList.getChild('0'))['Text']) self.assertEqual("0.046", get_state_as_dict(xTreeList.getChild('1'))['Text']) self.assertEqual("0.365", get_state_as_dict(xTreeList.getChild('2'))['Text']) self.assertEqual("0.516", get_state_as_dict(xTreeList.getChild('3'))['Text']) xFirstEntry = xTreeList.getChild("0") xFirstEntry.executeAction("CLICK", tuple()) xFirstEntry = xTreeList.getChild("1") xFirstEntry.executeAction("CLICK", tuple()) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(doc, 0)) self.assertTrue(is_row_hidden(doc, 1)) self.assertTrue(is_row_hidden(doc, 2)) self.assertTrue(is_row_hidden(doc, 3)) self.assertTrue(is_row_hidden(doc, 4)) self.assertFalse(is_row_hidden(doc, 5)) self.assertFalse(is_row_hidden(doc, 6)) self.ui_test.close_doc()
def test_differentSearches(self): self.ui_test.create_doc_in_start_center("calc") document = self.ui_test.get_component() calcDoc = self.xUITest.getTopFocusWindow() xGridWindow = calcDoc.getChild("grid_window") enter_text_to_cell(xGridWindow, "A1", "X") enter_text_to_cell(xGridWindow, "A2", "11") enter_text_to_cell(xGridWindow, "A3", "22") xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) self.xUITest.executeCommand(".uno:DataFilterAutoFilter") xGridWindow.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xList = xCheckListMenu.getChild("check_list_box") self.assertEqual(2, len(xList.getChildren())) self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) self.assertEqual("22", get_state_as_dict(xList.getChild('1'))['Text']) xSearchEdit = xFloatWindow.getChild("search_edit") xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "11"})) self.assertEqual(1, len(xList.getChildren())) self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(document, 0)) self.assertFalse(is_row_hidden(document, 1)) self.assertTrue(is_row_hidden(document, 2)) xGridWindow.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xList = xCheckListMenu.getChild("check_list_box") self.assertEqual(2, len(xList.getChildren())) self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) self.assertEqual("22", get_state_as_dict(xList.getChild('1'))['Text']) xSearchEdit = xFloatWindow.getChild("search_edit") xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "22"})) self.assertEqual(1, len(xList.getChildren())) self.assertEqual("22", get_state_as_dict(xList.getChild('0'))['Text']) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(document, 0)) self.assertTrue(is_row_hidden(document, 1)) self.assertFalse(is_row_hidden(document, 2)) self.ui_test.close_doc()
def test_tdf130770_autofilter(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf130770.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() # 1. open attached file and check initial state self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertTrue(is_row_hidden(calc_doc, 2)) self.assertFalse(is_row_hidden(calc_doc, 3)) self.assertFalse(is_row_hidden(calc_doc, 4)) # 2. open filter of column A and cancel gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xOkBtn = xFloatWindow.getChild("cancel") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertTrue(is_row_hidden(calc_doc, 2)) self.assertFalse(is_row_hidden(calc_doc, 3)) self.assertFalse(is_row_hidden(calc_doc, 4)) # 3. open filter of column A and just click OK gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertTrue(is_row_hidden(calc_doc, 2)) self.assertFalse(is_row_hidden(calc_doc, 3)) self.assertTrue(is_row_hidden(calc_doc, 4)) # filtered out self.ui_test.close_doc()
def check_row_hidden(self, document, results=[True] * 14): for i, value in enumerate(results, start=1): bVisible = not is_row_hidden(document, i) self.assertEqual(bVisible, value)
def test_tdf117276_autofilter(self): calc_doc = self.ui_test.load_file( get_url_for_data_file("tdf117276.ods")) xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() # 1. open attached file # 2. open filter of column B (Fabrikat) and deselect (Citroen, Fiat, Ford, Opel, Peugeot, Renault, Tesla) gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "1", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") xCitroenEntry = xTreeList.getChild("2") xCitroenEntry.executeAction("CLICK", tuple()) #Citroen xFiatEntry = xTreeList.getChild("3") xFiatEntry.executeAction("CLICK", tuple()) #Fiat xFordEntry = xTreeList.getChild("4") xFordEntry.executeAction("CLICK", tuple()) #Ford xOpelEntry = xTreeList.getChild("6") xOpelEntry.executeAction("CLICK", tuple()) #Opel xPeugeotEntry = xTreeList.getChild("7") xPeugeotEntry.executeAction("CLICK", tuple()) #Peugeot xRenaultEntry = xTreeList.getChild("9") xRenaultEntry.executeAction("CLICK", tuple()) #Renault xTeslaEntry = xTreeList.getChild("10") xTeslaEntry.executeAction("CLICK", tuple()) #Tesla xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertTrue(is_row_hidden(calc_doc, 3)) # 3. open filter of column I (Wert) and deselect 8000 (Values 7000 and 9000 are not shown) gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "8", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") xCitroenEntry = xTreeList.getChild("0") xCitroenEntry.executeAction("CLICK", tuple()) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertTrue(is_row_hidden(calc_doc, 9)) # 4. open filter of column B and select Tesla gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "1", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") xTeslaEntry = xTreeList.getChild("4") xTeslaEntry.executeAction("CLICK", tuple()) #Tesla xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertFalse(is_row_hidden(calc_doc, 21)) # 5. open filter of column I and select 7000 --> 8000 because:new strategy of the filter is implemented #(which strings to show and which to hide, when multiple filters are in used). gridwin.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "8", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") x8000Entry = xTreeList.getChild("1") # check "8000" x8000Entry.executeAction("CLICK", tuple()) xOkBtn = xFloatWindow.getChild("ok") xOkBtn.executeAction("CLICK", tuple()) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertFalse(is_row_hidden(calc_doc, 1)) self.assertFalse(is_row_hidden(calc_doc, 7)) self.ui_test.close_doc()
def test_run(self): self.ui_test.create_doc_in_start_center("calc") document = self.ui_test.get_component() calcDoc = self.xUITest.getTopFocusWindow() xGridWindow = calcDoc.getChild("grid_window") # self.ui_test.execute_dialog_through_command(".uno:Insert") # insert sheet # xDialog = self.xUITest.getTopFocusWindow() # xOKButton = xDialog.getChild("ok") # xOKButton.executeAction("CLICK", tuple()) # 1. prepare document # | A | B | # ----------------------------------------- # 1 | HEADER-A | HEADER-B | # ----------------------------------------- # 2 | Unique a2 | common value for B2:B4 | # 3 | Unique a3 | common value for B2:B4 | # 4 | Unique a4 | common value for B2:B4 | # 5 | Unique a5 | Unique b5 | # 6 | Unique a6 | Unique b6 | # # row-1 enter_text_to_cell(xGridWindow, "A1", "HEADER-A") enter_text_to_cell(xGridWindow, "B1", "HEADER-B") # row-1 enter_text_to_cell(xGridWindow, "A2", "Unique a2") enter_text_to_cell(xGridWindow, "B2", "common value for B2:B4") # row-2 enter_text_to_cell(xGridWindow, "A3", "Unique a3") enter_text_to_cell(xGridWindow, "B3", "common value for B2:B4") # row-3 enter_text_to_cell(xGridWindow, "A4", "Unique a4") enter_text_to_cell(xGridWindow, "B4", "common value for B2:B4") # row-4 enter_text_to_cell(xGridWindow, "A5", "Unique a5") enter_text_to_cell(xGridWindow, "B5", "Unique b5") # row-5 enter_text_to_cell(xGridWindow, "A6", "Unique a6") enter_text_to_cell(xGridWindow, "B6", "Unique b6") xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) # 2. switch on auto-filter self.ui_test.execute_dialog_through_command( ".uno:DataFilterAutoFilter") xDialog = self.xUITest.getTopFocusWindow() xYesBtn = xDialog.getChild("yes") self.ui_test.close_dialog_through_button(xYesBtn) # autofilter still exist self.assertEqual( document.getPropertyValue("UnnamedDatabaseRanges").getByTable( 0).AutoFilter, True) # 3. open filter of column A and deselect first 3 entries (Unique a2, Unique a3, Unique a4) xGridWindow.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "0", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") xEntry1 = xTreeList.getChild("0") xEntry1.executeAction("CLICK", tuple()) # Unique a2 xEntry2 = xTreeList.getChild("1") xEntry2.executeAction("CLICK", tuple()) # Unique a3 xEntry3 = xTreeList.getChild("2") xEntry3.executeAction("CLICK", tuple()) # Unique a4 xOkButton = xFloatWindow.getChild("ok") xOkButton.executeAction("CLICK", tuple()) # check filtering # | A | B | # ----------------------------------------- # 1 | HEADER-A | HEADER-B | # ----------------------------------------- # 5 | Unique a5 | Unique b5 | # 6 | Unique a6 | Unique b6 | self.assertFalse(is_row_hidden(document, 0)) # column headers self.assertTrue(is_row_hidden(document, 1)) self.assertTrue(is_row_hidden(document, 2)) self.assertTrue(is_row_hidden(document, 3)) self.assertFalse(is_row_hidden(document, 4)) self.assertFalse(is_row_hidden(document, 5)) self.assertEqual(5, self.get_values_count_in_AutoFilter(xGridWindow, "0")) self.assertEqual(2, self.get_values_count_in_AutoFilter(xGridWindow, "1")) # 4. open filter of column B and deselect "Unique b5" xGridWindow.executeAction( "LAUNCH", mkPropertyValues({ "AUTOFILTER": "", "COL": "1", "ROW": "0" })) xFloatWindow = self.xUITest.getFloatWindow() xCheckListMenu = xFloatWindow.getChild("check_list_menu") xTreeList = xCheckListMenu.getChild("check_list_box") xEntry = xTreeList.getChild("0") xEntry.executeAction("CLICK", tuple()) # Unique b5 xOkButton = xFloatWindow.getChild("ok") xOkButton.executeAction("CLICK", tuple()) # check filtering # | A | B | # ----------------------------------------- # 1 | HEADER-A | HEADER-B | # ----------------------------------------- # 6 | Unique a6 | Unique b6 | self.check_state(document, xGridWindow) # 4. open filters of column A, B and close it using different buttons self.openAutoFilterAndCloseIt(xGridWindow, "1", "ok") self.check_state(document, xGridWindow) self.openAutoFilterAndCloseIt(xGridWindow, "1", "cancel") self.check_state(document, xGridWindow) self.openAutoFilterAndCloseIt(xGridWindow, "0", "cancel") self.check_state(document, xGridWindow) self.openAutoFilterAndCloseIt(xGridWindow, "0", "ok") self.check_state(document, xGridWindow) # finish self.ui_test.close_doc()