def testParentWhenRemovingFilterFromContainer(self): container = HierarchicalContainer() self.initializeHierarchicalContainer(container) container.setIncludeParentsWhenFiltering(True) container.addContainerFilter(self.FULLY_QUALIFIED_NAME, 'ab', False, False) p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertEquals('com.vaadin.ui', p1) p1 = container.getParent( 'com.vaadin.terminal.gwt.client.ui.VPopupCalendar') self.assertIsNone(p1) container.removeAllContainerFilters() p1 = container.getParent( 'com.vaadin.terminal.gwt.client.ui.VPopupCalendar') self.assertEquals('com.vaadin.terminal.gwt.client.ui', p1)
def testRemovingItemsFromFilteredContainer(self): container = HierarchicalContainer() self.initializeHierarchicalContainer(container) container.setIncludeParentsWhenFiltering(True) container.addContainerFilter(self.FULLY_QUALIFIED_NAME, 'ab', False, False) p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertEquals('com.vaadin.ui', p1) container.removeItem('com.vaadin.ui.TabSheet') # Parent for the removed item must be null because the item is no # longer in the container p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertIsNone(p1, 'Parent should be null, is ' + str(p1)) container.removeAllItems() p1 = container.getParent('com.vaadin.terminal.gwt.client.Focusable') self.assertIsNone(p1, 'Parent should be null, is ' + str(p1))
def testChangeParentInFilteredContainer(self): container = HierarchicalContainer() self.initializeHierarchicalContainer(container) container.setIncludeParentsWhenFiltering(True) container.addContainerFilter(self.FULLY_QUALIFIED_NAME, 'Tab', False, False) # Change parent of filtered item p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertEquals('com.vaadin.ui', p1) container.setParent('com.vaadin.ui.TabSheet', 'com.vaadin') p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertEquals('com.vaadin', p1) container.setParent('com.vaadin.ui.TabSheet', 'com') p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertEquals('com', p1) container.setParent('com.vaadin.ui.TabSheet', None) p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertIsNone(p1) # root -> non-root container.setParent('com.vaadin.ui.TabSheet', 'com') p1 = container.getParent('com.vaadin.ui.TabSheet') self.assertEquals('com', p1)