public void Title_WithoutCallingSetTitle_ReturnsDefaultTitle() { var url = @"https://www.google.com/test"; var options = new BackgroundDownloadOptions(url); Assert.AreEqual(Application.productName, options.Title); }
public void DestinationPath_AfterSettingToEmpty_ReturnsDefaultPath() { var url = @"https://www.google.com/myTestAssetBundle.bin"; var options = new BackgroundDownloadOptions(url).SetDestinationPath(string.Empty); Assert.AreEqual(Path.Combine(BackgroundDownloadOptions.DEFAULT_DOWNLOAD_PATH, "myTestAssetBundle.bin"), options.DestinationPath); }
public void Title_AfterCallingSetTitle_ReturnsSetTitle() { var url = @"https://www.google.com/test"; var options = new BackgroundDownloadOptions(url).SetTitle("My Title"); Assert.AreEqual("My Title", options.Title); }
public void URL_AfterConstructingWithURL_ReturnsCorrectURL() { var url = @"https://www.google.com/test"; var options = new BackgroundDownloadOptions(url); Assert.AreEqual(url, options.URL); }
public void DestinationPath_WithoutCallingSetDestination_ReturnsDefaultPath() { var url = @"https://www.google.com/myTestAssetBundle.bin"; var options = new BackgroundDownloadOptions(url); Assert.AreEqual(Path.Combine(BackgroundDownloadOptions.DEFAULT_DOWNLOAD_PATH, "myTestAssetBundle.bin"), options.DestinationPath); }
public AndroidDownloadOperation(AndroidDownloader downloader, BackgroundDownloadOptions options, long id) : base(options) { this.id = id; cachedStatus = new Cached <DownloadStatus>(() => downloader.GetStatus(id)); cachedProgress = new Cached <float>(() => downloader.GetProgress(id)); }
public void StartDownload_CalledWithOptions_CorrectDestinationPath() { string url = @"https://www.google.com/test.bundle"; var options = new BackgroundDownloadOptions(url); var op = BackgroundDownloads.StartDownload(options); Assert.AreEqual(Path.Combine(BackgroundDownloadOptions.DEFAULT_DOWNLOAD_PATH, "test.bundle"), op.DestinationPath); }
public void StartDownload_CalledWithOptions_ReturnsOperation() { string url = @"https://www.google.com"; var options = new BackgroundDownloadOptions(url); var op = BackgroundDownloads.StartDownload(options); Assert.That(op.ID != -1, "DownloadOperation.ID should not be -1!"); }
/// <summary> /// Starts a download with the given download configuration options. /// </summary> public static DownloadOperation StartDownload(BackgroundDownloadOptions options) { Profiler.BeginSample(string.Format("StartDownload (options): {0}", options.URL)); var op = Downloader.StartDownload(options); Profiler.EndSample(); return(op); }
public void DestinationPath_AfterSettingToEmpty_ReturnsPreviouslySetPath() { var url = @"https://www.google.com/myTestAssetBundle.bin"; var destinationPath = Path.Combine("D:", "MyCache"); var options = new BackgroundDownloadOptions(url).SetDestinationPath(destinationPath).SetDestinationPath(string.Empty); var expectedPath = Path.Combine(destinationPath, "myTestAssetBundle.bin"); Assert.AreEqual(expectedPath, options.DestinationPath); }
public void DestinationPath_AfterCallingSetDestination_ReturnsCorrectPath() { var url = @"https://www.google.com/myTestAssetBundle.bin"; var destinationPath = Path.Combine("D:", "MyCache"); var options = new BackgroundDownloadOptions(url).SetDestinationPath(destinationPath); var expectedPath = Path.Combine(destinationPath, "myTestAssetBundle.bin"); Assert.AreEqual(expectedPath, options.DestinationPath); }
public DownloadOperation StartDownload(BackgroundDownloadOptions options) { // Use the destination path stored in the 'options' instance. // On iOS, for init we only need the directory name, not the full path (including file name). //iOSDownloaderNative.init(Path.GetDirectoryName(options.DestinationPath)); var id = iOSDownloaderNative.startDownload(options.URL, options.DestinationPath); var op = new iOSDownloadOperation(this, id, options.URL); return(op); }
/// <summary> /// Starts a download with the given download configuration options. /// </summary> public static DownloadOperation StartDownload(BackgroundDownloadOptions options) { Profiler.BeginSample(string.Format("StartDownload (options): {0}", options.URL)); var op = Downloader.StartDownload(options); Profiler.EndSample(); Debug.Log("开始下载:" + options.URL + " " + options.DestinationPath); return(op); }
/// <summary> /// Starts or continues tracking an ongoing download. /// If the download is not running yet, it will be started with the given download configuration options. /// </summary> /// <returns>A <see cref="DownloadOperation"/> instance that tracks the download of the given URL</returns> public static DownloadOperation StartOrContinueDownload(BackgroundDownloadOptions options) { var op = GetDownloadOperation(options.URL); if (op == null || op.ID == DOWNLOAD_ERROR_ID) { Debug.LogError("no download was found for: " + options.URL); op = StartDownload(options); } return(op); }
public void StartDownload_OptionsWithCustomDestinationPath_CorrectDestinationPath() { string url = @"https://www.google.com/test.bundle"; var destinationPath = Path.Combine("D:", "MyPath"); var options = new BackgroundDownloadOptions(url).SetDestinationPath(destinationPath); var op = BackgroundDownloads.StartDownload(options); var expectedPath = Path.Combine(destinationPath, "test.bundle"); Assert.AreEqual(expectedPath, op.DestinationPath); }
public DownloadOperation StartDownload(BackgroundDownloadOptions options) { try { var id = AndroidBridge.CallStatic <long>("download", Context, options.URL, options.DestinationPath, options.Title, options.Description); return(new AndroidDownloadOperation(this, options, id)); } catch (Exception e) { Debug.LogException(e); } return(null); }
public void StoragePermission(string s) { downloadOperation = BackgroundDownloads.GetDownloadOperation("https://qianxi.fahaxiki.cn/AB/OnlineAB/AF-ABForServer/APPInfo.txt"); BackgroundDownloadOptions backgroundDownloadOptions = new BackgroundDownloadOptions("https://qianxi.fahaxiki.cn/AB/OnlineAB/AF-ABForServer/APPInfo.txt", PathTool.PersistentDataPath + "APPInfo.txt"); if (downloadOperation == null || (downloadOperation != null && downloadOperation.Status == DownloadStatus.Successful)) { downloadOperation = BackgroundDownloads.StartDownload(backgroundDownloadOptions); } else if (downloadOperation != null && downloadOperation.Status != DownloadStatus.Successful) { //断点续存 downloadOperation = BackgroundDownloads.StartOrContinueDownload(backgroundDownloadOptions); } Debug.Log("downloadOperation是否为空:" + (downloadOperation == null)); }
/// <summary> /// 下载完成 /// </summary> public void DownloadComplete() { switch (downloadOperation.Status) { case DownloadStatus.Failed: //下载失败 LastPro = CurPro; if (WebRequestCount <= 3) { DownManager.Instance.DebugDownError(WebRequestCount, httpInfo.m_srcUrl, downloadOperation.Error); WebRequestCount += 1; CancelDownload(); BackgroundDownloadOptions backgroundDownloadOptions = new BackgroundDownloadOptions(httpInfo.m_srcUrl, m_saveFilePath); downloadOperation = BackgroundDownloads.StartDownload(backgroundDownloadOptions); } else { DownManager.Instance.RemoveAndFinish(httpInfo.m_srcUrl); CancelDownload(); downResult = DownStatus.Fail; downError = downloadOperation.Error; httpInfo.processEvent.InvokeGracefully(httpInfo, CurPro, true, downResult, downError); m_isStartDownload = false; DownloadFinish(); } break; case DownloadStatus.Successful: //下载成功 //AFLogger.d("下载完成:" + downloadOperation.DestinationPath); //AFLogger.d("下载完成后是否存在路径:" + m_saveFilePath + " " + FileHelper.JudgeFilePathExit(m_saveFilePath)); CurPro = 1; LastPro = CurPro; DownManager.Instance.RemoveAndFinish(httpInfo.m_srcUrl); downResult = DownStatus.Sucess; downError = ""; m_isStartDownload = false; DownloadFinish(); httpInfo.processEvent.InvokeGracefully(httpInfo, CurPro, true, downResult, downError); break; } }
public void StartWebRequest() { WebRequestCount = 1; if (string.IsNullOrEmpty(httpInfo.m_srcUrl)) { downResult = DownStatus.Fail; downError = "下载地址为空"; DownloadFinish(); return; } if (string.IsNullOrEmpty(httpInfo.m_savePath)) { downResult = DownStatus.Fail; downError = "保存地址为空"; DownloadFinish(); return; } m_saveFilePath = httpInfo.m_savePath; if (WebRequestCount == 1) { LastPro = GetProcess(); } FileHelper.DeleteFile(m_saveFilePath); downloadOperation = BackgroundDownloads.GetDownloadOperation(httpInfo.m_srcUrl); BackgroundDownloadOptions backgroundDownloadOptions = new BackgroundDownloadOptions(httpInfo.m_srcUrl, m_saveFilePath); if (downloadOperation == null || (downloadOperation != null && downloadOperation.Status != DownloadStatus.Paused)) { downloadOperation = BackgroundDownloads.StartDownload(backgroundDownloadOptions); } else if (downloadOperation != null && downloadOperation.Status == DownloadStatus.Paused) { //断点续存 downloadOperation = BackgroundDownloads.StartOrContinueDownload(backgroundDownloadOptions); } m_isStartDownload = true; }
public DownloadOperation StartDownload(string url) { var options = new BackgroundDownloadOptions(url); return(StartDownload(options)); }
public DownloadOperation StartDownload(BackgroundDownloadOptions options) { return(new EditorDownloadOperation(options)); }
/// <summary> /// Initializes a new instance of the <see cref="DownloadOperation"/> class. /// </summary> /// <param name="options">Options.</param> public DownloadOperation(BackgroundDownloadOptions options) { this.options = options; }
public EditorDownloadOperation(BackgroundDownloadOptions options) : base(options) { request = new WWW(options.URL); }