Add unit testing to workkUtilityView

Testing inflate and visibility states (with both flag states)

bug: 361589193
Test: manually screenshot: https://screenshot.googleplex.com/45HDsyfQfNbgjiE
Flag: com.android.launcher3.work_scheduler_in_work_profile
Change-Id: I57cff03fe3b362e304f52984a2699f8d5b6e653e
This commit is contained in:
Brandon Dayauon
2024-11-25 13:51:33 -08:00
parent c4a90de0e9
commit fcb892328b
2 changed files with 96 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.Insets;
import androidx.core.view.WindowInsetsCompat;
@@ -126,6 +127,7 @@ public class WorkUtilityView extends LinearLayout implements Insettable,
setInsets(mActivityContext.getDeviceProfile().getInsets());
updateStringFromCache();
mSchedulerButton.setVisibility(GONE);
mSchedulerButton.setOnClickListener(null);
if (shouldUseScheduler()) {
mSchedulerButton.setVisibility(VISIBLE);
mSchedulerButton.setOnClickListener(view ->
@@ -393,7 +395,13 @@ public class WorkUtilityView extends LinearLayout implements Insettable,
}
}
private boolean shouldUseScheduler() {
@VisibleForTesting
boolean shouldUseScheduler() {
return Flags.workSchedulerInWorkProfile() && !mWorkSchedulerIntentAction.isEmpty();
}
@VisibleForTesting
ImageButton getSchedulerButton() {
return mSchedulerButton;
}
}