Ejemplo n.º 1
0
    def test_xml_parse_to_list(self):
        result = parseXML(testData)
        self.assertEqual(result.tag, "hierarchy")
        self.assertEqual(len(result.findall(f".//node")), 34)

        nodeList = parseXmlToList(result)
        self.assertEqual(len(nodeList), 34)
Ejemplo n.º 2
0
 def test_pretty_print_line(self):
     cols = ["resource-id", "text", "class", "bounds"]
     rootNode = parseXML(testData)
     nodeList = [parseXmlToList(rootNode)[0]]
     filtered = filterList(nodeList, cols)
     max_cols = max_col_lengths(filtered)
     expected = "           |    |android.widget.FrameLayout|[0,0][1080,2160]|540.0 1080.0"
     self.assertEqual(pretty_print_line(list(filtered[0].values()), max_cols), expected)
Ejemplo n.º 3
0
 def test_max_col_lengths(self):
     cols = ["resource-id", "text", "class", "bounds"]
     rootNode = parseXML(testData)
     nodeList = parseXmlToList(rootNode)
     filtered = filterList(nodeList, cols)
     max_cols = max_col_lengths(filtered)
     expected = [23, 232, 27, 20, 12]
     self.assertEqual(max_cols, expected)
Ejemplo n.º 4
0
 def test_filter_cols(self):
     cols = ['text', 'resource-id', 'class', 'package', 'content-desc', 'checkable', 'checked', 'clickable', 'enabled', 'focusable', 'focused', 'scrollable', 'long-clickable', 'password', 'selected', 'bounds', 'midOf']
     rootNode = parseXML(testData)
     nodeList = parseXmlToList(rootNode)
     filtered = filterList(nodeList)
     for element in filtered:
         self.assertEqual(len(element), len(cols))
         self.assertTrue("midOf" in element)
         self.assertEqual(list(element.keys()), cols)
Ejemplo n.º 5
0
 def test_filter_cols(self):
     cols = ["resource-id", "text", "class", "bounds"]
     rootNode = parseXML(testData)
     nodeList = parseXmlToList(rootNode)
     filtered = filterList(nodeList, cols)
     for element in filtered:
         self.assertEqual(len(element), 5)
         self.assertTrue("midOf" in element)
         for colName in cols:
             self.assertTrue(colName in element)