// Path: app/src/androidTest/java/com/kevalpatel2106/smartlens/testUtils/BaseTestClass.java
// public abstract class BaseTestClass {
// 
// //    /**
// //     * Gran all the runtime permissions.
// //     * Update it when you add new permission in manifest.
// //     */
// //    @BeforeClass
// //    public static void grantAllRuntimePermission() {
// //        // In M+, trying to call a number will trigger a runtime dialog. Make sure
// //        // the permission is granted before running this test.
// //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.CAMERA");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.SYSTEM_ALERT_WINDOW");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.WRITE_EXTERNAL_STORAGE");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.WRITE_SETTINGS");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.ACCESS_COARSE_LOCATION");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.ACCESS_FINE_LOCATION");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.SEND_SMS");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.READ_CONTACTS");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.PROCESS_OUTGOING_CALLS");
// //        }
// //    }
// 
//     public abstract Activity getActivity();
// 
//     @Before
//     public void setup() {
//         // Unlock the screen if it's locked
//         UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
//         try {
//             device.wakeUp();
//         } catch (RemoteException e) {
//             e.printStackTrace();
//         }
// 
//         // Set the flags on our activity so it'll appear regardless of lock screen state
//         new Handler(Looper.getMainLooper()).post(() -> {
//             if (getActivity() == null) return;
//             getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
//                     WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
//                     WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//         });
//     }
// }


import org.junit.Test;
import org.junit.runner.RunWith;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import com.kevalpatel2106.smartlens.R;
import com.kevalpatel2106.smartlens.testUtils.BaseTestClass;
import org.junit.Before;
    }


    /**
     * Check if we can cancel the cancel the notification? For that we will first create the notification
     * using {@link #checkNotificationDisplayed()}. Than we will cancel the notification.
     *
     * @see <a href="https://stackoverflow.com/a/33515200/4690731">https://stackoverflow.com/a/33515200/4690731</a>
     */
    @Test
    public void checkIfNotificationCanceled() throws UiObjectNotFoundException {
        //Fire the notification
        ModelDownloadingNotification.notify(InstrumentationRegistry.getTargetContext(),
                0, true);

        /*
         * access Notification Center through resource id, package name, class name.
         * if you want to check resource id, package name or class name of the specific view
         * in the screen, run 'uiautomatorviewer' from command.
         */
        UiSelector notificationStackScroller = new UiSelector()
                .packageName("com.android.systemui")
                .className("android.view.ViewGroup")
                .resourceId("com.android.systemui:id/notification_stack_scroller");
        UiObject notificationStackScrollerUiObject = mDevice.findObject(notificationStackScroller);
        assertTrue(notificationStackScrollerUiObject.exists());

        /*
         * access top notification in the center through parent
         */
// Path: app/src/androidTest/java/com/kevalpatel2106/smartlens/testUtils/BaseTestClass.java
// public abstract class BaseTestClass {
// 
// //    /**
// //     * Gran all the runtime permissions.
// //     * Update it when you add new permission in manifest.
// //     */
// //    @BeforeClass
// //    public static void grantAllRuntimePermission() {
// //        // In M+, trying to call a number will trigger a runtime dialog. Make sure
// //        // the permission is granted before running this test.
// //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.CAMERA");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.SYSTEM_ALERT_WINDOW");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.WRITE_EXTERNAL_STORAGE");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.WRITE_SETTINGS");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.ACCESS_COARSE_LOCATION");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.ACCESS_FINE_LOCATION");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.SEND_SMS");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.READ_CONTACTS");
// //            getInstrumentation().getUiAutomation().executeShellCommand("pm grant " + getTargetContext().getPackageName() + " android.permission.PROCESS_OUTGOING_CALLS");
// //        }
// //    }
// 
//     public abstract Activity getActivity();
// 
//     @Before
//     public void setup() {
//         // Unlock the screen if it's locked
//         UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
//         try {
//             device.wakeUp();
//         } catch (RemoteException e) {
//             e.printStackTrace();
//         }
// 
//         // Set the flags on our activity so it'll appear regardless of lock screen state
//         new Handler(Looper.getMainLooper()).post(() -> {
//             if (getActivity() == null) return;
//             getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
//                     WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
//                     WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//         });
//     }
// }


// Path: app/src/androidTest/java/com/kevalpatel2106/smartlens/downloader/ModelDownloadingNotificationTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import com.kevalpatel2106.smartlens.R;
import com.kevalpatel2106.smartlens.testUtils.BaseTestClass;
import org.junit.Before;

    }


    /**
     * Check if we can cancel the cancel the notification? For that we will first create the notification
     * using {@link #checkNotificationDisplayed()}. Than we will cancel the notification.
     *
     * @see <a href="https://stackoverflow.com/a/33515200/4690731">https://stackoverflow.com/a/33515200/4690731</a>
     */
    @Test
    public void checkIfNotificationCanceled() throws UiObjectNotFoundException {
        //Fire the notification
        ModelDownloadingNotification.notify(InstrumentationRegistry.getTargetContext(),
                0, true);

        /*
         * access Notification Center through resource id, package name, class name.
         * if you want to check resource id, package name or class name of the specific view
         * in the screen, run 'uiautomatorviewer' from command.
         */
        UiSelector notificationStackScroller = new UiSelector()
                .packageName("com.android.systemui")
                .className("android.view.ViewGroup")
                .resourceId("com.android.systemui:id/notification_stack_scroller");
        UiObject notificationStackScrollerUiObject = mDevice.findObject(notificationStackScroller);
        assertTrue(notificationStackScrollerUiObject.exists());

        /*
         * access top notification in the center through parent
         */
        UiObject notiSelectorUiObject = notificationStackScrollerUiObject.getChild(new UiSelector()