Created
February 17, 2020 13:26
-
-
Save fourlastor/d7477a755a22e4c56f380c49d15b6380 to your computer and use it in GitHub Desktop.
Espresso hierarchy dump analyzer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<div> | |
<textarea id="hierarchy-text" cols="30" rows="10"> | |
+>DecorView{id=-1, visibility=VISIBLE, width=320, height=470, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=WM.LayoutParams{(0,0)(fillxfill) sim=#3 ty=1 fl=#81810100 pfl=0x20000 wanim=0x10302f6 needsMenuKey=2 colorMode=0}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} | |
| | |
+->LinearLayout{id=-1, visibility=VISIBLE, width=320, height=470, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@2bb16ebe, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2} | |
| | |
+-->ViewStub{id=16908679, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@7961766e, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0} | |
| | |
+-->FrameLayout{id=-1, visibility=VISIBLE, width=320, height=470, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@501886c4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} | |
| | |
+--->FitWindowsFrameLayout{id=2131296317, res-name=action_bar_root, visibility=VISIBLE, width=320, height=470, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@65d2bee9, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2} | |
| | |
+---->ContentFrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=320, height=470, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@67350115, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} | |
</textarea> | |
<button id="check-hierarchy">Check</button> | |
</div> | |
<div style="position: relative;" id="view-container"> | |
</div> | |
<script> | |
document.querySelector('#check-hierarchy').addEventListener('click', () => { | |
const regex = /\+(-*)>(\w+)\{(.*)\}/ | |
const hierarchy = document.querySelector('#hierarchy-text').value | |
console.log( | |
hierarchy.split("\n") | |
.filter(line => regex.test(line)) | |
.map(line => line.trim()) | |
.map(line => regex.exec(line)) | |
.map(([_, dashes, viewName, attributes]) => ({ | |
depth: dashes.length, viewName, attributes | |
})) | |
.map(view => ({ | |
...view, | |
attributes: view.attributes | |
.split(', ') | |
.map(attributePair => attributePair.split('=')) | |
.reduce((attrs, [name, value]) => ({...attrs, [name]: value}), {}) | |
})) | |
) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment