本文整理汇总了Java中android.test.MoreAsserts.assertContainsRegex方法的典型用法代码示例。如果您正苦于以下问题:Java MoreAsserts.assertContainsRegex方法的具体用法?Java MoreAsserts.assertContainsRegex怎么用?Java MoreAsserts.assertContainsRegex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.test.MoreAsserts
的用法示例。
在下文中一共展示了MoreAsserts.assertContainsRegex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWithCounterBasedAccount
import android.test.MoreAsserts; //导入方法依赖的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());
}
示例2: testRecordBuilderImplHasAHierarchyDumpFile
import android.test.MoreAsserts; //导入方法依赖的package包/类
@Test
public void testRecordBuilderImplHasAHierarchyDumpFile() throws Throwable {
RecordBuilderImpl rb = mScreenshot.snap(mTextView).setName("blahblah");
rb.record();
mScreenshot.flush();
String fileName =
new File(mScreenshotDirectories.get("verify-in-test"), "blahblah_dump.json")
.getAbsolutePath();
InputStream is = new FileInputStream(fileName);
StringBuilder builder = new StringBuilder();
byte[] buffer = new byte[8 * 1024];
int read;
while ((read = is.read(buffer)) != -1) {
builder.append(new String(buffer, 0, read));
}
String expected =
"{"
+ " \"class\": \"android.widget.TextView\","
+ " \"left\": 0,"
+ " \"top\": 0,"
+ " \"width\": 200,"
+ " \"height\": 100"
+ "}";
assertEquals(expected, builder.toString().replace("\n", ""));
File metadata = mAlbumImpl.getMetadataFile();
String metadataContents = fileToString(metadata);
MoreAsserts.assertContainsRegex("blahblah.*.json", metadataContents);
}
示例3: testWithTimeBasedAccount
import android.test.MoreAsserts; //导入方法依赖的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());
}
示例4: testWithAnotherCounterBasedAccount
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void testWithAnotherCounterBasedAccount() {
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);
MoreAsserts.assertContainsRegex(
"[email protected]", mCheckCodeTextView.getText().toString());
assertEquals("086620", mCodeTextView.getText().toString());
}