Skip to content

Commit

Permalink
Fix for appium#3325. localizableStrings is no longer an array
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeff committed Aug 7, 2014
1 parent e082371 commit 84197da
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 36 deletions.
4 changes: 2 additions & 2 deletions lib/devices/ios/ios-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ iOSController.getLocalizedStringForSelector = function (selector) {
var newSelector = selector;

var strings = this.localizableStrings;
if (strings && strings.length >= 1) {
var localizedSelector = strings[0][selector];
if (strings) {
var localizedSelector = strings[selector];
if (localizedSelector) {
newSelector = localizedSelector;
} else {
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion test/unit/ios-controller-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('ios-controller', function () {
});
describe('when there are localizableStrings', function () {
beforeEach(function () {
var locString = [{'someSelector': 'localSelector'}];
var locString = {'someSelector': 'localSelector'};
controller.localizableStrings = locString;
});
afterEach(function () {
Expand Down
66 changes: 66 additions & 0 deletions test/unit/ios-device-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Run with mocha by installing dev deps: npm install --dev
// more docs on writing tests with mocha can be found here:
// http://visionmedia.github.com/mocha/
"use strict";

require('chai');

var path = require('path')
, _ = require('underscore')
, IOS = require('../../lib/devices/ios/ios.js');

describe('IOS', function () {
var device;

beforeEach(function () {
device = new IOS();
});

describe('#proxy()', function () {
beforeEach(function () {
// we'd like to test ios.proxy; mock instruments
device.commandProxy = {};
device.commandProxy.sendCommand = function (cmd, cb) {
// let's pretend we've got some latency here.
var to = Math.round(Math.random() * 10);
setTimeout(function () { cb([cmd, to]); }, to);
};
});

return it('should execute one command at a time keeping the seq right', function (done) {
var intercept = []
, iterations = 100
, check = function (err, result) {
intercept.push(result);
if (intercept.length >= iterations) {
for (var x = 0; x < iterations; x++) {
intercept[x][0].should.equal('' + x);
}
done();
}
};

for (var i = 0; i < iterations; i++) {
device.proxy("" + i, check);
}
});
});

describe('#parseLocalizableStrings()', function () {
var stubApp = path.resolve(__dirname, '../fixtures/localization_tests/StubApp.app');

beforeEach(function () {
_.extend(device.args, {
language : 'en'
, app : stubApp
});
});

it('should return a dictionary', function (done) {
device.parseLocalizableStrings(function () {
device.localizableStrings.should.eql({ 'main.button.computeSum' : 'Compute Sum' });
done();
});
});
});
});
35 changes: 2 additions & 33 deletions test/unit/queue-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,14 @@
var chai = require('chai')
, should = chai.should()
, getAppium = require('../../lib/appium.js')
, path = require('path')
, mock = require('../helpers/mock.js')
, IOS = require('../../lib/devices/ios/ios.js');
, IOS = require('../../lib/devices/ios/ios.js')
, path = require('path');

mock.noop(IOS.prototype, 'start');
mock.noop(IOS.prototype, 'stop');
mock.noop(IOS.prototype, 'configureApp');

describe('IOS', function () {
// we'd like to test ios.proxy; mock instruments
var inst = new IOS({});
inst.commandProxy = {};
inst.commandProxy.sendCommand = function (cmd, cb) {
// let's pretend we've got some latency here.
var to = Math.round(Math.random() * 10);
setTimeout(function () { cb([cmd, to]); }, to);
};

describe('#proxy()', function () {
return it('should execute one command at a time keeping the seq right', function (done) {
var intercept = []
, iterations = 100
, check = function (err, result) {
intercept.push(result);
if (intercept.length >= iterations) {
for (var x = 0; x < iterations; x++) {
intercept[x][0].should.equal('' + x);
}
done();
}
};

for (var i = 0; i < iterations; i++) {
inst.proxy("" + i, check);
}
});
});
});

describe('Appium', function () {
var intercept = []
, logPath = path.resolve(__dirname, "../../../appium.log")
Expand Down

0 comments on commit 84197da

Please sign in to comment.