// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogSupportFragment.java
// public class SimpleAlertDialogSupportFragment extends DialogFragment {
// 
//     /**
//      * Default constructor.
//      */
//     public SimpleAlertDialogSupportFragment() {
//     }
// 
//     @Override
//     public Dialog onCreateDialog(Bundle savedInstanceState) {
//         Bundle args = getArguments();
//         // Cancelable must be set to DialogFragment
//         if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
//             setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
//         }
//         return new InternalHelper<Fragment, FragmentActivity>() {
//             public FragmentActivity getActivity() {
//                 return SimpleAlertDialogSupportFragment.this.getActivity();
//             }
// 
//             public Fragment getTargetFragment() {
//                 return SimpleAlertDialogSupportFragment.this.getTargetFragment();
//             }
//         }.createDialog(args);
//     }
// 
//     @Override
//     public void onCancel(DialogInterface dialog) {
//         super.onCancel(dialog);
//         int requestCode = 0;
//         Bundle args = getArguments();
//         if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
//             requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
//         }
//         Fragment targetFragment = getTargetFragment();
//         if (targetFragment != null
//                 && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
//             ((SimpleAlertDialog.OnCancelListener) targetFragment)
//                     .onDialogCancel((SimpleAlertDialog) dialog,
//                             requestCode,
//                             ((SimpleAlertDialog) dialog).getView());
//         }
//         if (getActivity() != null
//                 && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
//             ((SimpleAlertDialog.OnCancelListener) getActivity())
//                     .onDialogCancel((SimpleAlertDialog) dialog,
//                             requestCode,
//                             ((SimpleAlertDialog) dialog).getView());
//         }
//     }
// 
//     /**
//      * Dialog builder for {@code android.support.v4.app.Fragment}.
//      * <p/>
//      * {@inheritDoc}
//      */
//     public static class Builder extends
//             SimpleAlertDialog.Builder<SimpleAlertDialogSupportFragment, Fragment> {
//         private Fragment mTargetFragment;
// 
//         @Override
//         public Builder setTargetFragment(final Fragment targetFragment) {
//             mTargetFragment = targetFragment;
//             return this;
//         }
// 
//         @Override
//         public SimpleAlertDialogSupportFragment create() {
//             Bundle args = createArguments();
//             SimpleAlertDialogSupportFragment fragment = new SimpleAlertDialogSupportFragment();
//             fragment.setArguments(args);
//             if (mTargetFragment != null) {
//                 fragment.setTargetFragment(mTargetFragment, 0);
//             }
//             return fragment;
//         }
//     }
// 
// }


import android.annotation.TargetApi;
import android.app.Dialog;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogSupportFragment;
                negative.performClick();
            }
        });
        getInstrumentation().waitForIdleSync();
    }

    public void test3Buttons() throws Throwable {
        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                activity.findViewById(R.id.btn_3_buttons).performClick();
                activity.getSupportFragmentManager().executePendingTransactions();
            }
        });
        getInstrumentation().waitForIdleSync();
        Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
        assertNotNull(f);
        Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
        assertNotNull(d);
        View positive = d.findViewById(R.id.button_positive);
        assertNotNull(positive);
        final View negative = d.findViewById(R.id.button_negative);
        assertNotNull(negative);
        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                negative.performClick();
            }
        });

// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogSupportFragment.java
// public class SimpleAlertDialogSupportFragment extends DialogFragment {
// 
//     /**
//      * Default constructor.
//      */
//     public SimpleAlertDialogSupportFragment() {
//     }
// 
//     @Override
//     public Dialog onCreateDialog(Bundle savedInstanceState) {
//         Bundle args = getArguments();
//         // Cancelable must be set to DialogFragment
//         if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
//             setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
//         }
//         return new InternalHelper<Fragment, FragmentActivity>() {
//             public FragmentActivity getActivity() {
//                 return SimpleAlertDialogSupportFragment.this.getActivity();
//             }
// 
//             public Fragment getTargetFragment() {
//                 return SimpleAlertDialogSupportFragment.this.getTargetFragment();
//             }
//         }.createDialog(args);
//     }
// 
//     @Override
//     public void onCancel(DialogInterface dialog) {
//         super.onCancel(dialog);
//         int requestCode = 0;
//         Bundle args = getArguments();
//         if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
//             requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
//         }
//         Fragment targetFragment = getTargetFragment();
//         if (targetFragment != null
//                 && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
//             ((SimpleAlertDialog.OnCancelListener) targetFragment)
//                     .onDialogCancel((SimpleAlertDialog) dialog,
//                             requestCode,
//                             ((SimpleAlertDialog) dialog).getView());
//         }
//         if (getActivity() != null
//                 && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
//             ((SimpleAlertDialog.OnCancelListener) getActivity())
//                     .onDialogCancel((SimpleAlertDialog) dialog,
//                             requestCode,
//                             ((SimpleAlertDialog) dialog).getView());
//         }
//     }
// 
//     /**
//      * Dialog builder for {@code android.support.v4.app.Fragment}.
//      * <p/>
//      * {@inheritDoc}
//      */
//     public static class Builder extends
//             SimpleAlertDialog.Builder<SimpleAlertDialogSupportFragment, Fragment> {
//         private Fragment mTargetFragment;
// 
//         @Override
//         public Builder setTargetFragment(final Fragment targetFragment) {
//             mTargetFragment = targetFragment;
//             return this;
//         }
// 
//         @Override
//         public SimpleAlertDialogSupportFragment create() {
//             Bundle args = createArguments();
//             SimpleAlertDialogSupportFragment fragment = new SimpleAlertDialogSupportFragment();
//             fragment.setArguments(args);
//             if (mTargetFragment != null) {
//                 fragment.setTargetFragment(mTargetFragment, 0);
//             }
//             return fragment;
//         }
//     }
// 
// }


// Path: simplealertdialog-tests/src/com/simplealertdialog/test/SupportActivityTest.java
import android.annotation.TargetApi;
import android.app.Dialog;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogSupportFragment;

                negative.performClick();
            }
        });
        getInstrumentation().waitForIdleSync();
    }

    public void test3Buttons() throws Throwable {
        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                activity.findViewById(R.id.btn_3_buttons).performClick();
                activity.getSupportFragmentManager().executePendingTransactions();
            }
        });
        getInstrumentation().waitForIdleSync();
        Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
        assertNotNull(f);
        Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
        assertNotNull(d);
        View positive = d.findViewById(R.id.button_positive);
        assertNotNull(positive);
        final View negative = d.findViewById(R.id.button_negative);
        assertNotNull(negative);
        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                negative.performClick();
            }
        });

        getInstrumentation().waitForIdleSync();