如何从Robotium检查我的PNG在屏幕上present? [英] How to check from Robotium that my png is present on the screen?

查看:130
本文介绍了如何从Robotium检查我的PNG在屏幕上present?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个额外的方法:

I create an additional method:

public boolean exampleEdTxt1(){
 try{
  solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw);
  return true;
 }
 catch(AssertionError e){
  return false;
 }
}

但是,当测试乳宁,code

But, when test is runing, code

assertTrue(exampleEdTxt1());

总是返回成功,code

always returns success and code

assertFalse(exampleEdTxt1());

总是返回失败。

如何从Robotium检查我的PNG是present在屏幕上?

How to check from Robotium that my png is present on the screen?

推荐答案

尝试使用.isShown()

try using .isShown()

solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw).isShown();

此断言是否显示我的形象,我用来检查:

this assert i used to check if my image is displayed:

assertEquals(true, solo.getCurrentActivity().findViewById(R.id.getting_started_image_1).isShown());

希望它能帮助

在这里,我检查的ImageView

Here i check for imageView

Boolean isVisible = (Boolean) solo.getCurrentActivity().findViewById(R.id.imageView1).isShown();
        assertTrue(isVisible);

下面是检查绘制(图)

Boolean isVisible2 = (Boolean) solo.getCurrentActivity().getResources().getDrawable(R.drawable.image).isVisible();
        assertTrue(isVisible2);

这是我使用的XML ImageView的:

imageView from the xml i used:

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="186dp"
    android:layout_height="90dp"
    android:src="@drawable/image" />

这篇关于如何从Robotium检查我的PNG在屏幕上present?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆