car/src/androidTest/java/androidx/car/widget/ActionBarTest.java
@Test
    public void testReservingNamedSlots() {
        View mainView = createButton(mActivity);
        setViewInPosition(mainView, ActionBar.SLOT_MAIN);
        View leftView = new Space(mActivity);
        setViewInPosition(leftView, ActionBar.SLOT_LEFT);
        setUpActionBarItems(NUM_COLS + 1);

        // Expand/collapse plus two other slots should be taken in the bottom row.
        onView(withContentDescription(R.string.action_bar_expand_collapse_button))
                .check((view, noViewFoundException) -> {
                    // Only 2 items fit in the bottom row. The remaining 4 should be on the top
                    Preconditions.checkNotNull(view);
                    assertLeftItemsNotEmpty(TOP_ROW_IDX, 4);
                    assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, NUM_COLS);
                    assertRowVisibility(TOP_ROW_IDX, View.GONE);
                    assertEquals(mainView, mActionBar.getViewAt(BOTTOM_ROW_IDX, 2));
                    assertEquals(leftView, mActionBar.getViewAt(BOTTOM_ROW_IDX, 1));
                })
                .perform(click())
                .check((view, noViewFoundException) -> {
                    assertRowVisibility(TOP_ROW_IDX, View.VISIBLE);
                });
    }
/**
     * Tests that reserved slots are not used by normal views.
     */
Tests that reserved slots are not used by normal views.
Tests that reserved slots are not used by normal views .
@Test
    public void testReservingNamedSlots() {
        View mainView = createButton(mActivity);
        setViewInPosition(mainView, ActionBar.SLOT_MAIN);
        View leftView = new Space(mActivity);
        setViewInPosition(leftView, ActionBar.SLOT_LEFT);
        setUpActionBarItems(NUM_COLS + 1);
        onView(withContentDescription(R.string.action_bar_expand_collapse_button))
                .check((view, noViewFoundException) -> {
                    Preconditions.checkNotNull(view);
                    assertLeftItemsNotEmpty(TOP_ROW_IDX, 4);
                    assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, NUM_COLS);
                    assertRowVisibility(TOP_ROW_IDX, View.GONE);
                    assertEquals(mainView, mActionBar.getViewAt(BOTTOM_ROW_IDX, 2));
                    assertEquals(leftView, mActionBar.getViewAt(BOTTOM_ROW_IDX, 1));
                })
                .perform(click())
                .check((view, noViewFoundException) -> {
                    assertRowVisibility(TOP_ROW_IDX, View.VISIBLE);
                });
    }
@ Test public void testReservingNamedSlots ( ) { View mainView = createButton ( mActivity ) ; setViewInPosition ( mainView , ActionBar . SLOT_MAIN ) ; View leftView = new Space ( mActivity ) ; setViewInPosition ( leftView , ActionBar . SLOT_LEFT ) ; setUpActionBarItems ( NUM_COLS + 1 ) ; onView ( withContentDescription ( R . string . action_bar_expand_collapse_button ) ) . check ( ( view , noViewFoundException ) -> { Preconditions . checkNotNull ( view ) ; assertLeftItemsNotEmpty ( TOP_ROW_IDX , 4 ) ; assertLeftItemsNotEmpty ( BOTTOM_ROW_IDX , NUM_COLS ) ; assertRowVisibility ( TOP_ROW_IDX , View . GONE ) ; assertEquals ( mainView , mActionBar . getViewAt ( BOTTOM_ROW_IDX , 2 ) ) ; assertEquals ( leftView , mActionBar . getViewAt ( BOTTOM_ROW_IDX , 1 ) ) ; } ) . perform ( click ( ) ) . check ( ( view , noViewFoundException ) -> { assertRowVisibility ( TOP_ROW_IDX , View . VISIBLE ) ; } ) ; }
Tests that reserved slots are not used by normal views.
Tests that reserved slots are not used by normal views .
// Expand/collapse plus two other slots should be taken in the bottom row. // Only 2 items fit in the bottom row. The remaining 4 should be on the top