當前位置: 首頁>>代碼示例>>Java>>正文


Java ShadowActivity.peekNextStartedActivityForResult方法代碼示例

本文整理匯總了Java中org.robolectric.shadows.ShadowActivity.peekNextStartedActivityForResult方法的典型用法代碼示例。如果您正苦於以下問題:Java ShadowActivity.peekNextStartedActivityForResult方法的具體用法?Java ShadowActivity.peekNextStartedActivityForResult怎麽用?Java ShadowActivity.peekNextStartedActivityForResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.robolectric.shadows.ShadowActivity的用法示例。


在下文中一共展示了ShadowActivity.peekNextStartedActivityForResult方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onViewClickTest

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void onViewClickTest() {
    onPostViewClickListener.onViewClick(viewMock, post);

    final ShadowActivity shadowActivity = Shadows.shadowOf(postsActivity);
    final Intent intent = shadowActivity.peekNextStartedActivityForResult().intent;
    assertThat(intent.getComponent()).isEqualTo(new ComponentName(postsActivity, PostActivity.class));
    assertThat(intent.getExtras().getInt(Post.USER_ID)).isEqualTo(getExtras(post).getInt(Post.USER_ID));
    assertThat(intent.getExtras().getInt(Post.ID)).isEqualTo(getExtras(post).getInt(Post.ID));
    assertThat(intent.getExtras().getInt(Post.TITLE)).isEqualTo(getExtras(post).getInt(Post.TITLE));
    assertThat(intent.getExtras().getInt(Post.BODY)).isEqualTo(getExtras(post).getInt(Post.BODY));
}
 
開發者ID:ParaskP7,項目名稱:sample-code-posts,代碼行數:13,代碼來源:OnPostViewClickListenerTest.java

示例2: onPaymentMethodSelected_startsAddCardActivity

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void onPaymentMethodSelected_startsAddCardActivity() {
    ShadowActivity shadowActivity = shadowOf(mActivity);

    mActivity.onPaymentMethodSelected(PaymentMethodType.UNKNOWN);

    IntentForResult intent = shadowActivity.peekNextStartedActivityForResult();
    assertEquals(AddCardActivity.class.getName(), intent.intent.getComponent().getClassName());
}
 
開發者ID:braintree,項目名稱:braintree-android-drop-in,代碼行數:10,代碼來源:DropInActivityPowerMockTest.java

示例3: runMainActivity

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
/**
     * Test the activity lifecycle in unit tests.
     * Simulates the opening of the app the very first time, initialization of preferences,
     * database, etc. Displays the Tutorial and the Welcome screen in the Home fragment.
     * Then opens the Add New Account activity.
     * See http://robolectric.org/activity-lifecycle/
     */
    //@Test
    public void runMainActivity() {
        Fragment homeFragment;
        Intent expectedIntent;

        homeFragment = UnitTestHelper.getFragment(activity, HomeFragment.class.getSimpleName());
        assertThat(homeFragment, notNullValue());

        // Confirm Tutorial is shown.
        ShadowActivity shadowActivity = shadowOf(activity);
        expectedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
//        assertThat(expectedIntent.getComponent()).isEqualTo(new ComponentName(activity, TutorialActivity.class));
//        assertThat(shadowActivity.getNextStartedActivity()).isEqualTo(expectedIntent);

        TutorialActivity tutorialActivity = Robolectric
                .buildActivity(TutorialActivity.class, expectedIntent)
                .create().get();
        assertThat(tutorialActivity, notNullValue());

        // Close tutorial
        View view = tutorialActivity.findViewById(R.id.skipTextView);
        assertThat(view, notNullValue()); // "Tutorial close not found"
        view.performClick();

        // Home Fragment is set-up.
//        testHomeFragment(homeFragment);

        // Click Add New Account button.
        view = homeFragment.getView().findViewById(R.id.buttonAddAccount);
        assertThat(view, notNullValue()); // "Add Account button not found"
        view.performClick();

        // Add Account opens up.
        expectedIntent = new Intent(activity, AccountEditActivity.class);
        expectedIntent.setAction(Intent.ACTION_INSERT);
        assertThat(shadowOf(activity).getNextStartedActivity(), equalTo(expectedIntent));
    }
 
開發者ID:moneymanagerex,項目名稱:android-money-manager-ex,代碼行數:45,代碼來源:MainActivityTests.java

示例4: searchForSubCategoryWorksWithData

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
/**
     * Add two transaction for Dining Out. Search for this sub/category and confirm that the
     * results are shown and the total & currency match.
     */
    //@Test
    public void searchForSubCategoryWorksWithData() {
        // arrange

        UnitTestHelper.setDefaultCurrency("BAM");
        DataHelpers.insertData();
        // add expected transaction
        DataHelpers.createTransaction(1, -1, TransactionTypes.Withdrawal, 2, 9, MoneyFactory.fromString("-14.68"));
        // add one more for testing the total calculation
        DataHelpers.createTransaction(1, -1, TransactionTypes.Withdrawal, 2, 9, MoneyFactory.fromString("-25.37"));

        //*******************************************
        // act

        // Click Select Category
        TextView selectCategory = (TextView) activity.findViewById(R.id.textViewSelectCategory);
//        assertThat(selectCategory).isNotNull();
        selectCategory.performClick();

        // confirm that clicking the Select Category text view opens category selector
        ShadowActivity shadowActivity = Shadows.shadowOf(this.activity);
        Intent expectedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
//        assertThat(expectedIntent.getComponent()).isEqualTo(new ComponentName(this.activity,
//                CategoryListActivity.class));
//        assertThat(shadowActivity.getNextStartedActivity()).isEqualTo(expectedIntent);

        // Now simulate that we received the category.

        Fragment searchFragment = UnitTestHelper.getFragment(activity, SearchParametersFragment.class.getSimpleName());
//        assertThat(searchFragment).isNotNull();

        // We "selected" Food:Dining out.
        Intent categoryData = UnitTestHelper.getSelectCategoryResult(2, "Food", 9, "Dining out");
        searchFragment.onActivityResult(RequestCodes.CATEGORY, Activity.RESULT_OK,
                categoryData);
//        assertThat(selectCategory.getText()).containsSequence("Food : Dining out");

        // Run search

        LinearLayout searchButton = (LinearLayout) activity.findViewById(R.id.action_search);
//        assertThat(searchButton).isNotNull();
        searchButton.performClick();

        //**************************************
        // assert

        // confirm the Total is shown and the sum is 0.

        Fragment resultsFragment = UnitTestHelper.getFragment(activity, AllDataListFragment.class.getSimpleName());
//        assertThat(resultsFragment).isNotNull();

        View totalView = resultsFragment.getView().findViewById(R.id.textViewColumn1);
//        assertThat(totalView).isNotNull();
//        assertThat(totalView).isInstanceOf(TextView.class);
        TextView totalTextView = (TextView) totalView;
//        assertThat(totalTextView.getText()).isEqualTo("Total");

        // total amount
        View totalNumberView = resultsFragment.getView().findViewById(R.id.textViewColumn2);
//        assertThat(totalNumberView).isNotNull();
//        assertThat(totalNumberView).isInstanceOf(TextView.class);
        TextView totalNumberTextView = (TextView) totalNumberView;
//        assertThat(totalNumberTextView.getText()).isEqualTo("KM 40.05");
    }
 
開發者ID:moneymanagerex,項目名稱:android-money-manager-ex,代碼行數:69,代碼來源:SearchActivityTests.java

示例5: searchForSubCategoryWorksWithNoData

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
public void searchForSubCategoryWorksWithNoData() {
        //*******************************************
        // arrange

        UnitTestHelper.setDefaultCurrency("BAM");
        DataHelpers.insertData();

        //*******************************************
        // act

        // Click Select Category
        TextView selectCategory = (TextView) activity.findViewById(R.id.textViewSelectCategory);
        selectCategory.performClick();

        // confirm that clicking the Select Category text view opens category selector
        ShadowActivity shadowActivity = Shadows.shadowOf(this.activity);
        Intent expectedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
//        assertThat(expectedIntent.getComponent()).isEqualTo(new ComponentName(this.activity,
//            CategoryListActivity.class));
        assertThat(shadowActivity.getNextStartedActivity(), equalTo(expectedIntent));

        // Now simulate that we received the category.

        Fragment searchFragment = UnitTestHelper.getFragment(activity, SearchParametersFragment.class.getSimpleName());

        // We "selected" Food:Dining out.
        Intent categoryData = UnitTestHelper.getSelectCategoryResult(2, "Food", 9, "Dining out");
        searchFragment.onActivityResult(RequestCodes.CATEGORY, Activity.RESULT_OK,
            categoryData);
//        assertThat(selectCategory.getText()).containsSequence("Food : Dining out");

        // Run search

        LinearLayout searchButton = (LinearLayout) activity.findViewById(R.id.action_search);
        searchButton.performClick();

        //**************************************
        // assert

        // confirm the Total is shown and the sum is 0.

        Fragment resultsFragment = UnitTestHelper.getFragment(activity, AllDataListFragment.class.getSimpleName());

        View totalView = resultsFragment.getView().findViewById(R.id.textViewColumn1);
//        assertThat(totalView).isInstanceOf(TextView.class);
        TextView totalTextView = (TextView) totalView;
//        assertThat(totalTextView.getText()).isEqualTo("Total");

        // total amount
        View totalNumberView = resultsFragment.getView().findViewById(R.id.textViewColumn2);
//        assertThat(totalNumberView).isInstanceOf(TextView.class);
        TextView totalNumberTextView = (TextView) totalNumberView;
        assertThat(totalNumberTextView.getText().toString(), equalTo("KM 0.00"));
    }
 
開發者ID:moneymanagerex,項目名稱:android-money-manager-ex,代碼行數:55,代碼來源:SearchActivityTests.java


注:本文中的org.robolectric.shadows.ShadowActivity.peekNextStartedActivityForResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。