@LargeTest public void testObjectContract() throws Exception { final long startTimeMillis = SystemClock.uptimeMillis(); try { // find a view and make sure it is not focused AccessibilityNodeInfo button = mUiTestAutomationBridge.findAccessibilityNodeInfoByViewIdInActiveWindow(R.id.button5); assertNotNull(button); AccessibilityNodeInfo parent = button.getParent(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { AccessibilityNodeInfo child = parent.getChild(i); assertNotNull(child); if (child.equals(button)) { assertEquals( "Equal objects must have same hasCode.", button.hashCode(), child.hashCode()); return; } } fail("Parent's children do not have the info whose parent is the parent."); } finally { if (DEBUG) { final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis; Log.i(LOG_TAG, "testObjectContract: " + elapsedTimeMillis + "ms"); } } }
public void recycle(AccessibilityNodeInfo info) { if (info.getChildCount() == 0) { log("child widget----------------------------" + info.getClassName(), 1); log("Text:" + info.getText(), 1); log("hash:=" + info.hashCode(), 1); } else { for (int i = 0; i < info.getChildCount(); i++) { if (info.getChild(i) != null) { recycle(info.getChild(i)); } } } }
public int findIDTextView(AccessibilityNodeInfo info) { if (info.getChildCount() == 0) { if (info != null && info.getClassName().equals("android.widget.EditText")) { if (info.getText().toString().trim().equals("正在激活")) { state = STATE_BEGIN; } if (info.getText().toString().trim().equals("-")) { mTeamViewData.mIdTextHash = info.hashCode(); return info.hashCode(); } } } else { for (int i = 0; i < info.getChildCount(); i++) { if (info.getChild(i) != null) { int hash = findIDTextView(info.getChild(i)); if (hash != 0) { return hash; } } } } return 0; }
public boolean ReadyID(AccessibilityNodeInfo info) { if (info.getChildCount() == 0) { if (info != null && info.getClassName().equals("android.widget.EditText")) { if (info.hashCode() == mTeamViewData.mIdTextHash) { if (!info.getText().toString().trim().equals("-")) { mTeamViewData.mIdText = info.getText().toString().replace(" ", "").trim(); return true; } } } } else { for (int i = 0; i < info.getChildCount(); i++) { if (info.getChild(i) != null) { if (ReadyID(info.getChild(i))) { return true; } } } } return false; }