久久久久久久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 等到某個視圖出現(xiàn)?)
      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 等到某個視圖出現(xiàn)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

                  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 實現(xiàn)等到某個視圖出現(xiàn)?

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

                  我已閱讀此處的答案,并且評論似乎表明您可以使用 IdlingResource 代替,但我不明白如何.Espresso 似乎沒有任何內(nèi)置方法來處理長操作,但必須編寫自己的等待循環(huán)感覺就像是 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.

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

                  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;
                          }
                      }
                  }
                  

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

                  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.

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

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?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久久久久久二百 | 国产一级视频免费播放 | 色就干| 久久日韩粉嫩一区二区三区 | 欧美日韩久久精品 | 成人激情视频在线观看 | 天堂男人av | 午夜在线免费观看 | 黄色一级大片在线免费看产 | 亚洲精品一区二区在线观看 | 亚洲成人久久久 | 丁香五月网久久综合 | 国产免费高清 | 国产精品久久久久久妇女 | 欧美一区二区三区久久精品 | www.久久久久久久久久久 | 久在线观看| 一区二区免费视频 | 在线观看av免费 | 欧美性生活视频 | 久久国产传媒 | 亚洲一区二区中文字幕 | 日韩一级免费电影 | 拍真实国产伦偷精品 | 超碰av人人 | 亚洲精品欧美 | 日韩伦理电影免费在线观看 | 亚洲va国产日韩欧美精品色婷婷 | 国产精品亚洲一区二区三区在线 | 一级免费毛片 | 人妖av| 国产有码 | 91精品久久久 | 欧美成人手机视频 | av午夜电影 | 久久久网 | 国产精品久久久久久久免费大片 | 国产精品mv在线观看 | va在线| 91豆花视频 |