diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 713009ed75..b8787fdf9f 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -238,7 +238,7 @@ public final class FeatureFlags { // Aconfig migration complete for ENABLE_TWOLINE_ALLAPPS. public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag(270390937, - "ENABLE_TWOLINE_ALLAPPS", DISABLED, "Enables two line label inside all apps."); + "ENABLE_TWOLINE_ALLAPPS", ENABLED, "Enables two line label inside all apps."); public static boolean enableTwolineAllapps() { return ENABLE_TWOLINE_ALLAPPS.get() || Flags.enableTwolineAllapps(); } diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait.txt index ec32680b77..82e46f456e 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 147.0px (56.0dp) allAppsIconTextSizePx: 38.0px (14.476191dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 315.0px (120.0dp) + allAppsCellHeightPx: 366.0px (139.42857dp) allAppsCellWidthPx: 189.0px (72.0dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait3Button.txt index d69be3f365..674d68cc2f 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/phonePortrait3Button.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 147.0px (56.0dp) allAppsIconTextSizePx: 38.0px (14.476191dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 315.0px (120.0dp) + allAppsCellHeightPx: 366.0px (139.42857dp) allAppsCellWidthPx: 189.0px (72.0dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar.txt index 7e92620853..1c30c1506d 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 147.0px (56.0dp) allAppsIconTextSizePx: 38.0px (14.476191dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 321.0px (122.28571dp) + allAppsCellHeightPx: 372.0px (141.71428dp) allAppsCellWidthPx: 189.0px (72.0dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar3Button.txt index a9bee2b232..52142a0a69 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/phoneVerticalBar3Button.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 147.0px (56.0dp) allAppsIconTextSizePx: 38.0px (14.476191dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 321.0px (122.28571dp) + allAppsCellHeightPx: 372.0px (141.71428dp) allAppsCellWidthPx: 189.0px (72.0dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape.txt index 42b022b471..8e0818d73e 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 120.0px (60.0dp) allAppsIconTextSizePx: 28.0px (14.0dp) allAppsIconDrawablePaddingPx: 9.0px (4.5dp) - allAppsCellHeightPx: 284.0px (142.0dp) + allAppsCellHeightPx: 322.0px (161.0dp) allAppsCellWidthPx: 252.0px (126.0dp) allAppsBorderSpacePxX: 32.0px (16.0dp) allAppsBorderSpacePxY: 32.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape3Button.txt index 53f8580755..ab13e502a7 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletLandscape3Button.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 120.0px (60.0dp) allAppsIconTextSizePx: 28.0px (14.0dp) allAppsIconDrawablePaddingPx: 9.0px (4.5dp) - allAppsCellHeightPx: 284.0px (142.0dp) + allAppsCellHeightPx: 322.0px (161.0dp) allAppsCellWidthPx: 252.0px (126.0dp) allAppsBorderSpacePxX: 32.0px (16.0dp) allAppsBorderSpacePxY: 32.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait.txt index 87189fa297..e2b1f69c41 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait.txt @@ -54,14 +54,14 @@ DeviceProfile: bottomSheetCloseDuration: 500 bottomSheetWorkspaceScale: 0.97 bottomSheetDepth: 0.0 - allAppsShiftRange: 1810.0px (905.0dp) - allAppsTopPadding: 750.0px (375.0dp) + allAppsShiftRange: 2019.0px (1009.5dp) + allAppsTopPadding: 541.0px (270.5dp) allAppsOpenDuration: 500 allAppsCloseDuration: 500 allAppsIconSizePx: 120.0px (60.0dp) allAppsIconTextSizePx: 28.0px (14.0dp) allAppsIconDrawablePaddingPx: 9.0px (4.5dp) - allAppsCellHeightPx: 316.0px (158.0dp) + allAppsCellHeightPx: 354.0px (177.0dp) allAppsCellWidthPx: 192.0px (96.0dp) allAppsBorderSpacePxX: 16.0px (8.0dp) allAppsBorderSpacePxY: 32.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait3Button.txt index 0ade560352..e838c0683b 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/tabletPortrait3Button.txt @@ -54,14 +54,14 @@ DeviceProfile: bottomSheetCloseDuration: 500 bottomSheetWorkspaceScale: 0.97 bottomSheetDepth: 0.0 - allAppsShiftRange: 1810.0px (905.0dp) - allAppsTopPadding: 750.0px (375.0dp) + allAppsShiftRange: 2019.0px (1009.5dp) + allAppsTopPadding: 541.0px (270.5dp) allAppsOpenDuration: 500 allAppsCloseDuration: 500 allAppsIconSizePx: 120.0px (60.0dp) allAppsIconTextSizePx: 28.0px (14.0dp) allAppsIconDrawablePaddingPx: 9.0px (4.5dp) - allAppsCellHeightPx: 316.0px (158.0dp) + allAppsCellHeightPx: 354.0px (177.0dp) allAppsCellWidthPx: 192.0px (96.0dp) allAppsBorderSpacePxX: 16.0px (8.0dp) allAppsBorderSpacePxY: 32.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape.txt index d24457d96b..903235aa6a 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 141.0px (53.714287dp) allAppsIconTextSizePx: 34.0px (12.952381dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 315.0px (120.0dp) + allAppsCellHeightPx: 361.0px (137.5238dp) allAppsCellWidthPx: 183.0px (69.71429dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape3Button.txt index 38dc2c9231..d3c3458f53 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelLandscape3Button.txt @@ -61,7 +61,7 @@ DeviceProfile: allAppsIconSizePx: 141.0px (53.714287dp) allAppsIconTextSizePx: 34.0px (12.952381dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 315.0px (120.0dp) + allAppsCellHeightPx: 361.0px (137.5238dp) allAppsCellWidthPx: 183.0px (69.71429dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt index 5d23147b0a..64b372194b 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt @@ -54,14 +54,14 @@ DeviceProfile: bottomSheetCloseDuration: 500 bottomSheetWorkspaceScale: 0.97 bottomSheetDepth: 1.0 - allAppsShiftRange: 1826.0px (695.619dp) - allAppsTopPadding: 382.0px (145.5238dp) + allAppsShiftRange: 2075.0px (790.4762dp) + allAppsTopPadding: 133.0px (50.666668dp) allAppsOpenDuration: 500 allAppsCloseDuration: 500 allAppsIconSizePx: 141.0px (53.714287dp) allAppsIconTextSizePx: 34.0px (12.952381dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 315.0px (120.0dp) + allAppsCellHeightPx: 361.0px (137.5238dp) allAppsCellWidthPx: 183.0px (69.71429dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt index 5b5350985b..584a3b533e 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt @@ -54,14 +54,14 @@ DeviceProfile: bottomSheetCloseDuration: 500 bottomSheetWorkspaceScale: 0.97 bottomSheetDepth: 1.0 - allAppsShiftRange: 1826.0px (695.619dp) - allAppsTopPadding: 382.0px (145.5238dp) + allAppsShiftRange: 2075.0px (790.4762dp) + allAppsTopPadding: 133.0px (50.666668dp) allAppsOpenDuration: 500 allAppsCloseDuration: 500 allAppsIconSizePx: 141.0px (53.714287dp) allAppsIconTextSizePx: 34.0px (12.952381dp) allAppsIconDrawablePaddingPx: 21.0px (8.0dp) - allAppsCellHeightPx: 315.0px (120.0dp) + allAppsCellHeightPx: 361.0px (137.5238dp) allAppsCellWidthPx: 183.0px (69.71429dp) allAppsBorderSpacePxX: 42.0px (16.0dp) allAppsBorderSpacePxY: 42.0px (16.0dp) diff --git a/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java b/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java index b01941456a..0d153002f1 100644 --- a/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java +++ b/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java @@ -22,6 +22,7 @@ import static com.android.launcher3.BubbleTextView.DISPLAY_ALL_APPS; import static com.android.launcher3.BubbleTextView.DISPLAY_PREDICTION_ROW; import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT; import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT_SMALL; +import static com.android.launcher3.config.FeatureFlags.ENABLE_TWOLINE_ALLAPPS; import static com.google.common.truth.Truth.assertThat; @@ -32,8 +33,8 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; -import android.platform.test.flag.junit.SetFlagsRule; import android.os.UserHandle; +import android.platform.test.flag.junit.SetFlagsRule; import android.view.ViewGroup; import com.android.launcher3.BubbleTextView; @@ -45,6 +46,7 @@ import com.android.launcher3.search.StringMatcherUtility; import com.android.launcher3.util.ActivityContextWrapper; import com.android.launcher3.util.FlagOp; import com.android.launcher3.util.IntArray; +import com.android.launcher3.util.TestUtil; import com.android.launcher3.views.BaseDragLayer; import org.junit.Before; @@ -128,149 +130,189 @@ public class BubbleTextViewTest { @Test public void testEmptyString_flagOn() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - mItemInfoWithIcon.title = EMPTY_STRING; - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + mItemInfoWithIcon.title = EMPTY_STRING; + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertNotEquals(TWO_LINE, mBubbleTextView.getMaxLines()); + assertNotEquals(TWO_LINE, mBubbleTextView.getMaxLines()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testEmptyString_flagOff() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - mItemInfoWithIcon.title = EMPTY_STRING; - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) { + mItemInfoWithIcon.title = EMPTY_STRING; + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testStringWithSpaceLongerThanCharLimit_flagOn() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "Battery Stats" - mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "Battery Stats" + mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testStringWithSpaceLongerThanCharLimit_flagOff() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "Battery Stats" - mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) { + // test string: "Battery Stats" + mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testLongStringNoSpaceLongerThanCharLimit_flagOn() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "flutterappflorafy" - mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "flutterappflorafy" + mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testLongStringNoSpaceLongerThanCharLimit_flagOff() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "flutterappflorafy" - mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) { + // test string: "flutterappflorafy" + mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testLongStringWithSpaceLongerThanCharLimit_flagOn() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "System UWB Field Test" - mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "System UWB Field Test" + mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testLongStringWithSpaceLongerThanCharLimit_flagOff() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "System UWB Field Test" - mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) { + // test string: "System UWB Field Test" + mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testLongStringSymbolLongerThanCharLimit_flagOn() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "LEGO®Builder" - mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "LEGO®Builder" + mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void testLongStringSymbolLongerThanCharLimit_flagOff() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "LEGO®Builder" - mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) { + // test string: "LEGO®Builder" + mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test @@ -332,45 +374,57 @@ public class BubbleTextViewTest { @Test public void testEnsurePredictionRowIsTwoLine() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "Battery Stats" - mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.setDisplay(DISPLAY_PREDICTION_ROW); - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "Battery Stats" + mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.setDisplay(DISPLAY_PREDICTION_ROW); + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void modifyTitleToSupportMultiLine_whenLimitedHeight_shouldBeOneLine() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "LEGO®Builder" - mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "LEGO®Builder" + mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + assertEquals(ONE_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test public void modifyTitleToSupportMultiLine_whenUnlimitedHeight_shouldBeTwoLine() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS); - // test string: "LEGO®Builder" - mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; - mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); - mBubbleTextView.applyLabel(mItemInfoWithIcon); - mBubbleTextView.setTypeface(Typeface.MONOSPACE); - mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); + try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) { + // test string: "LEGO®Builder" + mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT; + mBubbleTextView.setDisplay(DISPLAY_ALL_APPS); + mBubbleTextView.applyLabel(mItemInfoWithIcon); + mBubbleTextView.setTypeface(Typeface.MONOSPACE); + mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT); - mBubbleTextView.onPreDraw(); + mBubbleTextView.onPreDraw(); - assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + assertEquals(TWO_LINE, mBubbleTextView.getLineCount()); + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test