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.settingslib.graph; 19 20 import static com.google.common.truth.Truth.assertThat; 21 22 import android.content.Context; 23 import android.view.View; 24 import android.widget.LinearLayout; 25 import android.widget.Space; 26 27 import com.android.settingslib.R; 28 import com.android.settingslib.TestConfig; 29 30 import org.junit.Before; 31 import org.junit.Test; 32 import org.junit.runner.RunWith; 33 import org.robolectric.RobolectricTestRunner; 34 import org.robolectric.RuntimeEnvironment; 35 import org.robolectric.annotation.Config; 36 37 @RunWith(RobolectricTestRunner.class) 38 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) 39 public class BottomLabelLayoutTest { 40 private BottomLabelLayout mBottomLabelLayout; 41 private Context mContext; 42 private Space mSpace; 43 44 @Before 45 public void setUp() { 46 mContext = RuntimeEnvironment.application; 47 mBottomLabelLayout = new BottomLabelLayout(mContext, null); 48 mBottomLabelLayout.setOrientation(LinearLayout.HORIZONTAL); 49 50 mSpace = new Space(mContext); 51 mSpace.setId(R.id.spacer); 52 mBottomLabelLayout.addView(mSpace); 53 } 54 55 @Test 56 public void testSetStacked_stackedTrue_layoutVertical() { 57 mBottomLabelLayout.setStacked(true); 58 59 assertThat(mBottomLabelLayout.getOrientation()).isEqualTo(LinearLayout.VERTICAL); 60 assertThat(mSpace.getVisibility()).isEqualTo(View.GONE); 61 } 62 63 @Test 64 public void testSetStacked_stackedFalse_layoutHorizontal() { 65 mBottomLabelLayout.setStacked(false); 66 67 assertThat(mBottomLabelLayout.getOrientation()).isEqualTo(LinearLayout.HORIZONTAL); 68 assertThat(mSpace.getVisibility()).isEqualTo(View.VISIBLE); 69 } 70 } 71