Merge "Fix testSuwGlifButtonTertiary"
This commit is contained in:
commit
4225936aba
27
library/gingerbread/res/values-v21/styles.xml
Normal file
27
library/gingerbread/res/values-v21/styles.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 Google Inc.
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- Button styles -->
|
||||
|
||||
<style name="SuwGlifButton.Tertiary" parent="SuwGlifButton.BaseTertiary">
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
<item name="textAllCaps" tools:targetApi="ice_cream_sandwich">false</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -266,6 +266,13 @@
|
|||
<item name="colorControlHighlight">@color/suw_flat_button_highlight</item>
|
||||
</style>
|
||||
|
||||
<!-- Ignore UnusedResources: used by clients -->
|
||||
<style name="SuwGlifButton.Tertiary"
|
||||
parent="SuwGlifButton.BaseTertiary"
|
||||
tools:ignore="UnusedResources">
|
||||
<item name="textAllCaps" tools:targetApi="ice_cream_sandwich">false</item>
|
||||
</style>
|
||||
|
||||
<!-- Card layout (for tablets) -->
|
||||
|
||||
<style name="TextAppearance.SuwCardTitle" parent="@style/TextAppearance.AppCompat.Display1">
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
|
||||
<!-- Button styles -->
|
||||
|
||||
<style name="SuwGlifButton.Tertiary" parent="SuwGlifButton.BaseTertiary">
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
</style>
|
||||
|
||||
<style name="SuwBase.ProgressBarLarge" parent="@android:style/Widget.Material.ProgressBar.Large" />
|
||||
|
||||
<style name="SuwFourColorIndeterminateProgressBar" parent="SuwBase.ProgressBarLarge">
|
||||
|
|
|
@ -204,11 +204,6 @@
|
|||
<item name="android:textAllCaps" tools:targetApi="ice_cream_sandwich">false</item>
|
||||
</style>
|
||||
|
||||
<!-- Ignore UnusedResources: used by clients -->
|
||||
<style name="SuwGlifButton.Tertiary"
|
||||
parent="SuwGlifButton.BaseTertiary"
|
||||
tools:ignore="UnusedResources" />
|
||||
|
||||
<!-- The start and end paddings are asymmetric because start buttons are borderless buttons
|
||||
which aligns the text label. -->
|
||||
<style name="SuwGlifButtonBar">
|
||||
|
|
|
@ -222,4 +222,11 @@
|
|||
<item name="android:colorControlHighlight">@color/suw_flat_button_highlight</item>
|
||||
</style>
|
||||
|
||||
<!-- Ignore UnusedResources: used by clients -->
|
||||
<style name="SuwGlifButton.Tertiary"
|
||||
parent="SuwGlifButton.BaseTertiary"
|
||||
tools:ignore="UnusedResources">
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.content.Context;
|
|||
import android.os.Build.VERSION;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
|
@ -37,29 +38,21 @@ import androidx.annotation.Nullable;
|
|||
import com.android.setupwizardlib.R;
|
||||
import com.android.setupwizardlib.robolectric.SuwLibRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
import org.robolectric.util.ReflectionHelpers.ClassParameter;
|
||||
|
||||
@RunWith(SuwLibRobolectricTestRunner.class)
|
||||
@Config(sdk = {Config.OLDEST_SDK, Config.NEWEST_SDK})
|
||||
public class GlifStyleTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = new ContextThemeWrapper(application, R.style.SuwThemeGlif_Light);
|
||||
}
|
||||
|
||||
@Ignore("b/78472674")
|
||||
@Test
|
||||
public void testSuwGlifButtonTertiary() {
|
||||
Button button = new Button(
|
||||
mContext,
|
||||
Button button = createButton(
|
||||
new ContextThemeWrapper(application, R.style.SuwThemeGlif_Light),
|
||||
Robolectric.buildAttributeSet()
|
||||
.setStyleAttribute("@style/SuwGlifButton.Tertiary")
|
||||
.build());
|
||||
|
@ -89,6 +82,22 @@ public class GlifStyleTest {
|
|||
activity.findViewById(R.id.suw_large_progress_bar) instanceof ProgressBar);
|
||||
}
|
||||
|
||||
private Button createButton(Context context, AttributeSet attrs) {
|
||||
Class<? extends Button> buttonClass;
|
||||
try {
|
||||
// Use AppCompatButton in builds that have them (i.e. gingerbreadCompat)
|
||||
// noinspection unchecked
|
||||
buttonClass = (Class<? extends Button>)
|
||||
Class.forName("androidx.appcompat.widget.AppCompatButton");
|
||||
} catch (ClassNotFoundException e) {
|
||||
buttonClass = Button.class;
|
||||
}
|
||||
return ReflectionHelpers.callConstructor(
|
||||
buttonClass,
|
||||
ClassParameter.from(Context.class, context),
|
||||
ClassParameter.from(AttributeSet.class, attrs));
|
||||
}
|
||||
|
||||
private static class GlifThemeActivity extends Activity {
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue