|
46 | 46 | import java.util.HashMap; |
47 | 47 | import java.util.HashSet; |
48 | 48 | import java.util.List; |
| 49 | +import java.util.Locale; |
49 | 50 | import java.util.Map; |
50 | 51 | import java.util.stream.Collectors; |
51 | 52 |
|
@@ -220,7 +221,13 @@ protected List<TestListItem> getRows() { |
220 | 221 | } |
221 | 222 | } |
222 | 223 |
|
223 | | - return mDisplayModesTests.getOrDefault(sCurrentDisplayMode.toString(), new ArrayList<>()); |
| 224 | + if (mTestFilter != null) { |
| 225 | + // Filter test rows dynamically when the filter is specified. |
| 226 | + return getRowsWithDisplayMode(sCurrentDisplayMode.toString()); |
| 227 | + } else { |
| 228 | + return mDisplayModesTests.getOrDefault( |
| 229 | + sCurrentDisplayMode.toString(), new ArrayList<>()); |
| 230 | + } |
224 | 231 | } |
225 | 232 |
|
226 | 233 | /** |
@@ -585,6 +592,17 @@ private boolean matchAnyExcludedUserType(String[] userTypes) { |
585 | 592 | return false; |
586 | 593 | } |
587 | 594 |
|
| 595 | + /** Checks whether the title of the test matches the test filter. */ |
| 596 | + private boolean macthTestFilter(String testTitle) { |
| 597 | + if (mTestFilter == null) { |
| 598 | + return true; |
| 599 | + } |
| 600 | + return testTitle != null |
| 601 | + && testTitle |
| 602 | + .toLowerCase(Locale.getDefault()) |
| 603 | + .contains(mTestFilter.toLowerCase(Locale.getDefault())); |
| 604 | + } |
| 605 | + |
588 | 606 | private boolean isVisibleBackgroundNonProfileUser() { |
589 | 607 | if (!SdkLevel.isAtLeastU()) { |
590 | 608 | Log.d(LOG_TAG, "isVisibleBagroundNonProfileUser() returning false on pre-UDC device"); |
@@ -637,7 +655,8 @@ && hasAllFeatures(test.requiredFeatures) |
637 | 655 | && hasAllActions(test.requiredActions) |
638 | 656 | && matchAllConfigs(mContext, test.requiredConfigs) |
639 | 657 | && matchDisplayMode(test.displayMode, mode) |
640 | | - && !matchAnyExcludedUserType(test.excludedUserTypes)) { |
| 658 | + && !matchAnyExcludedUserType(test.excludedUserTypes) |
| 659 | + && macthTestFilter(test.title)) { |
641 | 660 | if (test.applicableFeatures == null || hasAnyFeature(test.applicableFeatures)) { |
642 | 661 | // Add suffix in test name if the test is in the folded mode. |
643 | 662 | test.testName = setTestNameSuffix(mode, test.testName); |
|
0 commit comments