Merge "Improve visual - Collapse the conditionals in all cases"
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
index 834ebbc..b477d52 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
@@ -40,7 +40,7 @@
  */
 public class ConditionContextualCardController implements ContextualCardController,
         ConditionListener, LifecycleObserver, OnStart, OnStop {
-    public static final int EXPANDING_THRESHOLD = 2;
+    public static final int EXPANDING_THRESHOLD = 0;
 
     private static final double UNSUPPORTED_RANKING = -99999.0;
     private static final String TAG = "ConditionCtxCardCtrl";
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
index 566ca07..4553f7c 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
@@ -112,7 +112,8 @@
     }
 
     @Test
-    public void getConditionalCards_hasOneConditionCard_shouldGetOneFullWidthCard() {
+    public void getConditionalCards_hasOneConditionCardAndExpanded_shouldGetOneFullWidthCard() {
+        mController.setIsExpanded(true);
         final Map<Integer, List<ContextualCard>> conditionalCards =
                 mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(1));
 
@@ -120,11 +121,24 @@
         assertThat(conditionalCards.get(CardType.CONDITIONAL)).hasSize(1);
         assertThat(conditionalCards.get(CardType.CONDITIONAL).get(0).isHalfWidth()).isFalse();
         assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
+        assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
+    }
+
+    @Test
+    public void getConditionalCards_hasOneConditionCardAndCollapsed_shouldGetConditionalHeader() {
+        mController.setIsExpanded(false);
+        final Map<Integer, List<ContextualCard>> conditionalCards =
+                mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(1));
+
+        assertThat(conditionalCards).hasSize(3);
+        assertThat(conditionalCards.get(CardType.CONDITIONAL)).isEmpty();
+        assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isNotEmpty();
         assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isEmpty();
     }
 
     @Test
-    public void getConditionalCards_hasTwoConditionCards_shouldGetTwoHalfWidthCards() {
+    public void getConditionalCards_hasTwoConditionCardsAndExpanded_shouldGetTwoHalfWidthCards() {
+        mController.setIsExpanded(true);
         final Map<Integer, List<ContextualCard>> conditionalCards =
                 mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
 
@@ -134,6 +148,18 @@
             assertThat(card.isHalfWidth()).isTrue();
         }
         assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
+        assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
+    }
+
+    @Test
+    public void getConditionalCards_hasTwoConditionCardsAndCollapsed_shouldGetConditionalHeader() {
+        mController.setIsExpanded(false);
+        final Map<Integer, List<ContextualCard>> conditionalCards =
+                mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
+
+        assertThat(conditionalCards).hasSize(3);
+        assertThat(conditionalCards.get(CardType.CONDITIONAL)).isEmpty();
+        assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isNotEmpty();
         assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isEmpty();
     }