/** * Test that swiping on the populated list triggers a refresh. */ public void testSwipingListView() { // Given a SwipeRefreshLayout which is displaying a populated list // When the swipe refresh layout is dragged TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, Math.round(mSwipeRefreshLayout.getHeight() * 0.4f)); // Then the SwipeRefreshLayout should be refreshing // We need to use runOnMainSync here as fake dragging uses waitForIdleSync() getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { assertTrue(mSwipeRefreshLayout.isRefreshing()); } }); }
/** * Test that swiping on the empty view triggers a refresh. */ public void testSwipingEmptyView() { // Given a SwipeRefreshLayout which is displaying the empty view // When the swipe refresh layout is dragged TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.CENTER, 0, Math.round(mSwipeRefreshLayout.getHeight() * 0.4f)); // Then the SwipeRefreshLayout should be refreshing getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { assertTrue(mSwipeRefreshLayout.isRefreshing()); } }); }
/** * Test that swiping on the populated list triggers a refresh. */ public void testSwipingListView() { // Given a SwipeRefreshLayout which is displaying a populated list populateList(); // When the swipe refresh layout is dragged TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.CENTER, 0, Math.round(mSwipeRefreshLayout.getHeight() * 0.4f)); // Then the SwipeRefreshLayout should be refreshing // We need to use runOnMainSync here as fake dragging uses waitForIdleSync() getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { assertTrue(mSwipeRefreshLayout.isRefreshing()); } }); }
public void setUp() throws Exception{ Log.e("TestScript_Guide", "setUp test!!"); setActivityInitialTouchMode(false); weappApplication = new WeappJsBaseTestCase(); mInstrumentation = getInstrumentation(); Intent intent = new Intent(); intent.putExtra("bundleUrl", Constants.BUNDLE_URL); launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent); waTestPageActivity = getActivity(); // waTestPageActivity.getIntent().getData().toString(); Log.e(TAG,"activity1=" + waTestPageActivity.toString() ); Thread.sleep(3000); mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container); setViewGroup(mViewGroup); Thread.sleep(2000); TouchUtils.scrollToBottom(this, waTestPageActivity, mViewGroup); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_"); addAllTargetView("TC_"); Thread.sleep(3000); }
/** * */ public void setUpToFindComponet(String target, InstrumentationTestCase test){ int max = 60; int count = 0; while(mCaseListIndexView.size() == 0){ if (count < max){ TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance ); mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target); count ++; } else{ break; } } }
/** * */ public void setUpToFindComponet(String target, InstrumentationTestCase test){ int max = 60; int count = 0; while(mCaseListIndexView.size() == 0){ if (count < max){ TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance ); mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target); count ++; } else{ targetComponetNotFound = true; } } }
/** * */ public void setUpToFindComponet(String targert){ int max = 60; int count = 0; while(mCaseListIndexView.size() == 0){ if (count < max){ TouchUtils.dragQuarterScreenUp(this, this.getActivity()); mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, targert); count ++; } else{ break; } } }
/** * */ public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){ if(mCaseListIndexView.size() ==1 || targetComponetNotFound){ if(((WXTextView)mCaseListIndexView.get(0)) .getText() .toString() .equals("TC__Home")){ TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance ); mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target); } TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance ); mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target); } }
public void setUp() throws Exception{ Log.e("TestScript_Guide", "setUp test!!"); setActivityInitialTouchMode(false); weappApplication = new WeappJsBaseTestCase(); mInstrumentation = getInstrumentation(); Intent intent = new Intent(); intent.putExtra("bundleUrl", Constants.BUNDLE_URL); launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent); waTestPageActivity = getActivity(); // waTestPageActivity.getIntent().getData().toString(); Log.e(TAG,"activity1=" + waTestPageActivity.toString() ); Thread.sleep(3000); mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container); setViewGroup(mViewGroup); Thread.sleep(2000); TouchUtils.scrollToBottom(this, waTestPageActivity, mViewGroup); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_"); Thread.sleep(3000); }
public void setUp() throws Exception{ Log.e("TestScript_Guide", "setUp test!!"); setActivityInitialTouchMode(false); weappApplication = new WeappJsBaseTestCase(); mInstrumentation = getInstrumentation(); Intent intent = new Intent(); intent.putExtra("bundleUrl", Constants.BUNDLE_URL); launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent); waTestPageActivity = getActivity(); // waTestPageActivity.getIntent().getData().toString(); Log.e(TAG,"activity1=" + waTestPageActivity.toString() ); Thread.sleep(3000); mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container); setViewGroup(mViewGroup); TouchUtils.scrollToBottom(this, waTestPageActivity, mViewGroup); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_"); Thread.sleep(3000); }
public void setUp() throws Exception{ Log.e("TestScript_Guide", "setUp test!!"); setActivityInitialTouchMode(false); weappApplication = new WeappJsBaseTestCase(); mInstrumentation = getInstrumentation(); Intent intent = new Intent(); intent.putExtra("bundleUrl", Constants.BUNDLE_URL); launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent); waTestPageActivity = getActivity(); // waTestPageActivity.getIntent().getData().toString(); Log.e(TAG,"activity1=" + waTestPageActivity.toString() ); Thread.sleep(3000); mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container); setViewGroup(mViewGroup); TouchUtils.scrollToBottom(this, waTestPageActivity, mViewGroup); mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_"); Thread.sleep(1000); }
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); }
/** * Test the coachmark's click listener */ private void checkCoachMarkClick() { showCoachMark(getInstrumentation(), mCoachMark); final View container = mCoachMark.getContentView(); TouchUtils.tapView(this, container); verify(mMockTargetClickListener, never()).onClick(container); verify(mMockCoachMarkClickListener, times(1)).onClick(container); // Check whether global listener is working on tapping textview(message) // The container view should be checked whether it is clicked or not. // Because tap event propagated to parent view when target view don't have listener. TouchUtils.tapView(this, mTextView); verify(mMockTargetClickListener, never()).onClick(container); verify(mMockCoachMarkClickListener, times(2)).onClick(container); }
@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()); }