Use preference for about phone page instead of injection.

It's faster than tile injection. The fragment comes from Settings
itself, we don't have to use to injection.

Bug: 118168552
Test: robotest
Change-Id: If6a79dd73f8a51dbb21338a40f22dc8b8f8c8cb8
This commit is contained in:
Fan Zhang
2018-11-08 14:11:13 -08:00
parent 08d8ed80b6
commit ac9d87695d
8 changed files with 123 additions and 38 deletions

View File

@@ -1,4 +1,20 @@
package com.android.settings.deviceinfo.deviceinfo;
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.deviceinfo.aboutphone;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -6,8 +22,6 @@ import static org.mockito.Mockito.verify;
import android.content.DialogInterface;
import com.android.settings.deviceinfo.aboutphone.DeviceNameWarningDialog;
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Test;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.settings.deviceinfo;
package com.android.settings.deviceinfo.aboutphone;
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
@@ -35,7 +35,7 @@ import android.util.ArrayMap;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceScreen;
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.deviceinfo.aboutphone;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.os.Build;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
public class TopLevelAboutDevicePreferenceControllerTest {
private Context mContext;
private TopLevelAboutDevicePreferenceController mController;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mController = new TopLevelAboutDevicePreferenceController(mContext, "test_key");
}
@Test
public void getAvailabilityState_shouldBeAvailable() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void getSummary_shouldReturnDeviceModel() {
assertThat(mController.getSummary().toString()).isEqualTo(Build.MODEL);
}
}