久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='xptSv'></bdo><ul id='xptSv'></ul>

        <tfoot id='xptSv'></tfoot>
        <i id='xptSv'><tr id='xptSv'><dt id='xptSv'><q id='xptSv'><span id='xptSv'><b id='xptSv'><form id='xptSv'><ins id='xptSv'></ins><ul id='xptSv'></ul><sub id='xptSv'></sub></form><legend id='xptSv'></legend><bdo id='xptSv'><pre id='xptSv'><center id='xptSv'></center></pre></bdo></b><th id='xptSv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xptSv'><tfoot id='xptSv'></tfoot><dl id='xptSv'><fieldset id='xptSv'></fieldset></dl></div>
      1. <small id='xptSv'></small><noframes id='xptSv'>

        <legend id='xptSv'><style id='xptSv'><dir id='xptSv'><q id='xptSv'></q></dir></style></legend>
      2. 是否可以使用 Espresso 的 IdlingResource 等到某個視圖

        Is it possible to use Espresso#39;s IdlingResource to wait until a certain view appears?(是否可以使用 Espresso 的 IdlingResource 等到某個視圖出現?)
      3. <tfoot id='PDlBT'></tfoot>

          <tbody id='PDlBT'></tbody>
        <i id='PDlBT'><tr id='PDlBT'><dt id='PDlBT'><q id='PDlBT'><span id='PDlBT'><b id='PDlBT'><form id='PDlBT'><ins id='PDlBT'></ins><ul id='PDlBT'></ul><sub id='PDlBT'></sub></form><legend id='PDlBT'></legend><bdo id='PDlBT'><pre id='PDlBT'><center id='PDlBT'></center></pre></bdo></b><th id='PDlBT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PDlBT'><tfoot id='PDlBT'></tfoot><dl id='PDlBT'><fieldset id='PDlBT'></fieldset></dl></div>
          <legend id='PDlBT'><style id='PDlBT'><dir id='PDlBT'><q id='PDlBT'></q></dir></style></legend>

            <small id='PDlBT'></small><noframes id='PDlBT'>

                <bdo id='PDlBT'></bdo><ul id='PDlBT'></ul>
                1. 本文介紹了是否可以使用 Espresso 的 IdlingResource 等到某個視圖出現?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在我的測試中,我有一個階段,在按下按鈕后,應用程序會執行大量異步計算并向云服務發出請求,之后它會顯示某個視圖.

                  In my test I have a stage where after pressing a button application does a lot of asynchronous calculations and requests to the cloud service, after which it displays a certain view.

                  是否可以使用 Espresso 的 IdlingResource 實現等到某個視圖出現?

                  Is it possible to use Espresso's IdlingResource implementation to wait until a certain view appears?

                  我已閱讀此處的答案,并且評論似乎表明您可以使用 IdlingResource 代替,但我不明白如何.Espresso 似乎沒有任何內置方法來處理長操作,但必須編寫自己的等待循環感覺就像是 hack.

                  I've read an answers here and comments seems to suggest that you can use IdlingResource instead, but I don't understand how. Espresso does not seem to have any built-in way to handle long operations, but having to write your own waiting loops feels like a hack.

                  有什么方法可以解決這個問題,或者我應該按照鏈接線程中的答案建議做嗎?

                  Any way to solve this or should I just do as the answer in the linked thread suggests?

                  推薦答案

                  您的 IdlingResource 可能如下所示:

                  Your IdlingResource could look like this:

                  import android.support.test.espresso.IdlingResource;
                  import android.support.test.espresso.ViewFinder;
                  import android.support.test.espresso.ViewInteraction;
                  import android.view.View;
                  
                  import org.hamcrest.Matcher;
                  
                  import java.lang.reflect.Field;
                  
                  import static android.support.test.espresso.Espresso.onView;
                  
                  public class ViewShownIdlingResource implements IdlingResource {
                  
                      private static final String TAG = ViewShownIdlingResource.class.getSimpleName();
                  
                      private final Matcher<View> viewMatcher;
                      private ResourceCallback resourceCallback;
                  
                      public ViewShownIdlingResource(final Matcher<View> viewMatcher) {
                          this.viewMatcher = viewMatcher;
                      }
                  
                      @Override
                      public boolean isIdleNow() {
                          View view = getView(viewMatcher);
                          boolean idle = view == null || view.isShown();
                  
                          if (idle && resourceCallback != null) {
                              resourceCallback.onTransitionToIdle();
                          }
                  
                          return idle;
                      }
                  
                      @Override
                      public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
                          this.resourceCallback = resourceCallback;
                      }
                  
                      @Override
                      public String getName() {
                          return this + viewMatcher.toString();
                      }
                  
                      private static View getView(Matcher<View> viewMatcher) {
                          try {
                              ViewInteraction viewInteraction = onView(viewMatcher);
                              Field finderField = viewInteraction.getClass().getDeclaredField("viewFinder");
                              finderField.setAccessible(true);
                              ViewFinder finder = (ViewFinder) finderField.get(viewInteraction);
                              return finder.getView();
                          } catch (Exception e) {
                              return null;
                          }
                      }
                  }
                  

                  然后,您可以創建一個等待您的視圖的輔助方法:

                  Then, you could create a helper method waiting for your view:

                  public void waitViewShown(Matcher<View> matcher) {
                      IdlingResource idlingResource = new ViewShownIdlingResource(matcher);///
                      try {
                          IdlingRegistry.getInstance().register(idlingResource);
                          onView(matcher).check(matches(isDisplayed()));  
                      } finally {
                          IdlingRegistry.getInstance().unregister(idlingResource);
                      }    
                  }
                  

                  最后,在你的測試中:

                  @Test
                  public void someTest() {
                      waitViewShown(withId(R.id.<some>));
                  
                      //do whatever verification needed afterwards    
                  } 
                  

                  您可以通過讓 IdlingResource 等待任何條件來改進此示例,而不僅僅是等待可見性條件.

                  You could improve this example by making IdlingResource wait for any condition, not just for the visibility one.

                  這篇關于是否可以使用 Espresso 的 IdlingResource 等到某個視圖出現?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                    • <bdo id='xQGgU'></bdo><ul id='xQGgU'></ul>

                      <small id='xQGgU'></small><noframes id='xQGgU'>

                        • <i id='xQGgU'><tr id='xQGgU'><dt id='xQGgU'><q id='xQGgU'><span id='xQGgU'><b id='xQGgU'><form id='xQGgU'><ins id='xQGgU'></ins><ul id='xQGgU'></ul><sub id='xQGgU'></sub></form><legend id='xQGgU'></legend><bdo id='xQGgU'><pre id='xQGgU'><center id='xQGgU'></center></pre></bdo></b><th id='xQGgU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xQGgU'><tfoot id='xQGgU'></tfoot><dl id='xQGgU'><fieldset id='xQGgU'></fieldset></dl></div>
                          <legend id='xQGgU'><style id='xQGgU'><dir id='xQGgU'><q id='xQGgU'></q></dir></style></legend><tfoot id='xQGgU'></tfoot>
                              <tbody id='xQGgU'></tbody>
                          • 主站蜘蛛池模板: 18在线观看免费入口 | 免费黄色片网站 | 欧美精品福利 | 成人国产综合 | 蜜桃精品一区二区 | 亚洲欧美一区二区三区在线 | 91手机在线视频 | 91午夜理伦私人影院 | 黄色成人小视频 | 一本不卡| 成年人免费在线观看 | 日韩精品免费视频 | 欧美日韩精品久久久免费观看 | 久久激情视频 | 国产超碰在线 | 久久久久久久av | 黄色免费大片 | 日本一区二区三区在线视频 | 国产精自产拍久久久久久蜜 | 日韩精品免费观看 | 久草福利视频 | 午夜网 | 日韩精品在线看 | 91精品国产成人www | a毛片视频| 中文字幕一区二区三区乱码 | 久久精品一区二区国产 | 毛片网站在线播放 | 国产青青操 | 国产成人在线观看免费网站 | 欧美黄视频 | 午夜综合网 | 精品一区二区三区在线观看 | 日韩一区精品 | 人人看人人草 | 亚洲免费黄色 | 一区二区三区国产 | 在线a视频| 日本乱轮视频 | 国产福利视频 | 91国内精品|