1 /*
2  * Copyright (C) 2019 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;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.app.Activity;
22 import android.view.LayoutInflater;
23 import android.widget.TextView;
24 
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.robolectric.Robolectric;
29 import org.robolectric.RobolectricTestRunner;
30 
31 @RunWith(RobolectricTestRunner.class)
32 public class MasterClearConfirmTest {
33     private Activity mActivity;
34 
35     @Before
setUp()36     public void setUp() {
37         mActivity = Robolectric.setupActivity(Activity.class);
38     }
39 
40     @Test
setSubtitle_eraseEsim()41     public void setSubtitle_eraseEsim() {
42         MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
43         masterClearConfirm.mEraseEsims = true;
44         masterClearConfirm.mContentView =
45                 LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
46 
47         masterClearConfirm.setSubtitle();
48 
49         assertThat(((TextView) masterClearConfirm.mContentView
50                 .findViewById(R.id.sud_layout_description)).getText())
51                 .isEqualTo(mActivity.getString(R.string.master_clear_final_desc_esim));
52     }
53 
54     @Test
setSubtitle_notEraseEsim()55     public void setSubtitle_notEraseEsim() {
56         MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
57         masterClearConfirm.mEraseEsims = false;
58         masterClearConfirm.mContentView =
59                 LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
60 
61         masterClearConfirm.setSubtitle();
62 
63         assertThat(((TextView) masterClearConfirm.mContentView
64                 .findViewById(R.id.sud_layout_description)).getText())
65                 .isEqualTo(mActivity.getString(R.string.master_clear_final_desc));
66     }
67 }
68