mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Merge "Clean up bubble text view test so that the feature flag is off at the end" into tm-qpr-dev am: c5677f824f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21964113 Change-Id: Iec943c917c17c789a04ae995bd55355d667ce09a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -102,120 +102,150 @@ public class BubbleTextViewTest {
|
||||
|
||||
@Test
|
||||
public void testEmptyString_flagOn() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true);
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getMaxLines());
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getMaxLines());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyString_flagOff() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false);
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) {
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringWithSpaceLongerThanCharLimit_flagOn() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true);
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringWithSpaceLongerThanCharLimit_flagOff() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false);
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringNoSpaceLongerThanCharLimit_flagOn() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true);
|
||||
// test string: "flutterappflorafy"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringNoSpaceLongerThanCharLimit_flagOff() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false);
|
||||
// test string: "flutterappflorafy"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringWithSpaceLongerThanCharLimit_flagOn() {
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringWithSpaceLongerThanCharLimit_flagOff() {
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringSymbolLongerThanCharLimit_flagOn() {
|
||||
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, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
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, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringSymbolLongerThanCharLimit_flagOff() {
|
||||
TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false);
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
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.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, 0);
|
||||
mBubbleTextView.onPreDraw();
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user