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