Skip to content

Commit

Permalink
Avoid video recording if it's not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyBelym committed Jan 21, 2019
1 parent edb2d72 commit 28de3e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/browser/provider/plugin-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default class BrowserProviderPluginHost {
}

async getVideoFrameData (browserId) {
this.reportWarning(browserId, WARNING_MESSAGE.screenshotNotSupportedByBrowserProvider, this[name]);
this.reportWarning(browserId, WARNING_MESSAGE.videoNotSupportedByBrowserProvider, this[name]);
}

async reportJobResult (/*browserId, status, data*/) {
Expand Down
1 change: 1 addition & 0 deletions src/notifications/warning-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
screenshotRewritingError: 'The file at "{screenshotPath}" already exists. It has just been rewritten with a recent screenshot. This situation can possibly cause issues. To avoid them, make sure that each screenshot has a unique path. If a test runs in multiple browsers, consider including the user agent in the screenshot path or generate a unique identifier in another way.',
browserManipulationsOnRemoteBrowser: 'The screenshot and window resize functionalities are not supported in a remote browser. They can function only if the browser is running on the same machine and in the same environment as the TestCafe server.',
screenshotNotSupportedByBrowserProvider: 'The screenshot functionality is not supported by the "{providerName}" browser provider.',
videoNotSupportedByBrowserProvider: 'The video recording functionality is not supported by the "{providerName}" browser provider.',
resizeNotSupportedByBrowserProvider: 'The window resize functionality is not supported by the "{providerName}" browser provider.',
maximizeNotSupportedByBrowserProvider: 'The window maximization functionality is not supported by the "{providerName}" browser provider.',
resizeError: 'Was unable to resize the window due to an error.\n\n{errMessage}',
Expand Down
20 changes: 18 additions & 2 deletions src/video-recorder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import makeDir from 'make-dir';
import VideoRecorderProcess from './process';
import TempDirectory from '../utils/temp-directory';
import PathPattern from '../utils/path-pattern';
import WARNING_MESSAGES from '../notifications/warning-message';


const VIDEO_EXTENSION = 'mp4';
Expand All @@ -18,6 +19,7 @@ const TEMP_MERGE_CONFIG_FILE_EXTENSION = 'txt';

export default class VideoRecorder {
constructor (browserJob, basePath, opts, encodingOpts) {
this.browserJob = browserJob;
this.basePath = basePath;
this.failedOnly = opts.failedOnly;
this.singleFile = opts.singleFile;
Expand Down Expand Up @@ -101,10 +103,18 @@ export default class VideoRecorder {
async _onTestRunCreate ({ testRun, quarantine, test, index }) {
const testRunInfo = { testRun, quarantine, test, index };

this.testRunInfo[testRun] = testRunInfo;

const connection = testRun.browserConnection;

const connectionCapabilities = await testRun.browserConnection.provider.hasCustomActionForBrowser(connection.id);

if (!connectionCapabilities || !connectionCapabilities.hasGetVideoFrameData) {
this.browserJob.warningLog.addWarning(WARNING_MESSAGES.videoNotSupportedByBrowserProvider, connection.browserInfo.providerName);

return;
}

this.testRunInfo[testRun] = testRunInfo;

testRunInfo.tempFiles = this._generateTempNames(connection.id);


Expand All @@ -116,12 +126,18 @@ export default class VideoRecorder {
async _onTestRunReady (testRun) {
const testRunInfo = this.testRunInfo[testRun];

if (!testRunInfo)
return;

await testRunInfo.videoRecorder.startCapturing();
}

async _onTestRunBeforeDone (testRun) {
const testRunInfo = this.testRunInfo[testRun];

if (!testRunInfo)
return;

delete this.testRunInfo[testRun];

await testRunInfo.videoRecorder.finishCapturing();
Expand Down

0 comments on commit 28de3e1

Please sign in to comment.