当前位置: 首页>>代码示例>>Java>>正文


Java TreeIterables.breadthFirstViewTraversal方法代码示例

本文整理汇总了Java中android.support.test.espresso.util.TreeIterables.breadthFirstViewTraversal方法的典型用法代码示例。如果您正苦于以下问题:Java TreeIterables.breadthFirstViewTraversal方法的具体用法?Java TreeIterables.breadthFirstViewTraversal怎么用?Java TreeIterables.breadthFirstViewTraversal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.test.espresso.util.TreeIterables的用法示例。


在下文中一共展示了TreeIterables.breadthFirstViewTraversal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResume

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
@Override
protected void onResume(){
    super.onResume();
    View root = this.getWindow().getDecorView();

    for(View v : TreeIterables.breadthFirstViewTraversal(root)){
        if(v.getId() != -1) {
            System.out.println("View: " + v.getResources().getResourceEntryName(v.getId()) + " " + v.isClickable());
        } else if(v.getContentDescription() != null){
            System.out.println("View: " + v.getContentDescription().toString() + " " + v.isClickable());
        } else{
            System.out.println("View: " + v.toString() + " No Des, No Id " + v.isClickable());
        }

    }
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:17,代码来源:SwipeActivity.java

示例2: getAllViews

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
protected ArrayList<View> getAllViews() {
    View root = getDecorView();
    ArrayList<View> views = new ArrayList<>();
    for (View v : TreeIterables.breadthFirstViewTraversal(root)) {
        // Log.i("Chimp-needs-to-know","Active View: " + v.toString());
        views.add(v);
    }

    /*
    View focus = getActivityInstance().getCurrentFocus();
    if (focus != null) {
        for (View v : TreeIterables.breadthFirstViewTraversal(focus)) {
            Log.i("Chimp-needs-to-know", "In focus View: " + v.toString());
        }
    } */

    return views;
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:19,代码来源:ActivityManager.java

示例3: matchView

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
private View matchView(View view, Matcher<View> matcher) {

        if (view == null) {
            return null;
        }

        if (matcher.matches(view)) {
            return view;
        }

        for (View child : TreeIterables.breadthFirstViewTraversal(view)) {

            if (matcher.matches(child)) {
                return child;
            }
        }
        return null;
    }
 
开发者ID:PGSSoft,项目名称:espresso-doppio,代码行数:19,代码来源:ComponentFinder.java

示例4: waitForMatch

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
public static ViewAction waitForMatch(final Matcher<View> aViewMatcher, final long timeout) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "Waiting for view matching " + aViewMatcher;
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();

            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + timeout;

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    if (aViewMatcher.matches(child)) {
                        // found
                        return;
                    }
                }


                uiController.loopMainThreadForAtLeast(50);
            } while (System.currentTimeMillis() < endTime);

            //The action has timed out.
            throw new PerformException.Builder()
                    .withActionDescription(getDescription())
                    .withViewDescription("")
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:41,代码来源:EspressoTest.java

示例5: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:andrey7mel,项目名称:android-step-by-step,代码行数:41,代码来源:EspressoTools.java

示例6: isConditionMet

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
@Override
protected boolean isConditionMet(View view) {
    for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
        if (matcher.matches(child)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:yandex-money,项目名称:yandex-money-sdk-android,代码行数:10,代码来源:MoreViewActions.java

示例7: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/**
 * Perform action of waiting for a specific view id.
 */
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:Utils.java

示例8: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/** Perform action of waiting for a specific view id. */
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:42,代码来源:ViewActions.java

示例9: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/**
 * Looks for a view with the given ID for a given millis
 * @param viewId ID of the view you are looking for
 * @param millis Millis trying to find it
 * @return ViewAction so you can use like any other EspressoAction
 */
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:47,代码来源:MalariaEspressoActions.java

示例10: waitInvisibleGoneId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
public static ViewAction waitInvisibleGoneId(final int viewId, final long millis) {
        return new ViewAction() {
            @Override
            public Matcher<View> getConstraints() {
                return isRoot();
            }

            @Override
            public String getDescription() {
                return "wait view id <" + viewId + "> during " + millis + " millis.";
            }

            @Override
            public void perform(final UiController uiController, final View view) {
                uiController.loopMainThreadUntilIdle();
                final long startTime = System.currentTimeMillis();
                final long endTime = startTime + millis;
                final Matcher<View> viewMatcher = withId(viewId);
//                Log.e("test", "waitInvisibleGoneId view id:" + viewId);
                uiController.loopMainThreadForAtLeast(200);
                do {
                    View find = null;
                    for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
//                        if (viewMatcher.matches(child) && child.getVisibility() == View.VISIBLE) {
//                          Log.e("test","original view id:"+viewId+" child view id:"+child.getId());
                        if (viewMatcher.matches(child)) {
                            find = child;
                            Log.e("test", "macthch  visible: " + child.getVisibility());
                        }

                    }
                    if (find != null && find.getVisibility() == View.VISIBLE) {
//                            Log.e("test", "find startTime:" + startTime);
//                            Log.e("test","find endTime:"+endTime);
//                            Log.e("test","find System.currentTimeMillis():"+System.currentTimeMillis());
                    } else {
                        Log.e("test", "waitInvisibleGoneId wait time :" + (System.currentTimeMillis() - startTime) / 1000 + " id:" + viewId);
                        return;
                    }
//                    Log.e("test","startTime:"+startTime);
//                    Log.e("test","endTime:"+endTime);
                    uiController.loopMainThreadForAtLeast(50);
                }
                while (System.currentTimeMillis() < endTime);

                Log.e("test", "waitInvisibleGoneId time out :" + (System.currentTimeMillis() - startTime) / 1000 + " id:" + viewId);
                throw new PerformException.Builder()
                        .withActionDescription(this.getDescription())
                        .withViewDescription(HumanReadables.describe(view))
                        .withCause(new TimeoutException())
                        .build();
            }
        };
    }
 
开发者ID:BioStar2,项目名称:BioStar2Android,代码行数:55,代码来源:ExtTest.java

示例11: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
public static ViewAction waitId(final int viewId, final long millis) {
        return new ViewAction() {
            @Override
            public Matcher<View> getConstraints() {
                return isRoot();
            }

            @Override
            public String getDescription() {
                return "wait view id <" + viewId + "> during " + millis + " millis.";
            }

            @Override
            public void perform(final UiController uiController, final View view) {
                uiController.loopMainThreadUntilIdle();
                final long startTime = System.currentTimeMillis();
                final long endTime = startTime + millis;
                final Matcher<View> viewMatcher = withId(viewId);
                Log.e("test", "waitId original view id:" + viewId);
                do {
                    for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
//                        if (viewMatcher.matches(child) && child.getVisibility() == View.VISIBLE) {
                        //  Log.e("test","original view id:"+viewId+" child view id:"+child.getId());
                        if (viewMatcher.matches(child) && child.getVisibility() == View.VISIBLE) {
//                            Log.e("test", "find startTime:" + startTime);
//                            Log.e("test","find endTime:"+endTime);
//                            Log.e("test","find System.currentTimeMillis():"+System.currentTimeMillis());
                            Log.e("test", "waitId wait time :" + (System.currentTimeMillis() - startTime) / 1000 + " id:" + viewId);
                            return;
                        }
                    }
//                    Log.e("test","startTime:"+startTime);
//                    Log.e("test","endTime:"+endTime);
                    uiController.loopMainThreadForAtLeast(50);
                }
                while (System.currentTimeMillis() < endTime);

                Log.e("test", "waitId time out :" + (System.currentTimeMillis() - startTime) / 1000 + " id:" + viewId);
                throw new PerformException.Builder()
                        .withActionDescription(this.getDescription())
                        .withViewDescription(HumanReadables.describe(view))
                        .withCause(new TimeoutException())
                        .build();
            }
        };
    }
 
开发者ID:BioStar2,项目名称:BioStar2Android,代码行数:47,代码来源:ExtTest.java

示例12: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/**
 * Perform action of waiting for a specific view id.
 * <p/>
 * E.g.:
 * onView(isRoot()).perform(waitId(R.id.dialogEditor, Sampling.SECONDS_15));
 *
 * @param viewId
 * @param millis
 * @return
 */
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:talenguyen,项目名称:PrettyBundle,代码行数:51,代码来源:ExtViewActions.java

示例13: screenshot

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/**
 * Performs screenshot of activity with specified view
 * use like onView(isRoot()).perform(screenshot(R.id.MainActivity));
 * @param viewId view to look at
 * @param testTag description of screenshoshot
 * @return
 */
public static ViewAction screenshot(final int viewId, final String testTag) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "screenshoting current activity with root id  <" + viewId + "> .";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final Matcher<View> viewMatcher = withId(viewId);


            for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                // found view with required ID
                if (viewMatcher.matches(child)) {
                    Activity host=(Activity) child.getContext();
                    try {
                        Screenshot.capture(testTag+"_"+host.getLocalClassName().toString(),host);
                    } catch (IOException e) {
                        //something bad happened.no screenshot.
                        Log.d(TAG,e.toString());
                        e.printStackTrace();
                        throw new RuntimeException(e);
                    }
                    return;
                }
            }

            // nothing found
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new NoRootViewFoundWithIdException())
                    .build();
        }
    };
}
 
开发者ID:intari,项目名称:readingtracker,代码行数:51,代码来源:TestHelpers.java

示例14: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/**
 * Perform action of waiting for a specific view id
 * based off https://stackoverflow.com/questions/21417954/espresso-thread-sleep
 * @param viewId - view to look for
 * @param millis - how long to wait for in milliseconds
 */
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                    .withActionDescription(this.getDescription())
                    .withViewDescription(HumanReadables.describe(view))
                    .withCause(new TimeoutException())
                    .build();
        }
    };
}
 
开发者ID:intari,项目名称:readingtracker,代码行数:47,代码来源:TestHelpers.java

示例15: waitId

import android.support.test.espresso.util.TreeIterables; //导入方法依赖的package包/类
/**
 * Perform action of waiting for a specific view id.
 * <p/>
 * E.g.:
 * onView(isRoot()).perform(waitId(R.id.dialogEditor, Sampling.SECONDS_15));
 *
 * @param viewId
 * @param millis
 * @return
 */
public static ViewAction waitId(final int viewId, final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            uiController.loopMainThreadUntilIdle();
            final long startTime = System.currentTimeMillis();
            final long endTime = startTime + millis;
            final Matcher<View> viewMatcher = withId(viewId);

            do {
                for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
                    // found view with required ID
                    if (viewMatcher.matches(child)) {
                        return;
                    }
                }

                uiController.loopMainThreadForAtLeast(50);
            }
            while (System.currentTimeMillis() < endTime);

            // timeout happens
            throw new PerformException.Builder()
                .withActionDescription(this.getDescription())
                .withViewDescription(HumanReadables.describe(view))
                .withCause(new TimeoutException())
                .build();
        }
    };
}
 
开发者ID:LiveTyping,项目名称:u2020-mvp,代码行数:51,代码来源:ViewActions.java


注:本文中的android.support.test.espresso.util.TreeIterables.breadthFirstViewTraversal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。