本文整理汇总了Java中android.test.ViewAsserts.assertOnScreen方法的典型用法代码示例。如果您正苦于以下问题:Java ViewAsserts.assertOnScreen方法的具体用法?Java ViewAsserts.assertOnScreen怎么用?Java ViewAsserts.assertOnScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.test.ViewAsserts
的用法示例。
在下文中一共展示了ViewAsserts.assertOnScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkViewsCreatedAndVisible
import android.test.ViewAsserts; //导入方法依赖的package包/类
/**
* Test the view creation and visibility.
*/
private void checkViewsCreatedAndVisible() {
showCoachMark(getInstrumentation(), mCoachMark);
final View container = mCoachMark.getContentView();
// Check the creation
assertNotNull(getActivity());
assertNotNull(mCoachMark);
assertNotNull(container);
assertNotNull(mTextView);
// Check the visibility
ViewAsserts.assertOnScreen(container, mTextView);
ViewAsserts.assertHorizontalCenterAligned(container, mTextView);
// Check the resources which passed by builder
assertEquals(MESSAGE, mTextView.getText().toString());
}
示例2: testNoAccountUi
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testNoAccountUi() throws Throwable {
getActivity();
ListView userList = (ListView) getActivity().findViewById(R.id.user_list);
TextView enterPinPrompt = (TextView) getActivity().findViewById(R.id.enter_pin_prompt);
Button howItWorksButton = (Button) getActivity().findViewById(R.id.how_it_works_button);
Button addAccountButton = (Button) getActivity().findViewById(R.id.add_account_button);
View contentWhenNoAccounts = getActivity().findViewById(R.id.content_no_accounts);
// check existence of fields
assertNotNull(userList);
assertNotNull(enterPinPrompt);
assertNotNull(howItWorksButton);
assertNotNull(addAccountButton);
assertNotNull(contentWhenNoAccounts);
// check visibility
View origin = getActivity().getWindow().getDecorView();
ViewAsserts.assertOnScreen(origin, enterPinPrompt);
ViewAsserts.assertOnScreen(origin, howItWorksButton);
ViewAsserts.assertOnScreen(origin, addAccountButton);
ViewAsserts.assertOnScreen(origin, contentWhenNoAccounts);
assertFalse(userList.isShown());
}
示例3: testWithCounterBasedAccount
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testWithCounterBasedAccount() {
setActivityIntent(new Intent(Intent.ACTION_MAIN).putExtra("user", "[email protected]"));
CheckCodeActivity mActivity = getActivity();
TextView mCodeTextView = (TextView) mActivity.findViewById(R.id.code_value);
TextView mCheckCodeTextView = (TextView) mActivity.findViewById(R.id.check_code);
TextView mCounterValue = (TextView) mActivity.findViewById(R.id.counter_value);
// check existence of fields
assertNotNull(mCheckCodeTextView);
assertNotNull(mCodeTextView);
assertNotNull(mCounterValue);
// check visibility
View origin = mActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(origin, mCheckCodeTextView);
ViewAsserts.assertOnScreen(origin, mCodeTextView);
ViewAsserts.assertOnScreen(origin, mCounterValue);
assertTrue(mActivity.findViewById(R.id.code_area).isShown()); // layout area
assertTrue(mActivity.findViewById(R.id.counter_area).isShown()); // layout area
// check values
MoreAsserts.assertContainsRegex("[email protected]", mCheckCodeTextView.getText().toString());
assertEquals("724477", mCodeTextView.getText().toString());
assertEquals("0", mCounterValue.getText().toString());
}
示例4: testClickMeButton_layout
import android.test.ViewAsserts; //导入方法依赖的package包/类
@MediumTest
public void testClickMeButton_layout() {
final View decorView = mActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, mBtn);
final ViewGroup.LayoutParams layoutParams = mBtn.getLayoutParams();
assertNotNull(layoutParams);
assertEquals(layoutParams.width, RelativeLayout.LayoutParams.WRAP_CONTENT);
assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT);
}
示例5: testFirstImageDataLoaded
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testFirstImageDataLoaded() throws Exception {
final View decorView = mActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, mRecyclerView);
ImageAdapter mImageAdapter = ImageDataManager.getInstance().getImageAdapter();
Thread.sleep(5000); // sleep to wait for request for image data to finish
// Test First round of ImageData is retrieved
int initialItemCount = mImageAdapter.getItemCount();
assertTrue(initialItemCount > 0);
Log.d("Test", "initialItemCount = " + initialItemCount);
}
示例6: testEditText
import android.test.ViewAsserts; //导入方法依赖的package包/类
@UiThreadTest
public void testEditText() {
assertEquals(nameEditText.getText().toString(), "");
nameEditText.setText("Jana Moudra");
assertEquals(nameEditText.getText().toString(), "Jana Moudra");
View origin = mainActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(origin, nameEditText);
}
示例7: testMessageBox
import android.test.ViewAsserts; //导入方法依赖的package包/类
@MediumTest
public void testMessageBox() {
//Retrieve the top-level window decor view
final View decorView = mUserActivity.getWindow().getDecorView();
//Verify that the mMessage is on screen and is not visible
ViewAsserts.assertOnScreen(decorView, mMessage);
assertTrue(View.VISIBLE == mMessage.getVisibility());
}
示例8: testWithTimeBasedAccount
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testWithTimeBasedAccount() {
// For TOTP accounts, AuthenticatorActivity never calls CheckCodeActivity, however, the
// code exists and we check its behavior here.
setActivityIntent(new Intent(Intent.ACTION_MAIN).putExtra("user", "[email protected]"));
CheckCodeActivity mActivity = getActivity();
TextView mCodeTextView = (TextView) mActivity.findViewById(R.id.code_value);
TextView mCheckCodeTextView = (TextView) mActivity.findViewById(R.id.check_code);
TextView mCounterValue = (TextView) mActivity.findViewById(R.id.counter_value);
// check existence of fields
assertNotNull(mActivity);
assertNotNull(mCheckCodeTextView);
assertNotNull(mCodeTextView);
assertNotNull(mCounterValue);
// check visibility
View origin = mActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(origin, mCheckCodeTextView);
ViewAsserts.assertOnScreen(origin, mCodeTextView);
assertTrue(mActivity.findViewById(R.id.code_area).isShown()); // layout area
assertFalse(mCounterValue.isShown()); // TOTP has no counter value to show.
assertFalse(mActivity.findViewById(R.id.counter_area).isShown()); // layout area
// check values
MoreAsserts.assertContainsRegex("[email protected]", mCheckCodeTextView.getText().toString());
assertEquals("724477", mCodeTextView.getText().toString());
}
示例9: testFieldsAreOnScreen
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testFieldsAreOnScreen() {
Window window = mActivity.getWindow();
View origin = window.getDecorView();
ViewAsserts.assertOnScreen(origin, mAccountName);
ViewAsserts.assertOnScreen(origin, mKeyEntryField);
ViewAsserts.assertOnScreen(origin, mType);
ViewAsserts.assertOnScreen(origin, mSubmitButton);
}
示例10: testTextViewLayout
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testTextViewLayout(){
final View decorView = connectionsActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, textView);
final ViewGroup.LayoutParams layoutParams = textView.getLayoutParams();
assertNotNull(layoutParams);
assertEquals(layoutParams.width, layoutParams.WRAP_CONTENT);
assertEquals(layoutParams.height, layoutParams.WRAP_CONTENT);
}
示例11: testAddButtonLayout
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testAddButtonLayout(){
final View decorView = myChannelsActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, addButton);
final ViewGroup.LayoutParams layoutParams = addButton.getLayoutParams();
assertNotNull(layoutParams);
assertEquals(layoutParams.width, 135);
assertEquals(layoutParams.height, 135);
}
示例12: testClickMeButton_layout
import android.test.ViewAsserts; //导入方法依赖的package包/类
@MediumTest
public void testClickMeButton_layout() {
// Retrieve the top-level window decor view
final View decorView = mClickFunActivity.getWindow()
.getDecorView();
// Verify that the mClickMeButton is on screen
ViewAsserts.assertOnScreen(decorView, mClickMeButton);
// Verify width and heights
final ViewGroup.LayoutParams layoutParams = mClickMeButton.getLayoutParams();
assertNotNull(layoutParams);
assertEquals(layoutParams.width, WindowManager.LayoutParams.MATCH_PARENT);
assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT);
}
示例13: testInfoTextView_layout
import android.test.ViewAsserts; //导入方法依赖的package包/类
@MediumTest
public void testInfoTextView_layout() {
// Retrieve the top-level window decor view
final View decorView = mClickFunActivity.getWindow()
.getDecorView();
// Verify that the mInfoTextView is on screen and is not visible
ViewAsserts.assertOnScreen(decorView, mInfoTextView);
assertTrue(View.GONE == mInfoTextView.getVisibility());
}
示例14: testClickSaveButton_layout
import android.test.ViewAsserts; //导入方法依赖的package包/类
public void testClickSaveButton_layout(){
final View decorView = listViewCheckboxTagsActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, saveButtonTest);
final ViewGroup.LayoutParams layoutParams = saveButtonTest.getLayoutParams();
assertNotNull(layoutParams);
assertEquals(layoutParams.width, WindowManager.LayoutParams.MATCH_PARENT);
assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT);
}
示例15: testListQuestions
import android.test.ViewAsserts; //导入方法依赖的package包/类
@UiThreadTest
public void testListQuestions() {
MainActivity ma = getActivity();
ViewAsserts.assertOnScreen(ma.getWindow().getDecorView(), ma.findViewById(com.team09.qanda.R.id.MainListView));
ViewAsserts.assertOnScreen(ma.getWindow().getDecorView(), ma.findViewById(com.team09.qanda.R.id.authorMain));
}