diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-12 16:33:27 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-12 16:33:27 -0600 |
| commit | 29b59441a4bbada64d8d07bd2609f15dfde670e5 (patch) | |
| tree | 3b3583edb261279cfcdfd9eed904d118c4bf67b1 /vendor/github.com/playwright-community/playwright-go/video.go | |
| parent | 78ccd9a4312eab7e11da4413733a12953f88a4fe (diff) | |
test: remove UI tests
Diffstat (limited to 'vendor/github.com/playwright-community/playwright-go/video.go')
| -rw-r--r-- | vendor/github.com/playwright-community/playwright-go/video.go | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/vendor/github.com/playwright-community/playwright-go/video.go b/vendor/github.com/playwright-community/playwright-go/video.go deleted file mode 100644 index a57b61a..0000000 --- a/vendor/github.com/playwright-community/playwright-go/video.go +++ /dev/null @@ -1,97 +0,0 @@ -package playwright - -import ( - "errors" - "sync" -) - -type videoImpl struct { - page *pageImpl - artifact *artifactImpl - artifactChan chan *artifactImpl - done chan struct{} - closeOnce sync.Once - isRemote bool -} - -func (v *videoImpl) Path() (string, error) { - if v.isRemote { - return "", errors.New("Path is not available when connecting remotely. Use SaveAs() to save a local copy.") - } - v.getArtifact() - if v.artifact == nil { - return "", errors.New("Page did not produce any video frames") - } - return v.artifact.AbsolutePath(), nil -} - -func (v *videoImpl) Delete() error { - v.getArtifact() - if v.artifact == nil { - return nil - } - return v.artifact.Delete() -} - -func (v *videoImpl) SaveAs(path string) error { - if !v.page.IsClosed() { - return errors.New("Page is not yet closed. Close the page prior to calling SaveAs") - } - v.getArtifact() - if v.artifact == nil { - return errors.New("Page did not produce any video frames") - } - return v.artifact.SaveAs(path) -} - -func (v *videoImpl) artifactReady(artifact *artifactImpl) { - v.artifactChan <- artifact -} - -func (v *videoImpl) pageClosed(p Page) { - v.closeOnce.Do(func() { - close(v.done) - }) -} - -func (v *videoImpl) getArtifact() { - // prevent channel block if no video will be produced - if v.page.browserContext.options == nil { - v.pageClosed(v.page) - } else { - option := v.page.browserContext.options - if option == nil || option.RecordVideo == nil { // no recordVideo option - v.pageClosed(v.page) - } - } - select { - case artifact := <-v.artifactChan: - if artifact != nil { - v.artifact = artifact - } - case <-v.done: // page closed - select { // make sure get artifact if it's ready before page closed - case artifact := <-v.artifactChan: - if artifact != nil { - v.artifact = artifact - } - default: - } - } -} - -func newVideo(page *pageImpl) *videoImpl { - video := &videoImpl{ - page: page, - artifactChan: make(chan *artifactImpl, 1), - done: make(chan struct{}, 1), - isRemote: page.connection.isRemote, - } - - if page.isClosed { - video.pageClosed(page) - } else { - page.OnClose(video.pageClosed) - } - return video -} |
