summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2016-06-22 12:01:44 -0700
committerMaurice Lam <yukl@google.com>2016-06-22 12:01:44 -0700
commitd66273847cb8cb69513db37e26e6ab0ee0590cc3 (patch)
treeac8a3edd0d0657c9f0617f23396b0131523fc6e1
parent50e31a5e909a65cf6457dd80b9c9150a6e76b6a7 (diff)
downloadsetupwizard-d66273847cb8cb69513db37e26e6ab0ee0590cc3.tar.gz
[SuwLib] Null check if progress bar is not in template
Bug: 28848765 Change-Id: If447167cb0bb3d112d797389d0f8d790b02e3557
-rw-r--r--library/main/src/com/android/setupwizardlib/GlifLayout.java4
-rw-r--r--library/test/src/com/android/setupwizardlib/test/GlifLayoutTest.java9
2 files changed, 11 insertions, 2 deletions
diff --git a/library/main/src/com/android/setupwizardlib/GlifLayout.java b/library/main/src/com/android/setupwizardlib/GlifLayout.java
index 3d79da5..765e6a6 100644
--- a/library/main/src/com/android/setupwizardlib/GlifLayout.java
+++ b/library/main/src/com/android/setupwizardlib/GlifLayout.java
@@ -236,7 +236,9 @@ public class GlifLayout extends TemplateLayout {
public void setProgressBarShown(boolean shown) {
if (shown) {
View progressBar = getProgressBar();
- progressBar.setVisibility(View.VISIBLE);
+ if (progressBar != null) {
+ progressBar.setVisibility(View.VISIBLE);
+ }
} else {
View progressBar = peekProgressBar();
if (progressBar != null) {
diff --git a/library/test/src/com/android/setupwizardlib/test/GlifLayoutTest.java b/library/test/src/com/android/setupwizardlib/test/GlifLayoutTest.java
index 24351da..8100eda 100644
--- a/library/test/src/com/android/setupwizardlib/test/GlifLayoutTest.java
+++ b/library/test/src/com/android/setupwizardlib/test/GlifLayoutTest.java
@@ -121,13 +121,20 @@ public class GlifLayoutTest extends InstrumentationTestCase {
}
@SmallTest
- public void testPekkProgressBar() {
+ public void testPeekProgressBar() {
GlifLayout layout = new GlifLayout(mContext);
layout.setProgressBarShown(true);
assertNotNull("Peek progress bar should return the bar after setProgressBarShown(true)",
layout.peekProgressBar());
}
+ @SmallTest
+ public void testSetProgressBarShownInvalid() {
+ GlifLayout layout = new GlifLayout(mContext, R.layout.test_template);
+ layout.setProgressBarShown(true);
+ // This is a no-op because there is no progress bar stub
+ }
+
private void assertDefaultTemplateInflated(GlifLayout layout) {
View title = layout.findViewById(R.id.suw_layout_title);
assertNotNull("@id/suw_layout_title should not be null", title);