-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(page): introduce Page.Video (#958)
- Loading branch information
Showing
9 changed files
with
134 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace PlaywrightSharp | ||
{ | ||
/// <summary> | ||
/// When browser context is created with the videosPath option, each page has a video object associated with it. | ||
/// </summary> | ||
public interface IVideo | ||
{ | ||
/// <summary> | ||
/// Returns the file system path this video will be recorded to. | ||
/// The video is guaranteed to be written to the filesystem upon closing the browser context. | ||
/// </summary> | ||
/// <returns>A <see cref="Task"/> that completes when the path has been resolved.</returns> | ||
Task<string> GetPathAsync(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
namespace PlaywrightSharp.Transport.Channels | ||
{ | ||
internal class VideoEventArgs : EventArgs | ||
{ | ||
public string RelativePath { get; set; } | ||
} | ||
} |
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,22 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using PlaywrightSharp.Transport; | ||
using PlaywrightSharp.Transport.Channels; | ||
|
||
namespace PlaywrightSharp | ||
{ | ||
internal class Video : IVideo | ||
{ | ||
private readonly Page _page; | ||
private readonly TaskCompletionSource<string> _pathTask = new TaskCompletionSource<string>(); | ||
|
||
public Video(Page page) => _page = page; | ||
|
||
/// <inheritdoc/> | ||
public Task<string> GetPathAsync() => _pathTask.Task; | ||
|
||
internal void SetRelativePath(string relativePath) | ||
=> _pathTask.TrySetResult(Path.Combine(_page.BrowserContext.Options.VideosPath, relativePath)); | ||
} | ||
} |