Merge "Enforce mutual exclusivity in setScrollCaptureHint" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9ab42eb145
@@ -30143,6 +30143,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
public void setScrollCaptureHint(@ScrollCaptureHint int hint) {
|
||||
mPrivateFlags4 &= ~PFLAG4_SCROLL_CAPTURE_HINT_MASK;
|
||||
// Since include/exclude are mutually exclusive, exclude takes precedence.
|
||||
if ((hint & SCROLL_CAPTURE_HINT_EXCLUDE) != 0) {
|
||||
hint &= ~SCROLL_CAPTURE_HINT_INCLUDE;
|
||||
}
|
||||
mPrivateFlags4 |= ((hint << PFLAG4_SCROLL_CAPTURE_HINT_SHIFT)
|
||||
& PFLAG4_SCROLL_CAPTURE_HINT_MASK);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,18 @@ public class ViewGroupScrollCaptureTest {
|
||||
viewGroup.getScrollCaptureHint());
|
||||
}
|
||||
|
||||
/** Make sure the hint flags are saved and loaded correctly. */
|
||||
@Test
|
||||
public void testSetScrollCaptureHint_mutuallyExclusiveFlags() throws Exception {
|
||||
final Context context = getInstrumentation().getContext();
|
||||
final MockViewGroup viewGroup = new MockViewGroup(context);
|
||||
|
||||
viewGroup.setScrollCaptureHint(
|
||||
View.SCROLL_CAPTURE_HINT_INCLUDE | View.SCROLL_CAPTURE_HINT_EXCLUDE);
|
||||
assertEquals("Mutually exclusive flags were not resolved correctly",
|
||||
ViewGroup.SCROLL_CAPTURE_HINT_EXCLUDE, viewGroup.getScrollCaptureHint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure a ViewGroup with 'scrollCaptureHint=auto', but no ScrollCaptureCallback set dispatches
|
||||
* correctly. Verifies that the framework helper is called. Verifies a that non-null callback
|
||||
|
||||
Reference in New Issue
Block a user