public void testAutoFilter(){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sh = wb.createSheet();
InternalWorkbook iwb = wb.getWorkbook();
InternalSheet ish = sh.getSheet();
assertNull( iwb.getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1) );
assertNull( ish.findFirstRecordBySid(AutoFilterInfoRecord.sid) );
CellRangeAddress range = CellRangeAddress.valueOf("A1:B10");
sh.setAutoFilter(range);
NameRecord name = iwb.getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1);
assertNotNull( name );
// The built-in name for auto-filter must consist of a single Area3d Ptg.
Ptg[] ptg = name.getNameDefinition();
assertEquals("The built-in name for auto-filter must consist of a single Area3d Ptg", 1, ptg.length);
assertTrue("The built-in name for auto-filter must consist of a single Area3d Ptg", ptg[0] instanceof Area3DPtg);
Area3DPtg aref = (Area3DPtg)ptg[0];
assertEquals(range.getFirstColumn(), aref.getFirstColumn());
assertEquals(range.getFirstRow(), aref.getFirstRow());
assertEquals(range.getLastColumn(), aref.getLastColumn());
assertEquals(range.getLastRow(), aref.getLastRow());
// verify AutoFilterInfoRecord
AutoFilterInfoRecord afilter = (AutoFilterInfoRecord)ish.findFirstRecordBySid(AutoFilterInfoRecord.sid);
assertNotNull(afilter );
assertEquals(2, afilter.getNumEntries()); //filter covers two columns
HSSFPatriarch dr = sh.getDrawingPatriarch();
assertNotNull(dr);
HSSFSimpleShape comboBoxShape = (HSSFSimpleShape)dr.getChildren().get(0);
assertEquals(comboBoxShape.getShapeType(), HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX);
assertNull( ish.findFirstRecordBySid(ObjRecord.sid) ); // ObjRecord will appear after serializetion
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
sh = wb.getSheetAt(0);
ish = sh.getSheet();
ObjRecord objRecord = (ObjRecord)ish.findFirstRecordBySid(ObjRecord.sid);
List<SubRecord> subRecords = objRecord.getSubRecords();
assertEquals(3, subRecords.size());
assertTrue(subRecords.get(0) instanceof CommonObjectDataSubRecord );
assertTrue(subRecords.get(1) instanceof FtCblsSubRecord ); // must be present, see Bug 51481
assertTrue(subRecords.get(2) instanceof LbsDataSubRecord );