public void addOnPausedListenerTest()
        {
            Debug.Log("DownloadTask addOnPausedListenerTest");

            StorageReference reference        = mAGCStorageManagement.getStorageReference(storageFileName);
            string           downloadFilePath = downloadFileFolder + "addOnPausedListenerTest.cpp";
            File             file             = new File(downloadFilePath);
            DownloadTask     task             = reference.getFile(file);

            task.addOnPausedListener(new MyPausedListener("1"))
            .addOnPausedListener(new Activity(), new MyPausedListener("2"))
            .addOnPausedListener(new MyExecutor("ExecutorListener"), new MyPausedListener("3"));

            MyPausedListener remove = new MyPausedListener("remove");

            task.addOnPausedListener(remove);
            task.removeOnPausedListener(remove);

            task.pause();
            Debug.Log("task.isPaused status: " + task.isPaused());
            Thread.Sleep(2000);
            task.resume();

            Debug.Log("after task.resume status: " + task.isPaused());

            Debug.Log("DownloadTask addOnPausedListenerTest success");
        }
        public void addOnCanceledListenerTest()
        {
            Debug.Log("DownloadTask addOnCanceledListenerTest");

            StorageReference reference        = mAGCStorageManagement.getStorageReference(storageFileName);
            string           downloadFilePath = downloadFileFolder + "addOnCanceledListenerTest.cpp";
            File             file             = new File(downloadFilePath);
            DownloadTask     task             = reference.getFile(file);


            Debug.Log("add addOnCanceledListener");
            //task.addOnCanceledListener(new MyOnCanceledListener("MyOnCanceledListener"));

            MyOnCanceledListener actitvity_listener = new MyOnCanceledListener("ActivityListener");

            task.addOnCanceledListener(new Activity(), actitvity_listener);

            MyOnCanceledListener executor_listener = new MyOnCanceledListener("ExecutorListener");

            task.addOnCanceledListener(new MyExecutor("ExecutorListener"), executor_listener);

            MyOnCanceledListener listener = new MyOnCanceledListener("NormalListener");

            task.addOnCanceledListener(listener);

            Debug.Log("remove addOnCanceledListener");
            MyOnCanceledListener remove = new MyOnCanceledListener("remoremoveve");

            task.addOnCanceledListener(new Activity(), remove);
            task.removeOnCanceledListener(remove);

            // UnityEngine.Debug.Log("cancel");
            Debug.Log("task.isCanceled status: " + task.isCanceled());
            if (!task.isCanceled())
            {
                task.pause();
                task.cancel();
            }

            Debug.Log("after cancel: task.isCanceled status: " + task.isCanceled());

            Debug.Log("UploadTask addOnCanceledListenerTest success");
        }
        public void continueWithTest()
        {
            StorageReference reference        = mAGCStorageManagement.getStorageReference(storageFileName);
            string           downloadFilePath = downloadFileFolder + "continueWithTest.cpp";
            File             file             = new File(downloadFilePath);
            DownloadTask     task             = reference.getFile(file);

            task.continueWith(new MyExecutor("continueWithTestExecutor"),
                              new MyContinuation("MyExecutor&MyContinuation"));
            task.continueWith(new MyContinuation("MyContinuation"));
            task.continueWithTask(new MyContinuation("MyContinuation&Task"));
            task.continueWithTask(new MyExecuteResult("continueWithTestExecuteResult"));
            task.continueWithTask(new MyExecutor("continueWithTestExecutor&Task"),
                                  new MyContinuation("MyExecutor&MyContinuation&Task"));

            task.onSuccessTask(new MyExecutor("onSuccessTask"), new MySuccessContinuation("onSuccessTask"));
            task.onSuccessTask(new MySuccessContinuation("onSuccessTaskSingle"));

            Debug.Log("continueWithTest Success");
        }
        public void addOnFailureListenerTest()
        {
            Debug.Log("DownloadTask addOnFailureListenerTest");

            StorageReference reference        = mAGCStorageManagement.getStorageReference(storageFileName);
            string           downloadFilePath = downloadFileFolder + "addOnFailureListenerTest.cpp";
            File             file             = new File(downloadFilePath);
            DownloadTask     task             = reference.getFile(file);

            task.addOnFailureListener(new MyFailureListener("NormalListener"))
            .addOnFailureListener(new Activity(), new MyFailureListener("ActivityListener"))
            .addOnFailureListener(new MyExecutor("ExecutorListener"), new MyFailureListener("ExecutorListener"));

            MyFailureListener remove = new MyFailureListener("remove");

            task.addOnFailureListener(remove);
            task.removeOnFailureListener(remove);

            Debug.Log("DownloadTask addOnFailureListenerTest success");
        }
        public void addOnProgressListenerTest()
        {
            Debug.Log("DownloadTask addOnProgressListenerTest");

            StorageReference reference        = mAGCStorageManagement.getStorageReference(storageFileName);
            string           downloadFilePath = downloadFileFolder + "addOnProgressListenerTest.cpp";
            File             file             = new File(downloadFilePath);
            DownloadTask     task             = reference.getFile(file);

            task.addOnProgressListener(new MyDownloadProgressListener("1"))
            .addOnProgressListener(new Activity(), new MyDownloadProgressListener("2"))
            .addOnProgressListener(new MyExecutor("addOnProgressListenerTest"),
                                   new MyDownloadProgressListener("3"));

            MyDownloadProgressListener remove = new MyDownloadProgressListener("remove");

            task.addOnProgressListener(remove);
            task.removeOnProgressListener(remove);

            bool isInProgress = task.isInProgress();

            Debug.Log("DownloadTask addOnProgressListenerTest success, is InProgress status: " + isInProgress);
        }
        private void downloadTest()
        {
            Debug.Log("downloadTest start");
            StorageReference reference = mAGCStorageManagement.getStorageReference(storageFileName);

            Debug.Log("getStorageReference end");
            string downloadFilePath = downloadFileFolder + "downloadTest.cpp";

            Debug.Log("downloadFilePath: " + downloadFilePath);
            File file = new File(downloadFilePath);

            try
            {
                DownloadTask task = reference.getFile(file);
                if (task == null)
                {
                    Debug.Log("downloadTask is null");
                }
                else
                {
                    Debug.Log("downloadTask is not null");
                    StorageTask.ErrorResult err = new MyErrorResult();
                    Exception e = err.getError();

                    task.setResult(err.obj);
                    err = task.getResult();
                    if (err == null)
                    {
                        Debug.Log("downloadFileTest fail, getResult err is null.");
                        return;
                    }

                    StorageTask.ErrorResult timePointState = task.getTimePointState();
                    if (timePointState == null)
                    {
                        Debug.Log("downloadFileTest fail, getTimePointState result is null.");
                        return;
                    }

                    Exception exp = task.getException();
                    if (exp == null)
                    {
                        Debug.Log("downloadFileTest fail, getException result is null.");
                        return;
                    }

                    task.setException(exp);

                    AndroidJavaObject ajObj = task.getResultThrowException(new AndroidJavaClass("java.lang.Exception"));
                    if (ajObj == null)
                    {
                        Debug.Log("downloadFileTest fail, getException result is null.");
                        return;
                    }

                    Debug.Log("downloadTest Success");
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e);
            }
        }
        private void storageReferenceTest()
        {
            initAGCStorageManagement();

            StorageReference     reference = mAGCStorageManagement.getStorageReference("storageReferenceTest.data");
            AGCStorageManagement storage   = reference.getStorage();

            if (storage == null)
            {
                Debug.Log("storageReferenceTest fail: storage is null");
                return;
            }

            StorageReference child = reference.child("/");

            if (child == null)
            {
                Debug.Log("storageReferenceTest fail: child is null");
                return;
            }

            StorageReference parent = reference.getParent();

            if (parent == null)
            {
                Debug.Log("storageReferenceTest fail: parent is null");
                return;
            }

            StorageReference root = reference.getRoot();

            if (root == null)
            {
                Debug.Log("storageReferenceTest fail: root is null");
                return;
            }

            Task updateTask = reference.updateFileMetadata(new FileMetadata());

            if (updateTask == null)
            {
                Debug.Log("storageReferenceTest fail: updateTask is null");
                return;
            }

            Task task = reference.getFileMetadata();

            if (task == null)
            {
                Debug.Log("storageReferenceTest fail: task is null");
                return;
            }

            Task listTask = reference.list(1);

            if (listTask == null)
            {
                Debug.Log("storageReferenceTest fail: listTask is null");
                return;
            }

            Task listTaskSec = reference.list(1, "1");

            if (listTaskSec == null)
            {
                Debug.Log("storageReferenceTest fail: listTaskSec is null");
                return;
            }

            Task listAll = reference.listAll();

            if (listAll == null)
            {
                Debug.Log("storageReferenceTest fail: listAll is null");
                return;
            }

            StreamDownloadTask stream = reference.getStream();

            if (stream == null)
            {
                Debug.Log("storageReferenceTest fail: stream is null");
                return;
            }

            StreamDownloadTask streamSecond = reference.getStream(new MyStreamHandler());

            if (streamSecond == null)
            {
                Debug.Log("storageReferenceTest fail: streamSecond is null");
                return;
            }

            Task getByteTask = reference.getBytes(10);

            if (getByteTask == null)
            {
                Debug.Log("storageReferenceTest fail: getByteTask is null");
                return;
            }

            Task downloadUrl = reference.getDownloadUrl();

            if (downloadUrl == null)
            {
                Debug.Log("storageReferenceTest fail: downloadUrl is null");
                return;
            }

            List activeUploadList = reference.getActiveUploadTasks();

            if (activeUploadList == null)
            {
                Debug.Log("storageReferenceTest fail: activeUploadList is null");
                return;
            }

            List activeDownloadList = reference.getActiveDownloadTasks();

            if (activeDownloadList == null)
            {
                Debug.Log("storageReferenceTest fail: activeDownloadList is null");
                return;
            }


            StorageReference ref_1       = mAGCStorageManagement.getStorageReference("putFileTest_1.data");
            UploadTask       uploadFirst = ref_1.putFile(new File("empty_first"));

            Debug.Log("putFileTest_1 success");

            StorageReference ref_2        = mAGCStorageManagement.getStorageReference("putFileTest_2.data");
            UploadTask       uploadSecond = ref_2.putFile(new File("empty_second"), new FileMetadata(), new Long(0));

            Debug.Log("putFileTest_2 success");

            StorageReference ref_3       = mAGCStorageManagement.getStorageReference("putFileTest_3.data");
            UploadTask       uploadThird = ref_3.putFile(new File("empty_third"), new FileMetadata());

            Debug.Log("putFileTest_3 success");


            StorageReference ref_4    = mAGCStorageManagement.getStorageReference("putFileTest_4.data");
            FileMetadata     metadata = new FileMetadata();

            metadata.setSHA256Hash("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
            UploadTask byteFirst = ref_4.putBytes(new byte[100], metadata, new Long(0));

            Debug.Log("putFileTest_4 success");

            DownloadTask downloadFirst = reference.getFile(new File("download_first.data"));

            Debug.Log("download_first success");
            Uri myUri = Uri.parse("content://downloads/public_downloads");

            if (myUri == null)
            {
                Debug.Log("Uri parse fail");
            }
            else
            {
                Debug.Log("Uri parse success");
                DownloadTask downloadSecond = reference.getFile(myUri);
            }

            string bucket    = reference.getBucket();
            string name      = reference.getName();
            string path      = reference.getPath();
            int    compareTo = reference.compareTo(ref_3);
            string toString  = reference.toString();

            Long myObject = new Long(10);
            bool equal    = reference.equals(myObject.obj);
            int  hashcode = reference.hashCode();

            Task deleteTask = reference.delete();

            if (deleteTask == null)
            {
                Debug.Log("storageReferenceTest fail: deleteTask is null");
                return;
            }

            Debug.Log("storageReferenceTest success. bucket: " + bucket +
                      ", name: " + name +
                      ", path: " + path +
                      ", compareTo: " + compareTo +
                      ", toString: " + toString +
                      ", equal: " + equal +
                      ", hashcode: " + hashcode);
        }