From 276dc6f7cb0f056d3155206951e74f1d837d1531 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Thu, 1 Nov 2018 00:58:31 +0900 Subject: [PATCH 1/9] add script param in setDeviceSysLocaleViaSettingApp --- lib/tools/adb-commands.js | 12 +++++++++--- test/functional/adb-commands-e2e-specs.js | 3 +++ test/unit/adb-commands-specs.js | 17 +++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/tools/adb-commands.js b/lib/tools/adb-commands.js index fa4dab89..ea703cb8 100644 --- a/lib/tools/adb-commands.js +++ b/lib/tools/adb-commands.js @@ -840,12 +840,18 @@ methods.isAnimationOn = async function () { * * @param {string} language - Language. e.g. en, ja * @param {string} country - Country. e.g. US, JP + * @param {?string} script - Script. e.g. Hans in `zh-Hans-CN` */ -methods.setDeviceSysLocaleViaSettingApp = async function (language, country) { - await this.shell(['am', 'broadcast', '-a', LOCALE_SETTING_ACTION, +methods.setDeviceSysLocaleViaSettingApp = async function (language, country, script) { + const param = [ + 'am', 'broadcast', + '-a', LOCALE_SETTING_ACTION, '-n', LOCALE_SETTING_RECEIVER, '--es', 'lang', language.toLowerCase(), - '--es', 'country', country.toUpperCase()]); + '--es', 'country', country.toUpperCase() + ].concat(_.isString(script) ? ['--es', 'script', script] : []); + + await this.shell(param); }; /** diff --git a/test/functional/adb-commands-e2e-specs.js b/test/functional/adb-commands-e2e-specs.js index 48cec0b5..57a81711 100644 --- a/test/functional/adb-commands-e2e-specs.js +++ b/test/functional/adb-commands-e2e-specs.js @@ -171,6 +171,9 @@ describe('adb commands', function () { await adb.setDeviceSysLocaleViaSettingApp('fr', 'fr'); (await adb.getDeviceSysLocale()).should.equal('fr-FR'); + await adb.setDeviceSysLocaleViaSettingApp('zh', 'CN', 'Hans'); + (await adb.getDeviceSysLocale()).should.equal('zh-Hans-CN'); + await adb.setDeviceSysLocaleViaSettingApp('en', 'us'); (await adb.getDeviceSysLocale()).should.equal('en-US'); }); diff --git a/test/unit/adb-commands-specs.js b/test/unit/adb-commands-specs.js index 394084fb..2860d097 100644 --- a/test/unit/adb-commands-specs.js +++ b/test/unit/adb-commands-specs.js @@ -516,13 +516,22 @@ describe('adb commands', withMocks({adb, logcat, teen_process, net}, function (m }); }); describe('setDeviceSysLocaleViaSettingApp', function () { - const adbArgs = ['am', 'broadcast', '-a', 'io.appium.settings.locale', - '-n', 'io.appium.settings/.receivers.LocaleSettingReceiver', - '--es', 'lang', 'en', '--es', 'country', 'US']; - it('should call shell with locale settings', async function () { + it('should call shell with locale settings without script', async function () { + const adbArgs = ['am', 'broadcast', '-a', 'io.appium.settings.locale', + '-n', 'io.appium.settings/.receivers.LocaleSettingReceiver', + '--es', 'lang', 'en', '--es', 'country', 'US']; + mocks.adb.expects("shell").once().withExactArgs(adbArgs); await adb.setDeviceSysLocaleViaSettingApp('en', 'US'); }); + + it('should call shell with locale settings with script', async function () { + const adbArgs = ['am', 'broadcast', '-a', 'io.appium.settings.locale', + '-n', 'io.appium.settings/.receivers.LocaleSettingReceiver', + '--es', 'lang', 'zh', '--es', 'country', 'CN', '--es', 'script', 'Hans']; + mocks.adb.expects("shell").once().withExactArgs(adbArgs); + await adb.setDeviceSysLocaleViaSettingApp('zh', 'CN', 'Hans'); + }); }); describe('setGeoLocation', function () { const location = { From ca6515dfd618c9bd4608284cec813c5e0d88aeb0 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Thu, 1 Nov 2018 16:48:27 +0900 Subject: [PATCH 2/9] make e2e test runnable --- gulpfile.js | 9 +++++---- package.json | 2 +- test/fixtures/selendroid-test-app.apk | Bin 506298 -> 511344 bytes test/functional/adb-commands-e2e-specs.js | 6 ++++++ test/functional/setup.js | 7 +++++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 473337ca..c21b7caf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,10 +1,11 @@ "use strict"; -let gulp = require('gulp'), - boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp); +const gulp = require('gulp'); +const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp); boilerplate({ build: 'appium-adb', - jscs: false, - e2eTest: { android: true } + testTimeout: 120000, + e2eTest: { android: true }, + eslint: true, }); diff --git a/package.json b/package.json index 34b281d3..00d72ece 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "watch": "gulp watch", "build": "gulp transpile", "mocha": "mocha", - "e2e-test": "gulp e2e-test", + "e2e-test": "gulp transpile && mocha --timeout 600000 build/test/functional/", "coverage": "gulp coveralls", "precommit-msg": "echo 'Pre-commit checks...' && exit 0", "precommit-test": "REPORTER=dot gulp once", diff --git a/test/fixtures/selendroid-test-app.apk b/test/fixtures/selendroid-test-app.apk index ca5267a05b107db23a5a027ba3bbdd3cf114ab81..d31c4d21d9807047b8cf8700af6d2a37ee6e8fd4 100644 GIT binary patch delta 11555 zcmeHtcT`kMv+s~*0LeLwM2P}3C{Yw7Nk%dVf*?t97=px2lpskEhMWXM$qYCkS;>e2 z1w>Rt6qF=NR1ofl!F$Bx{o|c?p5J2aw?2Z`|fK z!*#}(^OEd0Itn-8@B$(NxSlCnvaD#WY8Wjh0ufGzW1*$Miq5Ep(P2)UOy1}J_!R$s zZA%uu&lWB(yie0o=pn#$h0C*|8ERpa7=<$z32~$t7S4 z=p^Il;Ru5$gaIB{@WDa=7DBKPVG#yUR_;AsXew*iVf3dyC@~i03%$v;N5ryaLSL}{ z(vF7L!AP-k*03A2xE9yLu)|oeCo|1YNUeGpF}h_J8RQGi!LdVw><*)MTd;UL&=k^x zaGIZZVnLn~f3f4i4kBRtI^mcs?lQ^IgSk=dF~Ne`5B;PLdawPEFN_+;1j`WvbAsZa ziHR^2&OTUZGE8T`YI+@p+^;62!Qydd!?I_>>~Ir-jmd&B?^8>1VM93V&A;Vagpo4(!w&!hJPiAg@BZ5FQDIgHK6ge__K>tkqh#Bg(Is@d*y1{$7cOE5h0#8~! zZ#F6&c^x|XC7!P0My32~)3a6V$t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3hB6@J#jtV~J5P{43)>{2*BaKw9Fh1-wEWdh*Bt<`O89p6V}TD>*<6=IkRYE#XOr zbRa~>4DNeM)nXzJTCS73U9xAEvFuI2f=z?2eM= z5a1}&C6nPm$00WJ(=*`6kBI_WNgm+gQ^WpyU-tLs*#3Rl@#p`$J=0J*&hYpCdYs`s z5p4e>j#=f;<=o%npXQj-S@OTG>f|&ulyp?JuOYQ=%KcLfJXsAe;8&dl`Kkf7qu$xK zG}C|&ssTFI{rS`0OzHIoqThiE`!Siw)96{?EZA5LkRKq!9gv}~A;kQ@kb(3Nk_Du~ z08|G^_~+jly%0(s4+dj}{{Q=UFrfQL*!lk1&{DRNx@!OoCQS^39e>vpM)VFT9hikV zYDD`t;o>I{pDIMn^j}`6#?1kCV}SDq4XDdzl4it*!A79l57$#^gRvZAyDk6<)B=2m9bi-o#qCIf9<>1fp(SVEQX`E%!_NWE)c#T2+PBVMMynuM z|CO%W=x5j|NWv3J0>d#WN;$NRAQOnH`$H312hqsLqZ5VLz}Ej*2luU{3gCJjzHWcGJ*rJM!48Lgb2$YgJ0`=X4TG84nm9UII3mq0T>m*hK-qeTO7<}**8tFg zKNO=FXM#wy0bZCawwJlo-Xb~g@7aIRK_x6MCYaKbE#gG`h^qG z9P|U{1lqqFLJ&fqBgY52M*;x$hX9NquH{euMj%1_*ko|4 Date: Thu, 1 Nov 2018 16:55:08 +0900 Subject: [PATCH 3/9] define null if arg has no script --- lib/tools/adb-commands.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/tools/adb-commands.js b/lib/tools/adb-commands.js index ea703cb8..b45935cc 100644 --- a/lib/tools/adb-commands.js +++ b/lib/tools/adb-commands.js @@ -842,16 +842,20 @@ methods.isAnimationOn = async function () { * @param {string} country - Country. e.g. US, JP * @param {?string} script - Script. e.g. Hans in `zh-Hans-CN` */ -methods.setDeviceSysLocaleViaSettingApp = async function (language, country, script) { - const param = [ +methods.setDeviceSysLocaleViaSettingApp = async function (language, country, script = null) { + const params = [ 'am', 'broadcast', '-a', LOCALE_SETTING_ACTION, '-n', LOCALE_SETTING_RECEIVER, '--es', 'lang', language.toLowerCase(), '--es', 'country', country.toUpperCase() - ].concat(_.isString(script) ? ['--es', 'script', script] : []); + ]; + + if (script) { + params.push('--es', 'script', script); + } - await this.shell(param); + await this.shell(params); }; /** From 1d470c668fbe0889e5503e8379c082425d05e66e Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Thu, 1 Nov 2018 17:33:54 +0900 Subject: [PATCH 4/9] revert default api level and avd name --- gulpfile.js | 1 - test/functional/setup.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c21b7caf..e1e264a2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,6 @@ const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp); boilerplate({ build: 'appium-adb', - testTimeout: 120000, e2eTest: { android: true }, eslint: true, }); diff --git a/test/functional/setup.js b/test/functional/setup.js index eae5c084..d4536ebc 100644 --- a/test/functional/setup.js +++ b/test/functional/setup.js @@ -14,8 +14,8 @@ const API_LEVEL_MAP = { '9.0': '28', }; -const avdName = process.env.ANDROID_AVD || 'Nexus 5X API 27'; -const platformVersion = process.env.PLATFORM_VERSION || '8.1'; +const avdName = process.env.ANDROID_AVD || 'NEXUS_S_18_X86'; +const platformVersion = process.env.PLATFORM_VERSION || '4.3'; let apiLevel = process.env.API_LEVEL || API_LEVEL_MAP[parseFloat(platformVersion).toString()]; From f4d7a682572559d9885c197901a9f95971027393 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Fri, 2 Nov 2018 21:31:40 +0900 Subject: [PATCH 5/9] use npm run mocha than mocha directly --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 00d72ece..bb4af899 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "watch": "gulp watch", "build": "gulp transpile", "mocha": "mocha", - "e2e-test": "gulp transpile && mocha --timeout 600000 build/test/functional/", + "e2e-test": "gulp transpile && npm run mocha -- -t 600000 --recursive build/test/functional/", "coverage": "gulp coveralls", "precommit-msg": "echo 'Pre-commit checks...' && exit 0", "precommit-test": "REPORTER=dot gulp once", From 2a9a55467d75b3de03a06cd379da4dcee8e03835 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 3 Nov 2018 10:41:09 +0900 Subject: [PATCH 6/9] add script in setDeviceLanguageCountry --- lib/tools/apk-utils.js | 16 ++++++++++++---- test/unit/apk-utils-specs.js | 12 +++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/tools/apk-utils.js b/lib/tools/apk-utils.js index 3654c0b3..f271be6d 100644 --- a/lib/tools/apk-utils.js +++ b/lib/tools/apk-utils.js @@ -772,8 +772,10 @@ apkUtilsMethods.ensureCurrentLocale = async function (language, country) { * format: [a-zA-Z]{2,8}. e.g. en, ja : https://developer.android.com/reference/java/util/Locale.html * @param {string} country - Country. The country (region) field is case insensitive, but Locale always canonicalizes to upper case. * format: [a-zA-Z]{2} | [0-9]{3}. e.g. US, JP : https://developer.android.com/reference/java/util/Locale.html + * @param {?string} script - Script. The script field is case insensitive but Locale always canonicalizes to title case. + * format: [a-zA-Z]{4}. e.g. Hans in zh-Hans-CN : https://developer.android.com/reference/java/util/Locale.html */ -apkUtilsMethods.setDeviceLanguageCountry = async function (language, country) { +apkUtilsMethods.setDeviceLanguageCountry = async function (language, country, script = null) { let hasLanguage = language && _.isString(language); let hasCountry = country && _.isString(country); if (!hasLanguage && !hasCountry) { @@ -823,9 +825,15 @@ apkUtilsMethods.setDeviceLanguageCountry = async function (language, country) { return; } - log.debug(`Current locale: '${curLocale}'; requested locale: '${language}-${country}'`); - if (`${language}-${country}`.toLowerCase() !== curLocale.toLowerCase()) { - await this.setDeviceSysLocaleViaSettingApp(language, country); + let localeCode; + if (script) { + localeCode = `${language}-${script}-${country}`; + } else { + localeCode = `${language}-${country}`; + } + log.debug(`Current locale: '${curLocale}'; requested locale: '${localeCode}'`); + if (localeCode.toLowerCase() !== curLocale.toLowerCase()) { + await this.setDeviceSysLocaleViaSettingApp(language, country, script); } } } diff --git a/test/unit/apk-utils-specs.js b/test/unit/apk-utils-specs.js index 53548f70..4b95111c 100644 --- a/test/unit/apk-utils-specs.js +++ b/test/unit/apk-utils-specs.js @@ -758,11 +758,21 @@ describe('Apk-utils', withMocks({adb, fs, teen_process}, function (mocks) { .once().returns(24); mocks.adb.expects("getDeviceLocale").withExactArgs() .once().returns('fr-FR'); - mocks.adb.expects("setDeviceSysLocaleViaSettingApp").withExactArgs(language, country) + mocks.adb.expects("setDeviceSysLocaleViaSettingApp").withExactArgs(language, country, null) .once().returns(""); mocks.adb.expects('reboot').never(); await adb.setDeviceLanguageCountry(language, country); }); + it('should call set locale with script via setting app when API 24+', async function () { + mocks.adb.expects("getApiLevel").withExactArgs() + .once().returns(24); + mocks.adb.expects("getDeviceLocale").withExactArgs() + .once().returns('fr-FR'); + mocks.adb.expects("setDeviceSysLocaleViaSettingApp").withExactArgs('zh', 'CN', 'Hans') + .once().returns(""); + mocks.adb.expects('reboot').never(); + await adb.setDeviceLanguageCountry('zh', 'CN', 'Hans'); + }); it('should not set language and country if it does not change when API 24+', async function () { mocks.adb.expects("getApiLevel").withExactArgs() .once().returns(24); From cd88fe35c76e1a711e3f5b965df0aed6f34a89e4 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 3 Nov 2018 11:28:49 +0900 Subject: [PATCH 7/9] add script in ensureCurrentLocale --- lib/tools/apk-utils.js | 16 ++++++++++++---- test/unit/apk-utils-specs.js | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/tools/apk-utils.js b/lib/tools/apk-utils.js index f271be6d..0fd5524a 100644 --- a/lib/tools/apk-utils.js +++ b/lib/tools/apk-utils.js @@ -711,10 +711,11 @@ apkUtilsMethods.setDeviceLocale = async function (locale) { * * @param {string} language - Language. The language field is case insensitive, but Locale always canonicalizes to lower case. * @param {string} country - Country. The language field is case insensitive, but Locale always canonicalizes to lower case. + * @param {?string} script - Script. The script field is case insensitive but Locale always canonicalizes to title case. * * @return {boolean} If current locale is language and country as arguments, return true. */ -apkUtilsMethods.ensureCurrentLocale = async function (language, country) { +apkUtilsMethods.ensureCurrentLocale = async function (language, country, script = null) { const hasLanguage = _.isString(language); const hasCountry = _.isString(country); @@ -750,7 +751,14 @@ apkUtilsMethods.ensureCurrentLocale = async function (language, country) { } } else { const curLocale = (await this.getDeviceLocale()).toLowerCase(); - if (`${language}-${country}` === curLocale) { + let localeCode; + if (script) { + localeCode = `${language}-${script.toLowerCase()}-${country}`; // zh-hans-cn + } else { + localeCode = `${language}-${country}`; // zh-cn + } + + if (localeCode === curLocale) { return true; } } @@ -827,9 +835,9 @@ apkUtilsMethods.setDeviceLanguageCountry = async function (language, country, sc let localeCode; if (script) { - localeCode = `${language}-${script}-${country}`; + localeCode = `${language}-${script}-${country}`; // zh-Hans-CN } else { - localeCode = `${language}-${country}`; + localeCode = `${language}-${country}`; // zh-CN } log.debug(`Current locale: '${curLocale}'; requested locale: '${localeCode}'`); if (localeCode.toLowerCase() !== curLocale.toLowerCase()) { diff --git a/test/unit/apk-utils-specs.js b/test/unit/apk-utils-specs.js index 4b95111c..c8bf94a6 100644 --- a/test/unit/apk-utils-specs.js +++ b/test/unit/apk-utils-specs.js @@ -670,6 +670,16 @@ describe('Apk-utils', withMocks({adb, fs, teen_process}, function (mocks) { mocks.adb.expects("getDeviceLocale").withExactArgs().once().returns(""); (await adb.ensureCurrentLocale('en', 'us')).should.be.false; }); + it('should return true when API 23 with script', async function () { + mocks.adb.expects("getApiLevel").withExactArgs().once().returns(23); + mocks.adb.expects("getDeviceLocale").withExactArgs().once().returns("zh-Hans-CN"); + (await adb.ensureCurrentLocale('zh', 'CN', 'Hans')).should.be.true; + }); + it('should return false when API 23 with script', async function () { + mocks.adb.expects("getApiLevel").withExactArgs().once().returns(23); + mocks.adb.expects("getDeviceLocale").withExactArgs().once().returns(""); + (await adb.ensureCurrentLocale('zh', 'CN', 'Hans')).should.be.false; + }); }); describe('setDeviceLocale', function () { it('should not call setDeviceLanguageCountry because of empty', async function () { From 63128024eeb3c6bd435da16943a2ecfe05d747c2 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 3 Nov 2018 16:14:06 +0900 Subject: [PATCH 8/9] use a ternary operator --- lib/tools/apk-utils.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/tools/apk-utils.js b/lib/tools/apk-utils.js index 0fd5524a..581abd3c 100644 --- a/lib/tools/apk-utils.js +++ b/lib/tools/apk-utils.js @@ -751,12 +751,8 @@ apkUtilsMethods.ensureCurrentLocale = async function (language, country, script } } else { const curLocale = (await this.getDeviceLocale()).toLowerCase(); - let localeCode; - if (script) { - localeCode = `${language}-${script.toLowerCase()}-${country}`; // zh-hans-cn - } else { - localeCode = `${language}-${country}`; // zh-cn - } + // zh-hans-cn : zh-cn + const localeCode = script ? `${language}-${script.toLowerCase()}-${country}` : `${language}-${country}`; if (localeCode === curLocale) { return true; @@ -833,12 +829,8 @@ apkUtilsMethods.setDeviceLanguageCountry = async function (language, country, sc return; } - let localeCode; - if (script) { - localeCode = `${language}-${script}-${country}`; // zh-Hans-CN - } else { - localeCode = `${language}-${country}`; // zh-CN - } + // zh-Hans-CN : zh-CN + const localeCode = script ? `${language}-${script}-${country}` : `${language}-${country}`; log.debug(`Current locale: '${curLocale}'; requested locale: '${localeCode}'`); if (localeCode.toLowerCase() !== curLocale.toLowerCase()) { await this.setDeviceSysLocaleViaSettingApp(language, country, script); From 1b9f01e3122731b478f8161c0386d04a740ac916 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Mon, 5 Nov 2018 20:55:28 +0900 Subject: [PATCH 9/9] add a debug log to show current locale is equal to requested one --- lib/tools/apk-utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tools/apk-utils.js b/lib/tools/apk-utils.js index 581abd3c..e22a9021 100644 --- a/lib/tools/apk-utils.js +++ b/lib/tools/apk-utils.js @@ -755,6 +755,7 @@ apkUtilsMethods.ensureCurrentLocale = async function (language, country, script const localeCode = script ? `${language}-${script.toLowerCase()}-${country}` : `${language}-${country}`; if (localeCode === curLocale) { + log.debug(`Requested locale is equal to current locale: '${curLocale}'`); return true; } }