| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- /**
- * diag-page-state.js — 诊断:为什么 pageState() 判不出当前页面
- *
- * 用 `node tools/run.js --eval tools/diag-page-state.js` 跑。
- * 它只读不写,不会改变设备状态。
- */
- var l = TikTokAuto.layout;
- var t = TikTokAuto.tiktok;
- console.log('rootIsNull=' + (l.root() === null));
- console.log('fg=' + l.foregroundPackage());
- console.log('screen=' + JSON.stringify(l.screen()));
- console.log('state=' + t.pageState());
- console.log('onPlayerPage=' + t.onPlayerPage());
- console.log('tabStrip=' + t.resultTabStripPresent());
- console.log('bottomNav=' + t.bottomNavPresent());
- console.log('homeNode=' + (l.findOnce(desc('Home')) !== null));
- console.log('profileNode=' + (l.findOnce(desc('Profile')) !== null));
- console.log('searchEntryNull=' + (t.searchEntry() === null));
- var imgs = className('android.widget.ImageView').find();
- console.log('imageViewCount=' + imgs.size());
- for (var i = 0; i < imgs.size(); i += 1) {
- var node = imgs.get(i);
- if (l.desc(node) === 'Search') {
- console.log(' SearchImage visible=' + l.isVisible(node) +
- ' center=' + JSON.stringify(l.center(node)) +
- ' bounds=' + JSON.stringify(node.bounds()));
- }
- }
- var texts = className('android.widget.TextView').find();
- var bottomNavCandidates = [];
- for (var j = 0; j < texts.size(); j += 1) {
- var label = l.text(texts.get(j));
- if (label === 'Home' || label === 'Profile' || label === 'Inbox' || label === 'Friends') {
- bottomNavCandidates.push(label + '@' + JSON.stringify(texts.get(j).bounds()));
- }
- }
- console.log('bottomNavTextNodes=' + JSON.stringify(bottomNavCandidates));
|