Skip to content

Commit

Permalink
Add proxy helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Nov 3, 2015
1 parent 4682bfd commit c02bd14
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
20 changes: 20 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AndroidDriver extends BaseDriver {
this.desiredCapConstraints = desiredConstraints;
this.curContext = this.defaultContextName();
this.sessionChromedrivers = {};
this.jwpProxyActive = false;
this.jwpProxyAvoid = NO_PROXY;
this.settings = new DeviceSettings({ignoreUnimportantViews: false},
this.onSettingsUpdate.bind(this));
Expand Down Expand Up @@ -269,6 +270,25 @@ class AndroidDriver extends BaseDriver {
log.errorAndThrow(msg);
}
}

proxyActive (sessionId) {
super.proxyActive(sessionId);

return this.jwpProxyActive;
}

getProxyAvoidList (sessionId) {
super.getProxyAvoidList(sessionId);

return this.jwpProxyAvoid;
}

canProxy (sessionId) {
super.canProxy(sessionId);

// this will change depending on ChromeDriver status
return _.isFunction(this.proxyReqRes);
}
}

for (let [cmd, fn] of _.pairs(commands)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"appium-adb": "^2.0.1",
"appium-android-bootstrap": "^2.2.2",
"appium-android-ime": "^2.0.0",
"appium-base-driver": "^1.0.2",
"appium-base-driver": "^1.1.0",
"appium-chromedriver": "^2.5.0",
"appium-express": "^1.0.0",
"appium-logger": "^2.0.0",
Expand Down
44 changes: 44 additions & 0 deletions test/unit/driver-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,48 @@ describe('driver', () => {
}).to.throw(/should not include both/);
});
});

describe('proxying', () => {
before(() => {
driver = new AndroidDriver();
driver.sessionId = 'abc';
});
describe('#proxyActive', () => {
it('should exist', () => {
driver.proxyActive.should.be.an.instanceof(Function);
});
it('should return false', () => {
driver.proxyActive('abc').should.be.false;
});
it('should throw an error if session id is wrong', () => {
(() => { driver.proxyActive('aaa'); }).should.throw;
});
});

describe('#getProxyAvoidList', () => {
it('should exist', () => {
driver.getProxyAvoidList.should.be.an.instanceof(Function);
});
it('should return jwpProxyAvoid array', () => {
let avoidList = driver.getProxyAvoidList('abc');
avoidList.should.be.an.instanceof(Array);
avoidList.should.eql(driver.jwpProxyAvoid);
});
it('should throw an error if session id is wrong', () => {
(() => { driver.getProxyAvoidList('aaa'); }).should.throw;
});
});

describe('#canProxy', () => {
it('should exist', () => {
driver.canProxy.should.be.an.instanceof(Function);
});
it('should return false', () => {
driver.canProxy('abc').should.be.false;
});
it('should throw an error if session id is wrong', () => {
(() => { driver.canProxy('aaa'); }).should.throw;
});
});
});
});

0 comments on commit c02bd14

Please sign in to comment.