summaryrefslogtreecommitdiffstats
path: root/library/test/src/com
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2015-04-02 17:03:08 -0700
committerMaurice Lam <yukl@google.com>2015-04-03 18:26:42 -0700
commitd61674efcfaa9f591a44fc75d59566cdd5b409eb (patch)
tree220ca8157515e15800bd28058bede2f794a42499 /library/test/src/com
parente7b519c1769be4e43fff8c9a909cb1ba15f25ebb (diff)
downloadandroid_frameworks_opt_setupwizard-d61674efcfaa9f591a44fc75d59566cdd5b409eb.tar.gz
android_frameworks_opt_setupwizard-d61674efcfaa9f591a44fc75d59566cdd5b409eb.tar.bz2
android_frameworks_opt_setupwizard-d61674efcfaa9f591a44fc75d59566cdd5b409eb.zip
[SetupWizardLib] Add progress bar support
Added methods showProgressBar, hideProgressBar and isProgressBarShown to SetupWizardLayout, that will show the bar if the corresponding ViewStub exists. This implementation has an improvement over existing Setup Wizard implementations in that it supports ListViews as well as ScrollViews, and the progress bar will be sticky together with the header instead of being scrolled away. Change-Id: Ifd7acae36a9b244d759b6528bb5dfdc3e1d15091
Diffstat (limited to 'library/test/src/com')
-rw-r--r--library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java31
-rw-r--r--library/test/src/com/android/setupwizardlib/test/SetupWizardListLayoutTests.java11
2 files changed, 42 insertions, 0 deletions
diff --git a/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java b/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java
index cce2f70..f640ca8 100644
--- a/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java
+++ b/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java
@@ -24,6 +24,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.setupwizardlib.SetupWizardLayout;
@@ -112,6 +113,36 @@ public class SetupWizardLayoutTests extends InstrumentationTestCase {
assertNull("getNavigationBar() in test_template should return null", navigationBar);
}
+ @SmallTest
+ public void testShowProgressBar() {
+ final SetupWizardLayout layout = new SetupWizardLayout(mContext);
+ layout.showProgressBar();
+ assertTrue("Progress bar should be shown", layout.isProgressBarShown());
+ final View progressBar = layout.findViewById(R.id.suw_layout_progress);
+ assertTrue("Progress bar view should be shown",
+ progressBar instanceof ProgressBar && progressBar.getVisibility() == View.VISIBLE);
+ }
+
+ @SmallTest
+ public void testHideProgressBar() {
+ final SetupWizardLayout layout = new SetupWizardLayout(mContext);
+ layout.showProgressBar();
+ assertTrue("Progress bar should be shown", layout.isProgressBarShown());
+ layout.hideProgressBar();
+ assertFalse("Progress bar should be hidden", layout.isProgressBarShown());
+ final View progressBar = layout.findViewById(R.id.suw_layout_progress);
+ assertTrue("Progress bar view should exist",
+ progressBar == null || progressBar.getVisibility() != View.VISIBLE);
+ }
+
+ @SmallTest
+ public void testShowProgressBarNotExist() {
+ // test_template does not have progress bar, so showNavigationBar() should do nothing.
+ final SetupWizardLayout layout = new SetupWizardLayout(mContext, R.layout.test_template);
+ layout.showProgressBar();
+ assertFalse("Progress bar should not be shown", layout.isProgressBarShown());
+ }
+
private void assertDefaultTemplateInflated(SetupWizardLayout layout) {
View decorView = layout.findViewById(R.id.suw_layout_decor);
View navbar = layout.findViewById(R.id.suw_layout_navigation_bar);
diff --git a/library/test/src/com/android/setupwizardlib/test/SetupWizardListLayoutTests.java b/library/test/src/com/android/setupwizardlib/test/SetupWizardListLayoutTests.java
index f6233a8..619435a 100644
--- a/library/test/src/com/android/setupwizardlib/test/SetupWizardListLayoutTests.java
+++ b/library/test/src/com/android/setupwizardlib/test/SetupWizardListLayoutTests.java
@@ -23,6 +23,7 @@ import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.setupwizardlib.SetupWizardLayout;
@@ -66,6 +67,16 @@ public class SetupWizardListLayoutTests extends InstrumentationTestCase {
assertListTemplateInflated(layout);
}
+ @SmallTest
+ public void testShowProgressBar() {
+ final SetupWizardListLayout layout = new SetupWizardListLayout(mContext);
+ layout.showProgressBar();
+ assertTrue("Progress bar should be shown", layout.isProgressBarShown());
+ final View progressBar = layout.findViewById(R.id.suw_layout_progress);
+ assertTrue("Progress bar view should be shown",
+ progressBar instanceof ProgressBar && progressBar.getVisibility() == View.VISIBLE);
+ }
+
private void assertListTemplateInflated(SetupWizardLayout layout) {
View decorView = layout.findViewById(R.id.suw_layout_decor);
View navbar = layout.findViewById(R.id.suw_layout_navigation_bar);