forked from hardkoded/puppeteer-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement BrowserFetcher (hardkoded#342)
- Loading branch information
Showing
25 changed files
with
438 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/PuppeteerSharp.Tests/PuppeteerTests/BrowserFetcherTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace PuppeteerSharp.Tests.PuppeteerTests | ||
{ | ||
[Collection("PuppeteerLoaderFixture collection")] | ||
public class BrowserFetcherTests : PuppeteerBaseTest | ||
{ | ||
public BrowserFetcherTests(ITestOutputHelper output) : base(output) { } | ||
|
||
[Fact] | ||
public async Task ShouldDownloadAndExtractLinuxBinary() | ||
{ | ||
var downloadsFolder = Path.Combine(Directory.GetCurrentDirectory(), ".test-chromium"); | ||
var browserFetcher = Puppeteer.CreateBrowserFetcher(new BrowserFetcherOptions | ||
{ | ||
Platform = Platform.Linux, | ||
Path = downloadsFolder, | ||
Host = TestConstants.ServerUrl | ||
}); | ||
var revisionInfo = browserFetcher.RevisionInfo(123456); | ||
|
||
Server.SetRedirect(revisionInfo.Url.Substring(TestConstants.ServerUrl.Length), "/chromium-linux.zip"); | ||
Assert.False(revisionInfo.Local); | ||
Assert.Equal(Platform.Linux, revisionInfo.Platform); | ||
Assert.False(await browserFetcher.CanDownloadAsync(100000)); | ||
Assert.True(await browserFetcher.CanDownloadAsync(123456)); | ||
|
||
revisionInfo = await browserFetcher.DownloadAsync(123456); | ||
Assert.True(revisionInfo.Local); | ||
Assert.Equal("LINUX BINARY\n", File.ReadAllText(revisionInfo.ExecutablePath)); | ||
Assert.Equal(new[] { 123456 }, browserFetcher.LocalRevisions()); | ||
browserFetcher.Remove(123456); | ||
Assert.Empty(browserFetcher.LocalRevisions()); | ||
|
||
new DirectoryInfo(downloadsFolder).Delete(true); | ||
} | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
lib/PuppeteerSharp.Tests/PuppeteerTests/DownloaderTests.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.