1 /* 2 * Copyright (C) 2024 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.applications; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import android.content.Context; 22 import android.view.View; 23 24 import androidx.preference.PreferenceViewHolder; 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 ProcessStatsPreferenceTest { 36 37 private Context mContext; 38 private View mRootView; 39 private ProcessStatsPreference mPref; 40 private PreferenceViewHolder mHolder; 41 42 @Before setUp()43 public void setUp() { 44 mContext = RuntimeEnvironment.application; 45 mRootView = View.inflate(mContext, R.layout.preference_process_stats, null /* parent */); 46 mHolder = PreferenceViewHolder.createInstanceForTests(mRootView); 47 mPref = new ProcessStatsPreference(mContext); 48 } 49 50 @Test setProgress_showProgress()51 public void setProgress_showProgress() { 52 mPref.setProgress(1); 53 mPref.onBindViewHolder(mHolder); 54 55 assertThat(mHolder.findViewById(android.R.id.progress).getVisibility()) 56 .isEqualTo(View.VISIBLE); 57 } 58 59 @Test foobar_testName()60 public void foobar_testName() { 61 float iconSize = mContext.getResources().getDimension( 62 com.android.settingslib.widget.theme.R.dimen.secondary_app_icon_size); 63 assertThat(Float.floatToIntBits(iconSize)).isEqualTo(Float.floatToIntBits(32)); 64 } 65 } 66