gpt4 book ai didi

android - 进度条和 Espresso

转载 作者:IT老高 更新时间:2023-10-28 23:10:51 25 4
gpt4 key购买 nike

当我在运行一些 espresso 测试时显示的布局中有一个 ProgressBar - 然后我遇到:

Caused by: android.support.test.espresso.AppNotIdleException: Looped for 1670 iterations over 60 SECONDS. The following Idle Conditions failed .

有什么好的方法可以解决这个问题?发现了一些骇人听闻的东西,但正在寻找一种好方法

最佳答案

如果在测试开始时 ProgressBar 不可见,则 Drawable 可以替换为自定义 ViewAction:

// Replace the drawable with a static color
onView(isAssignableFrom(ProgressBar.class)).perform(replaceProgressBarDrawable());

// Click a button (that will make the ProgressBar visible)
onView(withText("Show ProgressBar").perform(click());

自定义ViewAction:

public static ViewAction replaceProgressBarDrawable() {
return actionWithAssertions(new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(ProgressBar.class);
}

@Override
public String getDescription() {
return "replace the ProgressBar drawable";
}

@Override
public void perform(final UiController uiController, final View view) {
// Replace the indeterminate drawable with a static red ColorDrawable
ProgressBar progressBar = (ProgressBar) view;
progressBar.setIndeterminateDrawable(new ColorDrawable(0xffff0000));
uiController.loopMainThreadUntilIdle();
}
});
}

关于android - 进度条和 Espresso ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33289152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com