Use external/robolectric-shadows/run_robotests.mk

This allows Settings to test against the latest framework changes.

Also replaced TestConfig with traditional robolectric.properties.

Bug: 73173204
Bug: 73892008
Test: make -j56 RunSettingsRoboTests
Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
This commit is contained in:
James Lemieux
2018-02-26 00:51:42 -08:00
parent 229a6a2bc4
commit 22a39c2b93
752 changed files with 5096 additions and 9182 deletions

View File

@@ -15,45 +15,36 @@
*/
package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class
})
public class SummaryPreferenceTest {
private Context mContext;
private PreferenceViewHolder mHolder;
private SummaryPreference mPreference;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mPreference = new SummaryPreference(mContext, null);
final Context context = RuntimeEnvironment.application;
mPreference = new SummaryPreference(context, null);
LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(mPreference.getLayoutResource(),
new LinearLayout(mContext), false);
LayoutInflater inflater = LayoutInflater.from(context);
final View view =
inflater.inflate(mPreference.getLayoutResource(), new LinearLayout(context), false);
mHolder = PreferenceViewHolder.createInstanceForTests(view);
}
@@ -63,10 +54,11 @@ public class SummaryPreferenceTest {
mPreference.setChartEnabled(false);
mPreference.onBindViewHolder(mHolder);
assertTrue(
TextUtils.isEmpty(((TextView) mHolder.findViewById(android.R.id.text1)).getText()));
assertTrue(
TextUtils.isEmpty(((TextView) mHolder.findViewById(android.R.id.text2)).getText()));
final TextView textView1 = (TextView) mHolder.findViewById(android.R.id.text1);
assertThat(textView1.getText()).isEqualTo("");
final TextView textView2 = (TextView) mHolder.findViewById(android.R.id.text2);
assertThat(textView2.getText()).isEqualTo("");
}
@Test
@@ -77,10 +69,10 @@ public class SummaryPreferenceTest {
mPreference.setLabels(testLabel1, testLabel2);
mPreference.onBindViewHolder(mHolder);
assertEquals(testLabel1,
((TextView) mHolder.findViewById(android.R.id.text1)).getText());
assertEquals(testLabel2,
((TextView) mHolder.findViewById(android.R.id.text2)).getText());
}
final TextView textView1 = (TextView) mHolder.findViewById(android.R.id.text1);
assertThat(textView1.getText()).isEqualTo(testLabel1);
final TextView textView2 = (TextView) mHolder.findViewById(android.R.id.text2);
assertThat(textView2.getText()).isEqualTo(testLabel2);
}
}