Loading libs/gui/android/gui/FocusRequest.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ parcelable FocusRequest { /** /** * Input channel token used to identify the window that should gain focus. * Input channel token used to identify the window that should gain focus. */ */ IBinder token; @nullable IBinder token; @utf8InCpp String windowName; @utf8InCpp String windowName; /** /** * The token that the caller expects currently to be focused. If the * The token that the caller expects currently to be focused. If the Loading services/inputflinger/tests/FocusResolver_test.cpp +24 −0 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,30 @@ TEST(FocusResolverTest, SetFocusedWindow) { ASSERT_FALSE(changes); ASSERT_FALSE(changes); } } TEST(FocusResolverTest, RemoveFocusFromFocusedWindow) { sp<IBinder> focusableWindowToken = new BBinder(); std::vector<sp<WindowInfoHandle>> windows; windows.push_back(new FakeWindowHandle("Focusable", focusableWindowToken, true /* focusable */, true /* visible */)); FocusRequest request; request.displayId = 42; request.token = focusableWindowToken; FocusResolver focusResolver; // Focusable window gets focus. request.token = focusableWindowToken; std::optional<FocusResolver::FocusChanges> changes = focusResolver.setFocusedWindow(request, windows); ASSERT_FOCUS_CHANGE(changes, nullptr, focusableWindowToken); // Window token of a request is null, focus should be revoked. request.token = NULL; changes = focusResolver.setFocusedWindow(request, windows); ASSERT_EQ(focusableWindowToken, changes->oldFocus); ASSERT_EQ(nullptr, changes->newFocus); ASSERT_FOCUS_CHANGE(changes, focusableWindowToken, nullptr); } TEST(FocusResolverTest, SetFocusedMirroredWindow) { TEST(FocusResolverTest, SetFocusedMirroredWindow) { sp<IBinder> focusableWindowToken = new BBinder(); sp<IBinder> focusableWindowToken = new BBinder(); sp<IBinder> invisibleWindowToken = new BBinder(); sp<IBinder> invisibleWindowToken = new BBinder(); Loading Loading
libs/gui/android/gui/FocusRequest.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ parcelable FocusRequest { /** /** * Input channel token used to identify the window that should gain focus. * Input channel token used to identify the window that should gain focus. */ */ IBinder token; @nullable IBinder token; @utf8InCpp String windowName; @utf8InCpp String windowName; /** /** * The token that the caller expects currently to be focused. If the * The token that the caller expects currently to be focused. If the Loading
services/inputflinger/tests/FocusResolver_test.cpp +24 −0 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,30 @@ TEST(FocusResolverTest, SetFocusedWindow) { ASSERT_FALSE(changes); ASSERT_FALSE(changes); } } TEST(FocusResolverTest, RemoveFocusFromFocusedWindow) { sp<IBinder> focusableWindowToken = new BBinder(); std::vector<sp<WindowInfoHandle>> windows; windows.push_back(new FakeWindowHandle("Focusable", focusableWindowToken, true /* focusable */, true /* visible */)); FocusRequest request; request.displayId = 42; request.token = focusableWindowToken; FocusResolver focusResolver; // Focusable window gets focus. request.token = focusableWindowToken; std::optional<FocusResolver::FocusChanges> changes = focusResolver.setFocusedWindow(request, windows); ASSERT_FOCUS_CHANGE(changes, nullptr, focusableWindowToken); // Window token of a request is null, focus should be revoked. request.token = NULL; changes = focusResolver.setFocusedWindow(request, windows); ASSERT_EQ(focusableWindowToken, changes->oldFocus); ASSERT_EQ(nullptr, changes->newFocus); ASSERT_FOCUS_CHANGE(changes, focusableWindowToken, nullptr); } TEST(FocusResolverTest, SetFocusedMirroredWindow) { TEST(FocusResolverTest, SetFocusedMirroredWindow) { sp<IBinder> focusableWindowToken = new BBinder(); sp<IBinder> focusableWindowToken = new BBinder(); sp<IBinder> invisibleWindowToken = new BBinder(); sp<IBinder> invisibleWindowToken = new BBinder(); Loading