summaryrefslogtreecommitdiff
path: root/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java
blob: 58af51c564e7bb3851daea73f942e4cd9f6e3f17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.launcher3.ui;

import static androidx.test.core.app.ApplicationProvider.getApplicationContext;

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;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.UserHandle;
import android.platform.test.flag.junit.SetFlagsRule;
import android.view.ViewGroup;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Flags;
import com.android.launcher3.Utilities;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
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;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.MockitoAnnotations;

/**
 * Unit tests for testing modifyTitleToSupportMultiLine() in BubbleTextView.java
 * This class tests a couple of strings and uses the getMaxLines() to determine if the test passes.
 * Verifying with getMaxLines() is sufficient since BubbleTextView can only be in one line or
 * two lines, and this is enough to ensure whether the string should be specifically wrapped onto
 * the second line and to ensure truncation.
 */
public class BubbleTextViewTest {

    @Rule public final SetFlagsRule mSetFlagsRule =
            new SetFlagsRule(SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT);
    private static final StringMatcherUtility.StringMatcher
            MATCHER = StringMatcherUtility.StringMatcher.getInstance();
    private static final UserHandle WORK_HANDLE = new UserHandle(13);
    private static final int WORK_FLAG = 1;
    private static final int ONE_LINE = 1;
    private static final int TWO_LINE = 2;
    private static final String TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT = "Battery Stats";
    private static final String TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT_RESULT =
            "Battery\nStats";
    private static final String TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT =
            "flutterappflorafy";
    private static final String TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT =
            "System UWB Field Test";
    private static final String TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT_RESULT =
            "System\nUWB Field Test";
    private static final String TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT =
            "LEGO®Builder";
    private static final String TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT_RESULT =
            "LEGO®\nBuilder";
    private static final String EMPTY_STRING = "";
    private static final int CHAR_CNT = 7;
    private static final int MAX_HEIGHT = Integer.MAX_VALUE;
    private static final int LIMITED_HEIGHT = 357; /* allowedHeight in Pixel6 */
    private static final float SPACE_MULTIPLIER = 1;
    private static final float SPACE_EXTRA = 0;

    private BubbleTextView mBubbleTextView;
    private ItemInfoWithIcon mItemInfoWithIcon;
    private Context mContext;
    private int mLimitedWidth;
    private AppInfo mGmailAppInfo;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        Utilities.enableRunningInTestHarnessForTests();
        mContext = new ActivityContextWrapper(getApplicationContext());
        mBubbleTextView = new BubbleTextView(mContext);
        mBubbleTextView.reset();

        BubbleTextView testView = new BubbleTextView(mContext);
        testView.setTypeface(Typeface.MONOSPACE);
        testView.setText("B");
        // calculate the maxWidth of the textView by calculating the width of one monospace
        // character * CHAR_CNT
        mLimitedWidth =
                (int) (testView.getPaint().measureText(testView.getText().toString()) * CHAR_CNT);
        // needed otherwise there is a NPE during setText() on checkForRelayout()
        mBubbleTextView.setLayoutParams(
                new ViewGroup.LayoutParams(mLimitedWidth,
                BaseDragLayer.LayoutParams.WRAP_CONTENT));
        mItemInfoWithIcon = new ItemInfoWithIcon() {
            @Override
            public ItemInfoWithIcon clone() {
                return null;
            }
        };
        ComponentName componentName = new ComponentName(mContext,
                "com.android.launcher3.tests.Activity" + "Gmail");
        mGmailAppInfo = new AppInfo(componentName, "Gmail", WORK_HANDLE, new Intent());
    }

    @Test
    public void testEmptyString_flagOn() {
        mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertNotEquals(TWO_LINE, mBubbleTextView.getMaxLines());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testEmptyString_flagOff() {
        mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testStringWithSpaceLongerThanCharLimit_flagOn() {
        mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testStringWithSpaceLongerThanCharLimit_flagOff() {
        mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testLongStringNoSpaceLongerThanCharLimit_flagOn() {
        mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testLongStringNoSpaceLongerThanCharLimit_flagOff() {
        mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testLongStringWithSpaceLongerThanCharLimit_flagOn() {
        mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testLongStringWithSpaceLongerThanCharLimit_flagOff() {
        mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testLongStringSymbolLongerThanCharLimit_flagOn() {
        mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testLongStringSymbolLongerThanCharLimit_flagOff() {
        mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void modifyTitleToSupportMultiLine_TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT() {
        // test string: "Battery Stats"
        IntArray breakPoints = StringMatcherUtility.getListOfBreakpoints(
                TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT, MATCHER);
        CharSequence newString = BubbleTextView.modifyTitleToSupportMultiLine(mLimitedWidth,
                MAX_HEIGHT,
                TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT, mBubbleTextView.getPaint(),
                breakPoints,
                SPACE_MULTIPLIER,
                SPACE_EXTRA);
        assertEquals(TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT_RESULT, newString);
    }

    @Test
    public void modifyTitleToSupportMultiLine_TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT() {
        // test string: "flutterappflorafy"
        IntArray breakPoints = StringMatcherUtility.getListOfBreakpoints(
                TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT, MATCHER);
        CharSequence newString = BubbleTextView.modifyTitleToSupportMultiLine(mLimitedWidth, 0,
                TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT, mBubbleTextView.getPaint(),
                breakPoints,
                SPACE_MULTIPLIER,
                SPACE_EXTRA);
        assertEquals(TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT, newString);
    }

    @Test
    public void modifyTitleToSupportMultiLine_TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT() {
        // test string: "System UWB Field Test"
        IntArray breakPoints = StringMatcherUtility.getListOfBreakpoints(
                TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT, MATCHER);
        CharSequence newString = BubbleTextView.modifyTitleToSupportMultiLine(mLimitedWidth,
                MAX_HEIGHT,
                TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT, mBubbleTextView.getPaint(),
                breakPoints,
                SPACE_MULTIPLIER,
                SPACE_EXTRA);
        assertEquals(TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT_RESULT, newString);
    }

    @Test
    public void modifyTitleToSupportMultiLine_TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT() {
        // test string: "LEGO®Builder"
        IntArray breakPoints = StringMatcherUtility.getListOfBreakpoints(
                TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT, MATCHER);
        CharSequence newString = BubbleTextView.modifyTitleToSupportMultiLine(
                mLimitedWidth,
                MAX_HEIGHT,
                TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT, mBubbleTextView.getPaint(),
                breakPoints,
                SPACE_MULTIPLIER,
                SPACE_EXTRA);
        assertEquals(TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT_RESULT, newString);
    }

    @Test
    public void testEnsurePredictionRowIsTwoLine() {
        mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
        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();

            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);
        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();

            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);
        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();

            assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void applyIconAndLabel_whenDisplay_DISPLAY_SEARCH_RESULT_SMALL_noBadge() {
        FlagOp op = FlagOp.NO_OP;
        // apply the WORK bitmap flag to show work badge
        mGmailAppInfo.bitmap.flags = op.apply(WORK_FLAG);
        mBubbleTextView.setDisplay(DISPLAY_SEARCH_RESULT_SMALL);

        mBubbleTextView.applyIconAndLabel(mGmailAppInfo);

        assertThat(mBubbleTextView.getIcon().hasBadge()).isEqualTo(false);
    }

    @Test
    public void applyIconAndLabel_whenDisplay_DISPLAY_SEARCH_RESULT_hasBadge() {
        FlagOp op = FlagOp.NO_OP;
        // apply the WORK bitmap flag to show work badge
        mGmailAppInfo.bitmap.flags = op.apply(WORK_FLAG);
        mBubbleTextView.setDisplay(DISPLAY_SEARCH_RESULT);

        mBubbleTextView.applyIconAndLabel(mGmailAppInfo);

        assertThat(mBubbleTextView.getIcon().hasBadge()).isEqualTo(true);
    }
}