1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.widget; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import android.view.View; 22 import android.widget.LinearLayout; 23 import android.widget.Space; 24 25 import com.android.settings.R; 26 27 import org.junit.Before; 28 import org.junit.Test; 29 import org.junit.runner.RunWith; 30 import org.robolectric.RobolectricTestRunner; 31 import org.robolectric.RuntimeEnvironment; 32 33 @RunWith(RobolectricTestRunner.class) 34 public class BottomLabelLayoutTest { 35 36 private BottomLabelLayout mBottomLabelLayout; 37 private Space mSpace; 38 39 @Before setUp()40 public void setUp() { 41 mBottomLabelLayout = new BottomLabelLayout(RuntimeEnvironment.application, null); 42 mBottomLabelLayout.setOrientation(LinearLayout.HORIZONTAL); 43 44 mSpace = new Space(RuntimeEnvironment.application); 45 mSpace.setId(R.id.spacer); 46 mBottomLabelLayout.addView(mSpace); 47 } 48 49 @Test testSetStacked_stackedTrue_layoutVertical()50 public void testSetStacked_stackedTrue_layoutVertical() { 51 mBottomLabelLayout.setStacked(true); 52 53 assertThat(mBottomLabelLayout.getOrientation()).isEqualTo(LinearLayout.VERTICAL); 54 assertThat(mSpace.getVisibility()).isEqualTo(View.GONE); 55 } 56 57 @Test testSetStacked_stackedFalse_layoutHorizontal()58 public void testSetStacked_stackedFalse_layoutHorizontal() { 59 mBottomLabelLayout.setStacked(false); 60 61 assertThat(mBottomLabelLayout.getOrientation()).isEqualTo(LinearLayout.HORIZONTAL); 62 assertThat(mSpace.getVisibility()).isEqualTo(View.VISIBLE); 63 } 64 } 65