/** * The Android library module's own tests, independent from the main app. */ @RunWith(AndroidJUnit4.class) @MediumTest public class AndroidLibraryModuleTest { private Context mContext; @Before public void initTargetContext() { mContext = InstrumentationRegistry.getTargetContext(); assertThat(mContext, notNullValue()); } @Test public void verifyResourceFromLibrary() { assertThat(mContext.getString(R.string.library_module_hello_world), is(equalTo("Hello from an Android library module!"))); } @Test public void verifyClassFromLibrary() { AndroidLibraryModuleClass libraryModuleInstance = new AndroidLibraryModuleClass(); assertThat(libraryModuleInstance.isReady(), is(true)); } }
@MediumTest public void testLaunchingWithValidNativeLinkingNoUserIntent() throws Exception { final TestBlocker blocker = getTestBlocker();
@MediumTest @LargeTest public void testStaticExecuteMyFriendsAsync() { final AccessToken accessToken = getAccessTokenForSharedUser(); class FriendsCallback extends ExpectSuccessCallback implements GraphRequest.GraphJSONArrayCallback { @Override public void onCompleted(JSONArray friends, GraphResponse response) { assertNotNull(friends); RequestTests.validateMyFriendsResponse(response); onCompleted(response); } } runOnBlockerThread(new Runnable() { @Override public void run() { GraphRequest.newMyFriendsRequest(accessToken, new FriendsCallback()).executeAsync(); } }, false); waitAndAssertSuccess(1); }
@MediumTest @LargeTest public void testStaticExecuteMeAsync() { final AccessToken accessToken = getAccessTokenForSharedUser(); class MeCallback extends ExpectSuccessCallback implements GraphRequest.GraphJSONObjectCallback { @Override public void onCompleted(JSONObject me, GraphResponse response) { assertNotNull(me); assertEquals(accessToken.getUserId(), me.optString("id")); RequestTests.validateMeResponse(accessToken, response); onCompleted(response); } } runOnBlockerThread(new Runnable() { @Override public void run() { GraphRequest.newMeRequest(accessToken, new MeCallback()).executeAsync(); } }, false); waitAndAssertSuccess(1); }
@MediumTest @LargeTest public void testShortTimeoutCausesFailure() { final AccessToken accessToken = getAccessTokenForSharedUser(); GraphRequest request = new GraphRequest(accessToken, "me/likes", null, null, new ExpectFailureCallback()); GraphRequestBatch requestBatch = new GraphRequestBatch(request); // 1 millisecond timeout should be too short for response from server. requestBatch.setTimeout(1); TestGraphRequestAsyncTask task = new TestGraphRequestAsyncTask(requestBatch); task.executeOnBlockerThread(); // Note: plus 1, because the overall async task signals as well. waitAndAssertSuccess(2); }
/** * Test basic startup/shutdown of Application */ @MediumTest public void testSimpleCreate() { createApplication(); }
/** * Test basic startup/shutdown of Application */ @MediumTest public void testSimpleCreate() { createApplication(); }
@MediumTest public void test600k() throws Throwable { template(600); }
@MediumTest public void test600k2() throws Throwable { template2(600); }
/** * Test binding to service */ @MediumTest public void testBindable() { Intent startIntent = new Intent(); startIntent.setClass(getContext(), LocalService.class); IBinder service = bindService(startIntent); }
/** * Test binding to service */ @MediumTest public void testBindable() { Intent startIntent = new Intent(); startIntent.setClass(getContext(), LocalService.class); IBinder service = bindService(startIntent); }
@MediumTest public void testGoingRightFromLeftButtonJumpsOverCenterToRight() { sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT); assertTrue("right button should be focused", mRightButton.isFocused()); }
@MediumTest public void testGoingRightFromLeftButtonJumpsOverCenterToRight() { sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT); assertTrue("right button should be focused", mRightButton.isFocused()); }
@MediumTest public void testRotate() throws Throwable { getActivity().startActivity(intent); final ImageView btn = (ImageView) getActivity().findViewById(R.id.go); runTestOnUiThread(new Runnable() { @Override public void run() { btn.performClick(); } }); }
/** * The name 'test preconditions' is a convention to signal that if this * test doesn't pass, the test case was not set up properly and it might * explain any and all failures in other tests. This is not guaranteed * to run before other tests, as junit uses reflection to find the tests. */ @MediumTest public void testPreconditions() { startActivity(mStartIntent, null, null); mButton = (Button) getActivity().findViewById(R.id.go); assertNotNull(getActivity()); assertNotNull(mButton); }
/** * The name 'test preconditions' is a convention to signal that if this * test doesn't pass, the test case was not set up properly and it might * explain any and all failures in other tests. This is not guaranteed * to run before other tests, as junit uses reflection to find the tests. */ @MediumTest public void testPreconditions() { startActivity(mStartIntent, null, null); mButton = (Button) getActivity().findViewById(R.id.go); assertNotNull(getActivity()); assertNotNull(mButton); }
/** * This test demonstrates examining the way that activity calls startActivity() to launch * other activities. */ @MediumTest public void testSubLaunch() { Forwarding activity = startActivity(mStartIntent, null, null); mButton = (Button) activity.findViewById(R.id.go); // This test confirms that when you click the button, the activity attempts to open // another activity (by calling startActivity) and close itself (by calling finish()). mButton.performClick(); assertNotNull(getStartedActivityIntent()); assertTrue(isFinishCalled()); }
/** * This test demonstrates examining the way that activity calls startActivity() to launch * other activities. */ @MediumTest public void testSubLaunch() { Forwarding activity = startActivity(mStartIntent, null, null); mButton = (Button) activity.findViewById(R.id.go); // This test confirms that when you click the button, the activity attempts to open // another activity (by calling startActivity) and close itself (by calling finish()). mButton.performClick(); assertNotNull(getStartedActivityIntent()); assertTrue(isFinishCalled()); }
/** * The name 'test preconditions' is a convention to signal that if this * test doesn't pass, the test case was not set up properly and it might * explain any and all failures in other tests. This is not guaranteed * to run before other tests, as junit uses reflection to find the tests. */ @MediumTest public void testPreconditions() { assertTrue("center button should be right of left button", mLeftButton.getRight() < mCenterButton.getLeft()); assertTrue("right button should be right of center button", mCenterButton.getRight() < mRightButton.getLeft()); assertTrue("left button should be focused", mLeftButton.isFocused()); }
/** * The name 'test preconditions' is a convention to signal that if this * test doesn't pass, the test case was not set up properly and it might * explain any and all failures in other tests. This is not guaranteed * to run before other tests, as junit uses reflection to find the tests. */ @MediumTest public void testPreconditions() { assertTrue("center button should be right of left button", mLeftButton.getRight() < mCenterButton.getLeft()); assertTrue("right button should be right of center button", mCenterButton.getRight() < mRightButton.getLeft()); assertTrue("left button should be focused", mLeftButton.isFocused()); }