gpt4 book ai didi

Android Toast 堆积测试

转载 作者:行者123 更新时间:2023-11-28 20:31:33 24 4
gpt4 key购买 nike

像许多其他人一样,我一直在努力解决 toast 堆积的问题。

我最终决定跟踪当前显示的 toast 并在另一个 toast 到达时取消它(涉及更多逻辑),但我可以只使用一个 toast 并更改它的消息。我想知道的是......有没有办法测试这种行为?我目前正在使用 Robotium 并尝试了不同的方法,但不幸的是,检查 toasts 的方法(solo.waitForTextsolo.searchForText)对我没有帮助,因为我做不到做一些像

assertTrue(solo.waitForText(text));
//maybe even some sleep here
assertFalse(solo.searchText(text);

有没有人做过这样的事情?有没有办法使用 Robotium 对此进行测试?使用别的东西?

最佳答案

您可以使用机器人条件来等待文本消失。这是我为此使用的方法。

private void waitForTextToDisappear(final String text, int wait) {
Condition textNotFound = new Condition() {

@Override
public boolean isSatisfied() {
return !solo.searchText(text);
}
};
assertTrue("Text gone: " + text, solo.waitForCondition(textNotFound, wait));
}

关于Android Toast 堆积测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21268886/

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