Java 类android.test.suitebuilder.annotation.LargeTest 实例源码

项目:Freifunk-App    文件:NodeRepositoryTest.java   
@Test
@LargeTest // this is a slow tests, uses network
public void fetchNodeList_FetchesDataFromServer() throws Exception {
    // for some reason normal TimingLogger doesnt output anything in androidTest, even if setting correct log level (Log.d returns -1)...
    SysOutTimingLogger timing = new SysOutTimingLogger(TAG, "perf");

    List<Node> result = NodeRepository.fetchNodeList();
    assertTrue(result.size() > 0);
    timing.addSplit("fetch");

    NodeRepository sut = makeSut();
    sut.setNodes(result);
    timing.addSplit("set nodes");

    sut.save();
    timing.addSplit("save");

    NodeRepository.load(InstrumentationRegistry.getTargetContext());
    timing.addSplit("load");

    timing.dumpToSysOut();
}
项目:NickleAndDimed    文件:AddEventTest.java   
@LargeTest
public void testEditEventCurrentEventNameDisplayed() {
    // Given
    Event event = new Event(randomUUID(), "testname", EUR, randomUUID());
    Intent intent = new Intent();
    intent.putExtra(ARGUMENT_EVENT_ID, event.getId());
    setActivityIntent(intent);
    when(eventStore.getById(event.getId())).thenReturn(event);

    // When
    getActivity();

    // Then
    onView(withId(R.id.event_name)).check(matches(withText(event.getName())));

}
项目:NickleAndDimed    文件:AddEventTest.java   
@LargeTest
public void testEditParticipantsIsNotStartedIfNextButtonIsPressed() {
    // Given
    Event event = new Event(randomUUID(), "testname", EUR, randomUUID());
    Intent intent = new Intent();
    intent.putExtra(ARGUMENT_EVENT_ID, event.getId());
    setActivityIntent(intent);
    when(eventStore.getById(event.getId())).thenReturn(event);

    // When
    getActivity();
    onView(withText(R.string.next)).perform(click());

    // Then
    verify(eventStore, times(1)).persist(eq(event));
    verify(activityStarter, times(0)).startAddParticipants(any(Context.class), eq(event));
}
项目:NickleAndDimed    文件:AddParticipantsTest.java   
@LargeTest
public void testWhenNoUsernameIseEnteredAllNonParticipatingUsersAreShown() {
    // Given
    User user = new User(randomUUID(), "Joe");
    List<User> users = asList(user);
    when(userStore.getAll()).thenReturn(users);
    when(participantManager.filterOutParticipants(users)).thenReturn(users);

    // When
    getActivity();

    // Then
    onData(Matchers.<Object>equalTo(user)).inAdapterView(withId(R.id.user_grid)).check(matches(isDisplayed()));
    verify(userStore, times(1)).getAll();
    verify(participantManager, times(1)).filterOutParticipants(users);
}
项目:NickleAndDimed    文件:LoginTest.java   
@LargeTest
public void testUserIsLoggedInWhenPressingStart() throws InterruptedException {
    // Given
    String userName = "Joe";
    getActivity();
    onView(withId(R.id.user_name)).perform(typeText(userName));
    closeSoftKeyboard();
    //HACK: Await keyboard closed, since this animation can not be disabled on the phone
    Thread.sleep(100);

    // When
    onView(withId(R.id.action_login_start)).perform(click());

    // Then
    verify(loginService, times(1)).login(argThat(matchesUser(userName)));
}
项目:NickleAndDimed    文件:LoginTest.java   
@LargeTest
public void testStartEventIsStartedWhenPressingStart() throws InterruptedException {
    // Given
    String userName = "Joe";
    getActivity();
    onView(withId(R.id.user_name)).perform(typeText(userName));
    closeSoftKeyboard();
    //HACK: Await keyboard closed, since this animation can not be disabled on the phone
    Thread.sleep(100);

    // When
    onView(withId(R.id.action_login_start)).perform(click());

    // Then
    verify(activityStarter, times(1)).startStartEvent(any(Login.class));
}
项目:World-Weather    文件:GeneralDatabaseServiceTest.java   
@LargeTest
public void testHandleIntent() throws InterruptedException {
    Intent insertNewCityIntent = getInsertNewCityIntent();
    startService(insertNewCityIntent);

    Intent renameCityIntent = getRenameCityIntent();
    startService(renameCityIntent);

    Intent deleteCityIntent = getDeleteCityIntent();
    startService(deleteCityIntent);

    boolean wereIntentsHandledInTime = countDownLatch.await(
            SECONDS_TO_HANDLE_ALL_TESTED_INTENTS, TimeUnit.SECONDS);

    assertTrue("Failed to handle all " + HANDLED_INTENT_COUNT
            + " intents in a reasonable time", wereIntentsHandledInTime);
}
项目:TimberdoodleApp    文件:CipherStressTests.java   
/**
 * Test if public message cipher can handle high amounts of tasks and still work properly
 *
 * @throws Exception
 */
@LargeTest
public void testPublicMessageCipher() throws Exception {
    ComparisonFailure ex = null;
    //initialise and get data and units under test
    List<SecretKey> keyList = CipherSuiteTestsUtility.getSpecificKeysFromGroupKeyList(this.keyList, true);
    List<byte[]> nonceList = CipherSuiteTestsUtility.generateNonceList(stressTestAmount, CipherSuiteTestsUtility.ivLengthCipher);
    byte[] result = new byte[CipherSuiteTestsUtility.PLAINSIZE];
    byte[] buffer = new byte[CipherSuiteTestsUtility.PLAINSIZE];
    IPublicMessageCipher decryption = CipherSuiteTestsUtility.setUpPublicMessageCipher(Cipher.DECRYPT_MODE);
    IPublicMessageCipher encryption= CipherSuiteTestsUtility.setUpPublicMessageCipher(Cipher.ENCRYPT_MODE);
    //start the test
    for (int i = 0; i < keyList.size(); ++i) {
        assert encryption != null;
        encryption.doFinalOptimized(nonceList.get(i), keyList.get(i), CipherTestVectors.getByteInput(), 0, buffer, 0);
        assert decryption != null;
        decryption.doFinalOptimized(nonceList.get(i), keyList.get(i), buffer, 0, result, 0);
        try {
            Assert.assertEquals(CipherSuiteTestsUtility.PLAINSIZE, result.length);
            Assert.assertEquals(CipherTestVectors.testInput, new String(result));
        } catch (ComparisonFailure e) {
            ex = e;
        }
    }
    if (ex != null) throw ex;
}
项目:android-test-kit    文件:UiControllerImplIntegrationTest.java   
@LargeTest
public void testInjectKeyEvent() throws InterruptedException {
  sendActivity = getActivity();
  getInstrumentation().waitForIdleSync();

  getInstrumentation().runOnMainSync(new Runnable() {
    @Override
    public void run() {
      try {
        KeyCharacterMap keyCharacterMap = UiControllerImpl.getKeyCharacterMap();
        KeyEvent[] events = keyCharacterMap.getEvents("a".toCharArray());
        injectEventWorked.set(uiController.injectKeyEvent(events[0]));
        latch.countDown();
      } catch (InjectEventSecurityException e) {
        injectEventThrewSecurityException.set(true);
      }
    }
  });

  assertFalse("injectEvent threw a SecurityException", injectEventThrewSecurityException.get());
  assertTrue("Timed out!", latch.await(10, TimeUnit.SECONDS));
  assertTrue(injectEventWorked.get());
}
项目:LostAndFound    文件:AuthorizationClientTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testWebViewChecksInternetPermission() {
    MockAuthorizationClient client = new MockAuthorizationClient() {
        @Override
        int checkPermission(String permission) {
            return PackageManager.PERMISSION_DENIED;
        }
    };
    AuthorizationClient.WebViewAuthHandler handler = client.new WebViewAuthHandler();

    AuthorizationClient.AuthorizationRequest request = createRequest();
    client.setRequest(request);
    handler.onWebDialogComplete(request, null, new FacebookException(ERROR_MESSAGE));

    assertNotNull(client.result);
    assertEquals(AuthorizationClient.Result.Code.ERROR, client.result.code);
    assertNull(client.result.token);
    assertNotNull(client.result.errorMessage);
}
项目:android-test-kit    文件:EventInjectorTest.java   
@LargeTest
public void testInjectKeyEventUpWithNoDown() throws Exception {
  sendActivity = getActivity();

  getInstrumentation().runOnMainSync(new Runnable() {
    @Override
    public void run() {
      View view = sendActivity.findViewById(R.id.send_data_edit_text);
      assertTrue(view.requestFocus());
      latch.countDown();
    }
  });

  assertTrue("Timed out!", latch.await(10, TimeUnit.SECONDS));
  KeyCharacterMap keyCharacterMap = UiControllerImpl.getKeyCharacterMap();
  KeyEvent[] events = keyCharacterMap.getEvents("a".toCharArray());
  assertTrue(injector.injectKeyEvent(events[1]));
}
项目:LostAndFound    文件:AuthorizationClientTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testLoginDialogHandlesDisabled() {
    Bundle bundle = new Bundle();
    bundle.putInt(NativeProtocol.EXTRA_PROTOCOL_VERSION, NativeProtocol.PROTOCOL_VERSION_20121101);
    bundle.putString(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_SERVICE_DISABLED);

    Intent intent = new Intent();
    intent.putExtras(bundle);

    MockAuthorizationClient client = new MockAuthorizationClient();
    AuthorizationClient.KatanaLoginDialogAuthHandler handler = client.new KatanaLoginDialogAuthHandler();

    AuthorizationClient.AuthorizationRequest request = createRequest();
    client.setRequest(request);
    handler.onActivityResult(0, Activity.RESULT_OK, intent);

    assertNull(client.result);
    assertTrue(client.triedNextHandler);
}
项目:FacebookImageShareIntent    文件:RequestTests.java   
@MediumTest
@LargeTest
public void testExecutePlaceRequestWithSearchText() {
    TestSession session = openTestSessionWithSharedUser();

    // Pass a distance without a location to ensure it is correctly ignored.
    Request request = Request.newPlacesSearchRequest(session, null, 1000, 5, "Starbucks", null);
    Response response = request.executeAndWait();
    assertNotNull(response);

    assertNull(response.getError());

    GraphMultiResult graphResult = response.getGraphObjectAs(GraphMultiResult.class);
    assertNotNull(graphResult);

    List<GraphObject> results = graphResult.getData();
    assertNotNull(results);

    assertNotNull(response.getRawResponse());
}
项目:FacebookImageShareIntent    文件:AsyncRequestTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testExecuteBatchWithNullRequestThrows() throws Exception {
    try {
        TestRequestAsyncTask task = new TestRequestAsyncTask(new Request[] { null });

        task.executeOnBlockerThread();

        waitAndAssertSuccessOrRethrow(1);

        fail("expected NullPointerException");
    } catch (NullPointerException exception) {
    }

}
项目:LostAndFound    文件:AuthorizationClientTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testWebViewHandlesSuccess() {
    Bundle bundle = new Bundle();
    bundle.putString("access_token", ACCESS_TOKEN);
    bundle.putString("expires_in", String.format("%d", EXPIRES_IN_DELTA));
    bundle.putString("code", "Something else");

    MockAuthorizationClient client = new MockAuthorizationClient();
    AuthorizationClient.WebViewAuthHandler handler = client.new WebViewAuthHandler();

    AuthorizationClient.AuthorizationRequest request = createRequest();
    client.setRequest(request);
    handler.onWebDialogComplete(request, bundle, null);

    assertNotNull(client.result);
    assertEquals(AuthorizationClient.Result.Code.SUCCESS, client.result.code);

    AccessToken token = client.result.token;
    assertNotNull(token);
    assertEquals(ACCESS_TOKEN, token.getToken());
    assertDateDiffersWithinDelta(new Date(), token.getExpires(), EXPIRES_IN_DELTA * 1000, 1000);
    assertEquals(PERMISSIONS, token.getPermissions());
}
项目:FacebookImageShareIntent    文件:AsyncRequestTests.java   
@MediumTest
@LargeTest
public void testExecuteSingleGet() {
    final TestSession session = openTestSessionWithSharedUser();
    Request request = new Request(session, "TourEiffel", null, null, new ExpectSuccessCallback() {
        @Override
        protected void performAsserts(Response response) {
            assertNotNull(response);
            GraphPlace graphPlace = response.getGraphObjectAs(GraphPlace.class);
            assertEquals("Paris", graphPlace.getLocation().getCity());
        }
    });

    TestRequestAsyncTask task = new TestRequestAsyncTask(request);

    task.executeOnBlockerThread();

    // Wait on 2 signals: request and task will both signal.
    waitAndAssertSuccess(2);
}
项目:FacebookImageShareIntent    文件:FriendPickerFragmentTests.java   
@MediumTest
@LargeTest
public void testCanSetParametersViaLayout() throws Throwable {
    TestActivity activity = getActivity();
    assertNotNull(activity);

    runAndBlockOnUiThread(0, new Runnable() {
        @Override
        public void run() {
            getActivity().setContentToLayout(R.layout.friend_picker_test_layout_1, R.id.friend_picker_fragment);
        }
    });

    final FriendPickerFragment fragment = activity.getFragment();
    assertNotNull(fragment);

    assertEquals(false, fragment.getShowPictures());
    assertEquals(false, fragment.getMultiSelect());
    Collection<String> extraFields = fragment.getExtraFields();
    assertTrue(extraFields.contains("middle_name"));
    assertTrue(extraFields.contains("link"));
    // It doesn't make sense to specify user id via layout, so we don't support it.
}
项目:UK-Weather-repo    文件:GeneralDatabaseServiceTest.java   
@LargeTest
public void testHandleIntent() throws InterruptedException {
    Intent insertNewCityIntent = getInsertNewCityIntent();
    startService(insertNewCityIntent);

    Intent renameCityIntent = getRenameCityIntent();
    startService(renameCityIntent);

    Intent deleteCityIntent = getDeleteCityIntent();
    startService(deleteCityIntent);

    boolean wereIntentsHandledInTime = countDownLatch.await(
            SECONDS_TO_HANDLE_ALL_TESTED_INTENTS, TimeUnit.SECONDS);

    assertTrue("Failed to handle all " + HANDLED_INTENT_COUNT
            + " intents in a reasonable time", wereIntentsHandledInTime);
}
项目:LostAndFound    文件:BatchRequestTests.java   
@LargeTest
public void testTwoDifferentAccessTokens() {
    TestSession session1 = openTestSessionWithSharedUser();
    TestSession session2 = openTestSessionWithSharedUser(SECOND_TEST_USER_TAG);

    Request request1 = Request.newMeRequest(session1, null);
    Request request2 = Request.newMeRequest(session2, null);

    List<Response> responses = Request.executeBatchAndWait(request1, request2);
    assertNotNull(responses);
    assertEquals(2, responses.size());

    GraphUser user1 = responses.get(0).getGraphObjectAs(GraphUser.class);
    GraphUser user2 = responses.get(1).getGraphObjectAs(GraphUser.class);

    assertNotNull(user1);
    assertNotNull(user2);

    assertFalse(user1.getId().equals(user2.getId()));
    assertEquals(session1.getTestUserId(), user1.getId());
    assertEquals(session2.getTestUserId(), user2.getId());
}
项目:LostAndFound    文件:RequestTests.java   
@MediumTest
@LargeTest
public void testExecutePlaceRequestWithLocationAndSearchText() {
    TestSession session = openTestSessionWithSharedUser();

    Location location = new Location("");
    location.setLatitude(47.6204);
    location.setLongitude(-122.3491);

    Request request = Request.newPlacesSearchRequest(session, location, 1000, 5, "Starbucks", null);
    Response response = request.executeAndWait();
    assertNotNull(response);

    assertNull(response.getError());

    GraphMultiResult graphResult = response.getGraphObjectAs(GraphMultiResult.class);
    assertNotNull(graphResult);

    List<GraphObject> results = graphResult.getData();
    assertNotNull(results);
}
项目:LostAndFound    文件:AuthorizationClientTests.java   
@MediumTest
@LargeTest
public void testLegacyReauthDoesntValidate() throws Exception {
    TestBlocker blocker = getTestBlocker();

    MockValidatingAuthorizationClient client = new MockValidatingAuthorizationClient(blocker);
    AuthorizationClient.AuthorizationRequest request = createNewPermissionRequest(USER_1_ACCESS_TOKEN);
    request.setIsLegacy(true);
    client.setRequest(request);

    AccessToken token = AccessToken.createFromExistingAccessToken(USER_2_ACCESS_TOKEN, null, null, null, PERMISSIONS);
    AuthorizationClient.Result result = AuthorizationClient.Result.createTokenResult(request, token);

    client.completeAndValidate(result);

    AccessToken resultToken = client.result.token;
    assertNotNull(resultToken);
    assertEquals(USER_2_ACCESS_TOKEN, resultToken.getToken());
    assertEquals(PERMISSIONS, resultToken.getPermissions());
}
项目:LostAndFound    文件:AuthorizationClientTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testProxyAuthHandlesDisabled() {
    Bundle bundle = new Bundle();
    bundle.putString("error", "service_disabled");

    Intent intent = new Intent();
    intent.putExtras(bundle);

    MockAuthorizationClient client = new MockAuthorizationClient();
    AuthorizationClient.KatanaProxyAuthHandler handler = client.new KatanaProxyAuthHandler();

    AuthorizationClient.AuthorizationRequest request = createRequest();
    client.setRequest(request);
    handler.onActivityResult(0, Activity.RESULT_OK, intent);

    assertNull(client.result);
    assertTrue(client.triedNextHandler);
}
项目:LostAndFound    文件:AsyncRequestTests.java   
@MediumTest
@LargeTest
public void testExecuteSingleGetUsingHttpURLConnection() {
    Request request = new Request(null, "TourEiffel", null, null, new ExpectSuccessCallback() {
        @Override
        protected void performAsserts(Response response) {
            assertNotNull(response);
            GraphPlace graphPlace = response.getGraphObjectAs(GraphPlace.class);
            assertEquals("Paris", graphPlace.getLocation().getCity());
        }
    });
    HttpURLConnection connection = Request.toHttpConnection(request);

    TestRequestAsyncTask task = new TestRequestAsyncTask(connection, Arrays.asList(new Request[] { request }));

    task.executeOnBlockerThread();

    // Wait on 2 signals: request and task will both signal.
    waitAndAssertSuccess(2);
}
项目:FacebookImageShareIntent    文件:AuthorizationClientTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testWebViewChecksInternetPermission() {
    MockAuthorizationClient client = new MockAuthorizationClient() {
        @Override
        int checkPermission(String permission) {
            return PackageManager.PERMISSION_DENIED;
        }
    };
    AuthorizationClient.WebViewAuthHandler handler = client.new WebViewAuthHandler();

    AuthorizationClient.AuthorizationRequest request = createRequest();
    client.setRequest(request);
    handler.onWebDialogComplete(request, null, new FacebookException(ERROR_MESSAGE));

    assertNotNull(client.result);
    assertEquals(AuthorizationClient.Result.Code.ERROR, client.result.code);
    assertNull(client.result.token);
    assertNotNull(client.result.errorMessage);
}
项目:LostAndFound    文件:AsyncRequestTests.java   
@MediumTest
@LargeTest
@SuppressWarnings("deprecation")
public void testStaticExecuteMyFriendsAsync() {
    final TestSession session = openTestSessionWithSharedUser();

    class FriendsCallback extends ExpectSuccessCallback implements Request.GraphUserListCallback {
        @Override
        public void onCompleted(List<GraphUser> friends, Response response) {
            assertNotNull(friends);
            RequestTests.validateMyFriendsResponse(session, response);
            onCompleted(response);
        }
    }

    runOnBlockerThread(new Runnable() {
        @Override
        public void run() {
            Request.executeMyFriendsRequestAsync(session, new FriendsCallback());
        }
    }, false);
    waitAndAssertSuccess(1);
}
项目:LostAndFound    文件:GraphObjectFactoryTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testCollectionIterator() throws JSONException {
    JSONArray array = new JSONArray();
    array.put(5);
    array.put(-1);

    Collection<Integer> collection = GraphObject.Factory.createList(array, Integer.class);
    Iterator<Integer> iter = collection.iterator();
    assertTrue(iter.hasNext());
    assertTrue(iter.next() == 5);
    assertTrue(iter.hasNext());
    assertTrue(iter.next() == -1);
    assertFalse(iter.hasNext());

    for (Integer i : collection) {
        assertNotSame(0, i);
    }
}
项目:LostAndFound    文件:GraphObjectFactoryTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testMapKeySet() throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("hello", "world");
    jsonObject.put("hocus", "pocus");

    GraphObject graphObject = GraphObject.Factory.create(jsonObject);

    Set<String> keySet = graphObject.asMap().keySet();
    assertEquals(2, keySet.size());
    assertTrue(keySet.contains("hello"));
    assertTrue(keySet.contains("hocus"));
    assertFalse(keySet.contains("world"));
}
项目:LostAndFound    文件:AccessTokenTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testCreateFromExistingTokenDefaults() {
    final String token = "A token of my esteem";

    AccessToken accessToken = AccessToken.createFromExistingAccessToken(token, null, null, null, null);

    assertEquals(token, accessToken.getToken());
    assertEquals(new Date(Long.MAX_VALUE), accessToken.getExpires());
    assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_WEB, accessToken.getSource());
    assertEquals(0, accessToken.getPermissions().size());
    // Allow slight variation for test execution time
    long delta = accessToken.getLastRefresh().getTime() - new Date().getTime();
    assertTrue(delta < 1000);
}
项目:LostAndFound    文件:GraphObjectFactoryTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testCanCastBetweenGraphObjectTypes() {
    GraphObject graphObject = GraphObject.Factory.create();

    graphObject.setProperty("first_name", "Mickey");

    GraphUser graphUser = graphObject.cast(GraphUser.class);
    assertTrue(graphUser != null);
    // Should see the name we set earlier as a GraphObject.
    assertEquals("Mickey", graphUser.getFirstName());

    // Changes to GraphUser should be reflected in GraphObject version.
    graphUser.setLastName("Mouse");
    assertEquals("Mouse", graphObject.getProperty("last_name"));
}
项目:Android-Application-Using-CAF-Library    文件:MusicPlayerStability.java   
/**
 * Test case 1: This test case is for the power and general stability
 * measurment. We don't need to do the validation. This test case simply
 * play the mp3 for 30 seconds then stop.
 * The sdcard should have the target mp3 files.
 */
@LargeTest
public void testPlay30sMP3() throws Exception {
    // Launch the songs list. Pick the fisrt song and play
    try {
        Instrumentation inst = getInstrumentation();
        //Make sure the song list shown up
        Thread.sleep(2000);
        inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
        mTrackList = getActivity().getListView();
        int scrollCount = mTrackList.getMaxScrollAmount();
        //Make sure there is at least one song in the sdcard
        if (scrollCount != -1) {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
        } else {
            assertTrue("testPlayMP3", false);
        }
        Thread.sleep(PLAY_TIME);
    } catch (Exception e) {
        assertTrue("testPlayMP3", false);
    }
}
项目:LostAndFound    文件:SessionTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testOpenForReadFailure() {
    SessionStatusCallbackRecorder statusRecorder = new SessionStatusCallbackRecorder();
    MockTokenCachingStrategy cache = new MockTokenCachingStrategy(null, 0);
    ScriptedSession session = createScriptedSessionOnBlockerThread(cache);

    try {
        session.openForRead(new Session.OpenRequest(getActivity()).setCallback(statusRecorder).
                setPermissions(Arrays.asList(new String[]{"publish_something"})));
        fail("should not reach here without an exception");
    } catch (FacebookException e) {
        assertTrue(e.getMessage().contains("Cannot pass a publish or manage permission"));
    } finally {
        stall(STRAY_CALLBACK_WAIT_MILLISECONDS);
        statusRecorder.close();
    }
}
项目:FacebookImageShareIntent    文件:GraphObjectFactoryTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testMapKeySet() throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("hello", "world");
    jsonObject.put("hocus", "pocus");

    GraphObject graphObject = GraphObject.Factory.create(jsonObject);

    Set<String> keySet = graphObject.asMap().keySet();
    assertEquals(2, keySet.size());
    assertTrue(keySet.contains("hello"));
    assertTrue(keySet.contains("hocus"));
    assertFalse(keySet.contains("world"));
}
项目:LostAndFound    文件:GraphObjectFactoryTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testCanConvertFromGraphObject() throws JSONException {
    GraphObject graphObject = GraphObject.Factory.create();
    graphObject.setProperty("city", "Paris");
    graphObject.setProperty("country", "France");

    JSONObject jsonPlace = new JSONObject();
    jsonPlace.put("location", graphObject);
    jsonPlace.put("name", "Eiffel Tower");

    GraphPlace graphPlace = GraphObject.Factory.create(jsonPlace, GraphPlace.class);
    GraphLocation graphLocation = graphPlace.getLocation();
    assertEquals("Paris", graphLocation.getCity());
}
项目:FacebookImageShareIntent    文件:AccessTokenTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testFromSSOWithExpiresLong() {
    List<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play");
    String token = "AnImaginaryTokenValue";

    Intent intent = new Intent();
    intent.putExtra("access_token", token);
    intent.putExtra("expires_in", 60L);
    intent.putExtra("extra_extra", "Something unrelated");

    AccessToken accessToken = AccessToken
            .createFromWebBundle(permissions, intent.getExtras(), AccessTokenSource.FACEBOOK_APPLICATION_WEB);
    TestUtils.assertSamePermissions(permissions, accessToken);
    assertEquals(token, accessToken.getToken());
    assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_WEB, accessToken.getSource());
    assertTrue(!accessToken.isInvalid());
}
项目:FacebookImageShareIntent    文件:WorkQueueTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testRunSequence() {
    final int workTotal = 100;

    CountingRunnable run = new CountingRunnable();
    ScriptableExecutor executor = new ScriptableExecutor();
    WorkQueue manager = new WorkQueue(1, executor);

    for (int i = 0; i < workTotal; i++) {
        addActiveWorkItem(manager, run);
        assertEquals(1, executor.getPendingCount());
    }

    for (int i = 0; i < workTotal; i++) {
        assertEquals(1, executor.getPendingCount());
        assertEquals(i, run.getRunCount());
        executeNext(manager, executor);
    }
    assertEquals(0, executor.getPendingCount());
    assertEquals(workTotal, run.getRunCount());
}
项目:FacebookImageShareIntent    文件:WorkQueueTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testRunSomething() {
    CountingRunnable run = new CountingRunnable();
    assertEquals(0, run.getRunCount());

    ScriptableExecutor executor = new ScriptableExecutor();
    assertEquals(0, executor.getPendingCount());

    WorkQueue manager = new WorkQueue(1, executor);

    addActiveWorkItem(manager, run);
    assertEquals(1, executor.getPendingCount());
    assertEquals(0, run.getRunCount());

    executeNext(manager, executor);
    assertEquals(0, executor.getPendingCount());
    assertEquals(1, run.getRunCount());
}
项目:Icinga-Mobile    文件:LogInTest.java   
@LargeTest
@SuppressWarnings("unchecked")
public void testLogInAction_Success() {
    // Get test case dataset
    Map<String, String> test = testCase.get("SuccessCase");
    String sServer = test.get("Server");
    String sUser = test.get("User");
    String sPass = test.get("Pass");

    // Begin test
    new Login(null, new OnCompleteListener() {
        @Override
        public void onComplete(Object obj, String sender) {
            Map<String, Object> result = (Map<String, Object>) obj;
            int res = (Integer) result.get("Code");
            Assert.assertEquals("This should be an unknown host error", GlobalConst.SESSION_LOGGED_IN, res);
        }
    }).execute(sServer, sUser, sPass);
}
项目:LostAndFound    文件:GraphObjectFactoryTests.java   
@SmallTest
@MediumTest
@LargeTest
public void testCanCastCollectionOfGraphObjects() throws JSONException {
    JSONObject jsonSeattle = new JSONObject();
    jsonSeattle.put("city", "Seattle");

    JSONArray jsonArray = new JSONArray();
    jsonArray.put(jsonSeattle);

    GraphObjectList<GraphObject> collection = GraphObject.Factory
            .createList(jsonArray, GraphObject.class);

    GraphObjectList<GraphLocation> locationCollection = collection.castToListOf(GraphLocation.class);
    assertTrue(locationCollection != null);

    GraphLocation seattle = locationCollection.iterator().next();
    assertTrue(seattle != null);
    assertEquals("Seattle", seattle.getCity());
}
项目:chromium-net-for-android    文件:ChromiumUrlRequestTest.java   
@LargeTest
@Feature({"Cronet"})
public void testNoWriteAfterCancelOnAnotherThread() throws Exception {
    // This test verifies that WritableByteChannel.write is not called after
    // WritableByteChannel.close if request is canceled from another
    // thread.
    for (int i = 0; i < 100; ++i) {
        HashMap<String, String> headers = new HashMap<String, String>();
        TestByteChannel channel = new TestByteChannel();
        TestHttpUrlRequestListener listener =
                new TestHttpUrlRequestListener();

        // Create request.
        final HttpUrlRequest request =
                mTestFramework.mRequestFactory.createRequest(NativeTestServer.getSuccessURL(),
                        HttpUrlRequest.REQUEST_PRIORITY_LOW, headers, channel, listener);
        request.start();
        listener.blockForStart();
        Runnable cancelTask = new Runnable() {
            public void run() {
                request.cancel();
            }
        };
        Executors.newCachedThreadPool().execute(cancelTask);
        listener.blockForComplete();
        assertFalse(channel.isOpen());
        // Since getAllHeaders and other methods in
        // checkAfterAdapterDestroyed() acquire mLock, so this will happen
        // after the adapter is destroyed.
        checkAfterAdapterDestroyed(request);
    }
}
项目:Android_365    文件:PdfRendererBasicFragmentTests.java   
@LargeTest
public void testActivityTitle() {
    // The title of the activity should be "PdfRendererBasic (1/10)" at first
    String expectedActivityTitle = mActivity.getString(R.string.app_name_with_index, 1,
            mFragment.getPageCount());
    assertEquals(expectedActivityTitle, mActivity.getTitle());
}