fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.java
@Test
    public void sharedDuplicateTargetNames() throws Throwable {
        setupInitialFragment();

        final View startBlue = findBlue();
        final View startGreen = findGreen();

        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.addSharedElement(startBlue, "blueSquare");
        try {
            ft.addSharedElement(startGreen, "blueSquare");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected
        }

        try {
            ft.addSharedElement(startBlue, "greenSquare");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected
        }
    }
// Ensure that using the same source or target shared element results in an exception.
Ensure that using the same source or target shared element results in an exception.
Ensure that using the same source or target shared element results in an exception .
@Test
    public void sharedDuplicateTargetNames() throws Throwable {
        setupInitialFragment();
        final View startBlue = findBlue();
        final View startGreen = findGreen();
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.addSharedElement(startBlue, "blueSquare");
        try {
            ft.addSharedElement(startGreen, "blueSquare");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }
        try {
            ft.addSharedElement(startBlue, "greenSquare");
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }
    }
@ Test public void sharedDuplicateTargetNames ( ) throws Throwable { setupInitialFragment ( ) ; final View startBlue = findBlue ( ) ; final View startGreen = findGreen ( ) ; FragmentTransaction ft = mFragmentManager . beginTransaction ( ) ; ft . addSharedElement ( startBlue , "blueSquare" ) ; try { ft . addSharedElement ( startGreen , "blueSquare" ) ; fail ( "Expected IllegalArgumentException" ) ; } catch ( IllegalArgumentException e ) { } try { ft . addSharedElement ( startBlue , "greenSquare" ) ; fail ( "Expected IllegalArgumentException" ) ; } catch ( IllegalArgumentException e ) { } }
Ensure that using the same source or target shared element results in an exception.
Ensure that using the same source or target shared element results in an exception .
// expected // expected