Java Code Examples for android.widget.TextView#performClick()
The following examples show how to use
android.widget.TextView#performClick() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumericOptionItemTest.java From msdkui-android with Apache License 2.0 | 6 votes |
@Test public void testValueEditDialogPositive() { int newValue = 10; mNumericOptionItem.setLabel(getString(R.string.msdkui_violate_truck_options)); final TextView valueView = mNumericOptionItem.findViewById(R.id.numeric_item_value); assertNotNull(valueView); valueView.performClick(); AlertDialog alertDialog = (AlertDialog) ShadowDialog.getLatestDialog(); assertTrue(alertDialog.isShowing()); EditText valueEdit = alertDialog.findViewById(R.id.numeric_item_value_text); valueEdit.setText(String.valueOf(newValue)); alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); assertEquals(newValue, mNumericOptionItem.getValue().intValue()); }
Example 2
Source File: NumericOptionItemTest.java From msdkui-android with Apache License 2.0 | 5 votes |
@Test public void testValueEditDialogNegative() { mNumericOptionItem.setLabel(getString(R.string.msdkui_violate_truck_options)); final TextView valueView = mNumericOptionItem.findViewById(R.id.numeric_item_value); assertNotNull(valueView); valueView.performClick(); AlertDialog alertDialog = (AlertDialog) ShadowDialog.getLatestDialog(); assertTrue(alertDialog.isShowing()); alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); assertFalse(alertDialog.isShowing()); }
Example 3
Source File: TimeDialog.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * 处理返回键 */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { TextView btn = (TextView) findViewById(R.id.btnBack); btn.performClick(); return true; } return super.onKeyDown(keyCode, event); }
Example 4
Source File: FailDialog.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * 处理返回键 */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { TextView btn = (TextView) findViewById(R.id.fail_button_cancel); btn.performClick(); return true; } return super.onKeyDown(keyCode, event); }
Example 5
Source File: SuccessDialog.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * 处理返回键 */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { TextView btn = (TextView) findViewById(R.id.success_button_cancel); btn.performClick(); return true; } return super.onKeyDown(keyCode, event); }
Example 6
Source File: TaskDialog.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * 处理返回键 */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { TextView btn = (TextView) findViewById(R.id.btnBack); btn.performClick(); return true; } return super.onKeyDown(keyCode, event); }
Example 7
Source File: DiscussionTextUtilsTest.java From edx-app-android with Apache License 2.0 | 4 votes |
private void assertSetAuthorAttributionText(TextView textView, DiscussionTextUtils.AuthorAttributionLabel type, IAuthorData input, long now, String expectedOutput) { final Runnable listener = Mockito.mock(Runnable.class); DiscussionTextUtils.setAuthorAttributionText(textView, type, input, now, listener); if (expectedOutput == null) { assertTrue(textView.getVisibility() == View.GONE); } else { String output = textView.getText().toString(); assertEquals(expectedOutput, output); if (!input.isAuthorAnonymous()) { // Test whether author span is clickable or not int start = output.indexOf(input.getAuthor()); int end = start + input.getAuthor().length(); Spanned text = (Spanned) textView.getText(); StyleSpan[] styleSpans = text.getSpans(start, end, StyleSpan.class); ForegroundColorSpan[] colorSpans = text.getSpans(start, end, ForegroundColorSpan.class); if (config.isUserProfilesEnabled()) { // Verify that the author text is bold assertEquals(1, styleSpans.length); assertEquals(start, text.getSpanStart(styleSpans[0])); assertEquals(end, text.getSpanEnd(styleSpans[0])); assertEquals(Typeface.BOLD, styleSpans[0].getStyle()); // Verify that the correct foreground color is set assertEquals(1, colorSpans.length); assertEquals(start, text.getSpanStart(colorSpans[0])); assertEquals(end, text.getSpanEnd(colorSpans[0])); assertEquals(context.getResources().getColor(R.color.edx_brand_primary_base), colorSpans[0].getForegroundColor()); // Verify that the whole text view is clickable textView.performClick(); Mockito.verify(listener).run(); } else { assertEquals(0, styleSpans.length); assertEquals(0, colorSpans.length); assertFalse(textView.isClickable()); } } } }