當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewAction類代碼示例

本文整理匯總了Java中android.support.test.espresso.ViewAction的典型用法代碼示例。如果您正苦於以下問題:Java ViewAction類的具體用法?Java ViewAction怎麽用?Java ViewAction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ViewAction類屬於android.support.test.espresso包,在下文中一共展示了ViewAction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clickNoConstraints

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
static ViewAction clickNoConstraints() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isEnabled(); // No constraints, isEnabled and isClickable are checked
        }

        @Override
        public String getDescription() {
            return "Click a view with no constraints.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            view.performClick();
        }
    };
}
 
開發者ID:dev-labs-bg,項目名稱:fullscreen-video-view,代碼行數:19,代碼來源:CustomChecks.java

示例2: clickChildViewWithId

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
public static ViewAction clickChildViewWithId(final int id) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return null;
        }

        @Override
        public String getDescription() {
            return "Click on a child view with specified id.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            View v = view.findViewById(id);
            v.performClick();
        }
    };
}
 
開發者ID:hernandazevedo,項目名稱:starwarsshop,代碼行數:20,代碼來源:MyViewAction.java

示例3: closeSoftKeyboard

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
public static ViewAction closeSoftKeyboard() {
	return new ViewAction() {
		/**
		 * The real {@link CloseKeyboardAction} instance.
		 */
		private final ViewAction mCloseSoftKeyboard = new CloseKeyboardAction();

		@Override
		public Matcher<View> getConstraints() {
			return mCloseSoftKeyboard.getConstraints();
		}

		@Override
		public String getDescription() {
			return mCloseSoftKeyboard.getDescription();
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			mCloseSoftKeyboard.perform(uiController, view);
			uiController.loopMainThreadForAtLeast(KEYBOARD_DISMISSAL_DELAY_MILLIS);
		}
	};
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:StartupTest.java

示例4: loopMainThreadFor

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
public static ViewAction loopMainThreadFor(final long millis) {
	return new ViewAction() {

		@Override
		public Matcher<View> getConstraints() {
			return isEnabled();
		}

		@Override
		public String getDescription() {
			return "Rturns an action that loops the main thread for at least " + millis +"ms.";
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			uiController.loopMainThreadForAtLeast(millis);
		}
	};
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:StartupTest.java

示例5: fillEntropy

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
private ViewAction fillEntropy() {
	return new ViewAction() {
		@Override
		public Matcher<View> getConstraints() {
			return allOf(isDisplayed(), isAssignableFrom(EntropyView.class));
		}

		@Override
		public String getDescription() {
			return "Dismisses the 'Gathering entropy...' dialog";
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			((EntropyView) view).notifyListeners();
		}
	};
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:PubkeyListActivityTest.java

示例6: clickDescendantViewWithId

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
/**
 * Returns an action that clicks a descendant of the view matched with the given resource id.
 *
 * @param id resource id of the view to click.
 * @return an action that clicks a descendant of the view matched with the given resource id.
 */
public static ViewAction clickDescendantViewWithId(@IdRes final int id) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return hasDescendant(withId(id));
        }

        @Override
        public String getDescription() {
            return "Click on a descendant view with id: " + id;
        }

        @Override
        public void perform(UiController uiController, View view) {
            GeneralClickAction action = new GeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER);
            View target = view.findViewById(id);
            // getConstraints() guarantees that the target never be null.
            action.perform(uiController, target);
        }
    };
}
 
開發者ID:sumio,項目名稱:espresso-commons,代碼行數:29,代碼來源:RecyclerViewUtils.java

示例7: showControls

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
private static ViewAction showControls() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(MovieView.class);
        }

        @Override
        public String getDescription() {
            return "Show controls of MovieView";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ((MovieView) view).showControls();
            uiController.loopMainThreadUntilIdle();
        }
    };
}
 
開發者ID:googlesamples,項目名稱:android-PictureInPicture,代碼行數:21,代碼來源:MediaSessionPlaybackActivityTest.java

示例8: withCustomConstraints

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
/**
 * From: http://stackoverflow.com/questions/33505953/espresso-how-to-test-swiperefreshlayout/33516360#33516360
 * <p>
 * ViewPager will throw an error if not 90% of it is displayed. This reduces the restriction.
 *
 * @param action      Action to be done.
 * @param constraints Restrictions on the view.
 * @return Performs an action on the view.
 */
public static ViewAction withCustomConstraints(final ViewAction action, final Matcher<View> constraints)
{
    return new ViewAction()
    {
        @Override
        public Matcher<View> getConstraints()
        {
            return constraints;
        }

        @Override
        public String getDescription()
        {
            return action.getDescription();
        }

        @Override
        public void perform(UiController uiController, View view)
        {
            action.perform(uiController, view);
        }
    };
}
 
開發者ID:jbmlaird,項目名稱:DiscogsBrowser,代碼行數:33,代碼來源:TestUtils.java

示例9: setOrientation

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
static ViewAction setOrientation(final int orientation) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "Change orientation";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            changeOrientation(view, orientation);
        }
    };
}
 
開發者ID:dev-labs-bg,項目名稱:fullscreen-video-view,代碼行數:20,代碼來源:CustomChecks.java

示例10: setAspectRatio

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
static ViewAction setAspectRatio(@NonNull final AspectRatio ratio) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(CameraView.class);
        }

        @Override
        public String getDescription() {
            return "Set aspect ratio to " + ratio;
        }

        @Override
        public void perform(UiController controller, View view) {
            ((CameraView) view).setAspectRatio(ratio);
        }
    };
}
 
開發者ID:vshkl,項目名稱:PXLSRT,代碼行數:20,代碼來源:CameraViewActions.java

示例11: swipeOnCoord

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
public static ViewAction swipeOnCoord(final float fromX, final float fromY, final float toX, final float toY) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {

            return "Swipe from" + fromX + ", " + fromY + " to " + toX + ", " + toY;
        }

        @Override
        public void perform(UiController uiController, final View view) {
            drag(fromX, fromY, toX, toY);
        }
    };
}
 
開發者ID:cuplv,項目名稱:ChimpCheck,代碼行數:20,代碼來源:FingerGestures.java

示例12: waitFor

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
public static ViewAction waitFor(final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "Wait for " + millis + " milliseconds.";
        }

        @Override
        public void perform(UiController uiController, final View view) {
            uiController.loopMainThreadForAtLeast(millis);
        }
    };
}
 
開發者ID:d4rken,項目名稱:ommvplib,代碼行數:19,代碼來源:TestHelper.java

示例13: testGoToManual

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
/**
 * Test if the manual input activity opens.
 */
@Test
public void testGoToManual() {
    onView(withId(R.id.manual_input_button)).check(matches(allOf( isEnabled(), isClickable()))).perform(
            new ViewAction() {
                @Override
                public Matcher<View> getConstraints() {
                    return isEnabled(); // no constraints, they are checked above
                }

                @Override
                public String getDescription() {
                    return "click manual input button";
                }

                @Override
                public void perform(UiController uiController, View view) {
                    view.performClick();
                }
            }
    );
    intended(hasComponent(ManualInputActivity.class.getName()));
}
 
開發者ID:digital-voting-pass,項目名稱:polling-station-app,代碼行數:26,代碼來源:TestMainActivity.java

示例14: setNumber

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
/**
 * Set value for {@link NumberPicker}
 */
public static ViewAction setNumber(final int n) {
    return new ViewAction() {
        @Override
        public void perform(UiController uiController, View view) {
            ((NumberPicker) view).setValue(n);
        }

        @Override
        public String getDescription() {
            return "Set NumberPicker value";
        }

        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(NumberPicker.class);
        }
    };
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:22,代碼來源:EspressoUtils.java

示例15: smoothScrollToPosition_ScrollItemIsNotVisible_FirstVisiblePositionsEqualsScrollingTarget

import android.support.test.espresso.ViewAction; //導入依賴的package包/類
@Test
public synchronized void smoothScrollToPosition_ScrollItemIsNotVisible_FirstVisiblePositionsEqualsScrollingTarget() throws Exception {
    //arrange
    InstrumentalUtil.waitForIdle();

    //act
    ViewAction scrollAction = smoothScrollToPosition(18);
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (scrollAction) {
        recyclerView.perform(scrollAction);
        //wait for completion of SmoothScrollAction
        scrollAction.wait();
    }

    //assert
    int actual = layoutManager.findFirstCompletelyVisibleItemPosition();
    assertEquals(18, actual);
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:19,代碼來源:ColumnTest.java


注:本文中的android.support.test.espresso.ViewAction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。