Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 070a6a4d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix DateTimeViewTest illegal access error"

parents 292b08ff 92fcacdd
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -31,11 +31,25 @@ public class DateTimeViewTest {
    @UiThreadTest
    @Test
    public void additionalOnDetachedFromWindow_noException() {
        final DateTimeView dateTimeView = new DateTimeView(InstrumentationRegistry.getContext());
        dateTimeView.onAttachedToWindow();
        dateTimeView.onAttachedToWindow();
        final TestDateTimeView dateTimeView = new TestDateTimeView();
        dateTimeView.attachedToWindow();
        dateTimeView.detachedFromWindow();
        // Even there is an additional detach (abnormal), DateTimeView should not unregister
        // receiver again that raises "java.lang.IllegalArgumentException: Receiver not registered".
        dateTimeView.onDetachedFromWindow();
        dateTimeView.detachedFromWindow();
    }

    private static class TestDateTimeView extends DateTimeView {
        TestDateTimeView() {
            super(InstrumentationRegistry.getContext());
        }

        void attachedToWindow() {
            super.onAttachedToWindow();
        }

        void detachedFromWindow() {
            super.onDetachedFromWindow();
        }
    }
}