本文整理汇总了Java中android.test.TouchUtils.clickView方法的典型用法代码示例。如果您正苦于以下问题:Java TouchUtils.clickView方法的具体用法?Java TouchUtils.clickView怎么用?Java TouchUtils.clickView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.test.TouchUtils
的用法示例。
在下文中一共展示了TouchUtils.clickView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLaunchAboutAndSettingsActivities
import android.test.TouchUtils; //导入方法依赖的package包/类
public void testLaunchAboutAndSettingsActivities() {
mSolo.sendKey(Solo.MENU);
mSolo.sendKey(KeyEvent.KEYCODE_MENU);
mSolo.clickOnMenuItem("About");
mSolo.sleep(1500);
mSolo.assertCurrentActivity("About activity has not started", AboutActivity.class);
mSolo.getCurrentActivity().finish();
mSolo.sleep(2000);
TouchUtils.clickView(this, mSortSettingsImageView);
mSolo.sleep(1000);
assertTrue("Could not find the dialog!", mSolo.searchText("Suggestions sorting"));
mSolo.clickOnButton("OK");
mSolo.sleep(500);
}
示例2: testClickSendTweet
import android.test.TouchUtils; //导入方法依赖的package包/类
@MediumTest
public void testClickSendTweet() {
String expectedInfoText = mUserActivity.getString(R.string.tweet);
mUserActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
mMessage.setText("Hey, I'm in twitter");
}
});
// Perform a click on mSendTweetButton
TouchUtils.clickView(this, mSendTweetButton);
// Verify the that mSendTweetButton was clicked. mMessage is visible and contains
// the correct text.
assertTrue(View.VISIBLE == mMessage.getVisibility());
assertNotSame("", mMessage.getText());
}
示例3: testbtSend_pushButton
import android.test.TouchUtils; //导入方法依赖的package包/类
public void testbtSend_pushButton(){
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
etMessage.requestFocus();
}
});
getInstrumentation().waitForIdleSync();
getInstrumentation().sendStringSync("Test");
getInstrumentation().waitForIdleSync();
TouchUtils.clickView(this, btSend);
listView = (ListView) mChatActivity.findViewById(R.id.lvChat);
ChatListAdapter adapter = (ChatListAdapter) listView.getAdapter();
Message sent = adapter.getItem(0);
assertEquals("message not showing up in chat", sent.getBody(), "Test");
}
示例4: testClear
import android.test.TouchUtils; //导入方法依赖的package包/类
/**
* Tests that a clear will actually clear the list adapter.
*/
public void testClear() {
//Add Items to the List and notify ListAdapter of change
_list.add("Test1");
_list.add("Test2");
_activity.runOnUiThread(new Runnable() {
@Override
public void run() {
_listAdapter.notifyDataSetChanged();
}
});
assertEquals(2, _listAdapter.getCount()); //Confirm Add worked
//Simulate pressing clear button
TouchUtils.clickView(this, _clearButton);
assertEquals(0, _listAdapter.getCount());
}
示例5: launchCreateExperimentActivity
import android.test.TouchUtils; //导入方法依赖的package包/类
public static Activity launchCreateExperimentActivity(
ActivityInstrumentationTestCase2<?> testCase, Activity activity) {
// click the Create-New-Experiment button
ActivityMonitor activityMonitor = testCase.getInstrumentation().addMonitor(
CreateExperimentActivity.class.getName(), null, false);
Button buttonCreateExperiment = (Button) activity
.findViewById(R.id.button_create_experiment);
Assert.assertNotNull("The Create-Experiment Button should not be null",
buttonCreateExperiment);
TouchUtils.clickView(testCase, buttonCreateExperiment);
testCase.getInstrumentation().waitForIdleSync();
activity = testCase.getInstrumentation().waitForMonitor(activityMonitor);
testCase.getInstrumentation().removeMonitor(activityMonitor);
return activity;
}
示例6: viewMostRecentExperiment
import android.test.TouchUtils; //导入方法依赖的package包/类
public static Activity viewMostRecentExperiment(ActivityInstrumentationTestCase2<?> testCase,
Activity activity) {
// view the most recent experiment
Fragment fragment = ((SensorDataCollectorActivity) activity).getSupportFragmentManager()
.findFragmentById(R.id.fragment_container);
Assert.assertNotNull("The Sensor List Fragment should not be null.", fragment);
ListView listView = ((ListFragment) fragment).getListView();
Assert.assertNotNull("ListView should not be null.", listView);
ActivityMonitor monitor = testCase.getInstrumentation().addMonitor(
ViewExperimentActivity.class.getName(), null, false);
TouchUtils.clickView(testCase, listView.getChildAt(listView.getHeaderViewsCount()));
testCase.getInstrumentation().waitForIdleSync();
ViewExperimentActivity viewExperimentActivity = (ViewExperimentActivity) testCase
.getInstrumentation().waitForMonitor(monitor);
Assert.assertTrue("activity should be a ViewExperimentActivity.",
viewExperimentActivity instanceof ViewExperimentActivity);
testCase.getInstrumentation().removeMonitor(monitor);
// clone the experiment
testCase.getInstrumentation().waitForIdleSync();
return viewExperimentActivity;
}
示例7: cloneExperiment
import android.test.TouchUtils; //导入方法依赖的package包/类
public static Activity cloneExperiment(ActivityInstrumentationTestCase2<?> testCase,
Activity activity) {
Assert.assertTrue("The acitivty must be a ViewExperimentActivity.",
activity instanceof ViewExperimentActivity);
Button buttonCloneExperiment = (Button) activity
.findViewById(R.id.button_experiment_view_clone);
Assert.assertNotNull("Button should not be null.", buttonCloneExperiment);
ActivityMonitor monitor = testCase.getInstrumentation().addMonitor(
CreateExperimentActivity.class.getName(), null, false);
TouchUtils.clickView(testCase, buttonCloneExperiment);
activity = testCase.getInstrumentation().waitForMonitorWithTimeout(monitor, 5000);
Assert.assertTrue("activity should be CreateExperimentActivity.",
activity instanceof CreateExperimentActivity);
testCase.getInstrumentation().removeMonitor(monitor);
return activity;
}
示例8: testClickMeButton_clickButtonAndExpectInfoText
import android.test.TouchUtils; //导入方法依赖的package包/类
@MediumTest
public void testClickMeButton_clickButtonAndExpectInfoText() {
/*
TouchUtils 只能用于test thread
*/
TouchUtils.clickView(this, mBtn);
assertTrue(View.VISIBLE == mBtn.getVisibility());
assertEquals("点击了Recycler", mBtn.getText());
}
示例9: testAddition
import android.test.TouchUtils; //导入方法依赖的package包/类
@Test
public void testAddition() {
// 数字入力(num1)
EditText num1 = (EditText)mActivity.findViewById(R.id.num1);
TouchUtils.clickView(this, num1);
sendKeys(KeyEvent.KEYCODE_1);
// 数字入力(num2)
EditText num2 = (EditText)mActivity.findViewById(R.id.num2);
TouchUtils.clickView(this, num2);
sendKeys(KeyEvent.KEYCODE_1);
sendKeys(KeyEvent.KEYCODE_0);
// ResultActivityの起動を監視
Instrumentation.ActivityMonitor monitor =
new Instrumentation.ActivityMonitor(ResultActivity.class.getCanonicalName(), null, false);
getInstrumentation().addMonitor(monitor);
// =ボタンクリック
Button addBtn = (Button)mActivity.findViewById(R.id.equal_button);
TouchUtils.clickView(this, addBtn);
// 起動待ち
Activity resultActivity = getInstrumentation().waitForMonitorWithTimeout(monitor, 3000L);
// ResultActivityが起動したか確認
assertThat(monitor.getHits(), is(1));
assertThat(resultActivity, notNullValue());
// 計算結果確認
TextView result = (TextView)resultActivity.findViewById(R.id.result);
assertThat(result.getText().toString(), is("11"));
}
示例10: testClickMeButton_clickButtonAndExpectInfoText
import android.test.TouchUtils; //导入方法依赖的package包/类
@MediumTest
public void testClickMeButton_clickButtonAndExpectInfoText() {
String expectedInfoText = mClickFunActivity.getString(R.string.info_text);
// Perform a click on mClickMeButton
TouchUtils.clickView(this, mClickMeButton);
// Verify the that mClickMeButton was clicked. mInfoTextView is visible
// and contains
// the correct text.
assertTrue(View.VISIBLE == mInfoTextView.getVisibility());
assertEquals(expectedInfoText, mInfoTextView.getText());
}
示例11: startExperiment
import android.test.TouchUtils; //导入方法依赖的package包/类
public static void startExperiment(ActivityInstrumentationTestCase2<?> testCase,
Activity activity) {
Assert.assertTrue("The activity must be a CreateExperimentActivity.",
activity instanceof CreateExperimentActivity);
Button buttonRunExperiment = (Button) activity.findViewById(R.id.button_experiment_run);
Assert.assertNotNull("The Run-Experiment button should not be null.", buttonRunExperiment);
TouchUtils.clickView(testCase, buttonRunExperiment);
testCase.getInstrumentation().waitForIdleSync();
}
示例12: stopExperiment
import android.test.TouchUtils; //导入方法依赖的package包/类
public static Activity stopExperiment(ActivityInstrumentationTestCase2<?> testCase,
Activity activity) {
Assert.assertTrue("The activity must be a CreateExperimentActivity.",
activity instanceof CreateExperimentActivity);
Fragment fragment = ((CreateExperimentActivity) activity).getSupportFragmentManager()
.findFragmentById(
R.id.fragment_container);
Assert.assertNotNull("The ExperimentRunFragment should not be null.", fragment);
Assert.assertTrue("The fragment should be an ExperimentRunFragment.",
fragment instanceof ExperimentRunFragment);
Button buttonExperimentDone = (Button) fragment.getView().findViewById(
R.id.button_experiment_done);
Assert.assertNotNull("The Experiment-Done button shoud not be null.", buttonExperimentDone);
TouchUtils.clickView(testCase, buttonExperimentDone);
testCase.getInstrumentation().waitForIdleSync();
AlertDialog dialog = ((CreateExperimentActivity) activity).getAlertDialog();
Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
ActivityMonitor monitor = testCase.getInstrumentation().addMonitor(
SensorDataCollectorActivity.class.getName(), null, false);
TouchUtils.clickView(testCase, positiveButton);
testCase.getInstrumentation().waitForIdleSync();
SensorDataCollectorActivity sensorDataCollectorActivity =
(SensorDataCollectorActivity) testCase.getInstrumentation().waitForMonitor(monitor);
testCase.getInstrumentation().removeMonitor(monitor);
Assert.assertNotNull("SensorDataCollector Activity was not loaded",
sensorDataCollectorActivity);
return sensorDataCollectorActivity;
}
示例13: tap
import android.test.TouchUtils; //导入方法依赖的package包/类
private boolean tap(int id) {
View view = getView(id);
if(view != null) {
TouchUtils.clickView(this, view);
return true;
}
return false;
}
示例14: getInstrumentation
import android.test.TouchUtils; //导入方法依赖的package包/类
public void test点击链接() {
final Instrumentation inst = getInstrumentation();
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_VIEW);
intentFilter.addDataScheme("http");
intentFilter.addCategory(Intent.CATEGORY_BROWSABLE);
View link = this.getActivity().findViewById(R.id.link);
ActivityMonitor monitor = inst.addMonitor(
intentFilter, null, false);
assertEquals(0, monitor.getHits());
TouchUtils.clickView(this, link);
monitor.waitForActivityWithTimeout(5000);
assertEquals(1, monitor.getHits());
inst.removeMonitor(monitor);
}
示例15: testShowEmojiMenu
import android.test.TouchUtils; //导入方法依赖的package包/类
public void testShowEmojiMenu() {
TouchUtils.clickView(this, button);
View menu = emojiMenu.getPopupWindow().getContentView();
sleep(1000);
assertTrue(menu.isShown());
}