Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nativeWebScreenshot #366

Merged
merged 3 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ class EspressoDriver extends BaseDriver {
getProxyAvoidList (sessionId) {
super.getProxyAvoidList(sessionId);
this.jwpProxyAvoid = NO_PROXY;

if (this.opts.nativeWebScreenshot) {
this.jwpProxyAvoid = [...this.jwpProxyAvoid, ['GET', new RegExp('^/session/[^/]+/screenshot')]];
}

return this.jwpProxyAvoid;
}

Expand Down
28 changes: 28 additions & 0 deletions test/unit/driver-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,32 @@ describe('driver', function () {
driver.adb.setDefaultHiddenApiPolicy.calledOnce.should.be.false;
});
});

describe('#getProxyAvoidList', function () {
let driver;
describe('nativeWebScreenshot', function () {
let proxyAvoidList;
let nativeWebScreenshotFilter = (item) => item[0] === 'GET' && item[1].test('/session/xxx/screenshot/');
beforeEach(function () {
driver = new EspressoDriver({}, false);
driver.caps = { appPackage: 'io.appium.package', appActivity: '.MainActivity'};
driver.opts = { autoLaunch: false, skipUnlock: true };
driver.chromedriver = true;
sandbox.stub(driver, 'initEspressoServer');
sandbox.stub(driver, 'initAUT');
sandbox.stub(driver, 'startEspressoSession');
});

it('should proxy screenshot if nativeWebScreenshot is off on chromedriver mode', async function () {
await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: driver.caps.appPackage, nativeWebScreenshot: false});
proxyAvoidList = driver.getProxyAvoidList().filter(nativeWebScreenshotFilter);
proxyAvoidList.should.be.empty;
});
it('should not proxy screenshot if nativeWebScreenshot is on on chromedriver mode', async function () {
await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: driver.caps.appPackage, nativeWebScreenshot: true});
proxyAvoidList = driver.getProxyAvoidList().filter(nativeWebScreenshotFilter);
proxyAvoidList.should.not.be.empty;
});
});
});
});