car/src/androidTest/java/androidx/car/widget/ActionBarTest.java
@Test
    public void testExpandCollapseEnabled() {
        setUpActionBarItems(NUM_COLS + 1);

        // Top row should have 2 slot taken (as expand/collapse takes one slot on the bottom row)
        onView(withContentDescription(R.string.action_bar_expand_collapse_button))
                .check((view, noViewFoundException) -> {
                    Preconditions.checkNotNull(view);
                    assertLeftItemsNotEmpty(TOP_ROW_IDX, 2);
                    assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, NUM_COLS);
                    assertRowVisibility(TOP_ROW_IDX, View.GONE);
                })
                // Check that expand/collapse works
                .perform(click())
                .check((view, noViewFoundException) -> {
                    assertRowVisibility(TOP_ROW_IDX, View.VISIBLE);
                })
                .perform(click())
                .check((view, noViewFoundException) -> {
                    assertRowVisibility(TOP_ROW_IDX, View.GONE);
                });
    }
/**
     * Tests that the expand/collapse button is added if enough views are set
     */
Tests that the expand/collapse button is added if enough views are set
Tests that the expand / collapse button is added if enough views are set
@Test
    public void testExpandCollapseEnabled() {
        setUpActionBarItems(NUM_COLS + 1);
        onView(withContentDescription(R.string.action_bar_expand_collapse_button))
                .check((view, noViewFoundException) -> {
                    Preconditions.checkNotNull(view);
                    assertLeftItemsNotEmpty(TOP_ROW_IDX, 2);
                    assertLeftItemsNotEmpty(BOTTOM_ROW_IDX, NUM_COLS);
                    assertRowVisibility(TOP_ROW_IDX, View.GONE);
                })
                .perform(click())
                .check((view, noViewFoundException) -> {
                    assertRowVisibility(TOP_ROW_IDX, View.VISIBLE);
                })
                .perform(click())
                .check((view, noViewFoundException) -> {
                    assertRowVisibility(TOP_ROW_IDX, View.GONE);
                });
    }
@ Test public void testExpandCollapseEnabled ( ) { setUpActionBarItems ( NUM_COLS + 1 ) ; onView ( withContentDescription ( R . string . action_bar_expand_collapse_button ) ) . check ( ( view , noViewFoundException ) -> { Preconditions . checkNotNull ( view ) ; assertLeftItemsNotEmpty ( TOP_ROW_IDX , 2 ) ; assertLeftItemsNotEmpty ( BOTTOM_ROW_IDX , NUM_COLS ) ; assertRowVisibility ( TOP_ROW_IDX , View . GONE ) ; } ) . perform ( click ( ) ) . check ( ( view , noViewFoundException ) -> { assertRowVisibility ( TOP_ROW_IDX , View . VISIBLE ) ; } ) . perform ( click ( ) ) . check ( ( view , noViewFoundException ) -> { assertRowVisibility ( TOP_ROW_IDX , View . GONE ) ; } ) ; }
Tests that the expand/collapse button is added if enough views are set
Tests that the expand / collapse button is added if enough views are set
// Top row should have 2 slot taken (as expand/collapse takes one slot on the bottom row) // Check that expand/collapse works