Best JavaScript code snippet using appium-xcuitest-driver
defaultUILocalizer.js
Source:defaultUILocalizer.js
1// Description: Default UI localizer (needed only by non English locales)2// Author: kartu3//4// History:5// 2010-04-25 kartu - Refactored from core-lang6// 2010-05-02 kartu - Added second "unlock screen" localization (shown after sleep/usb connection)7// Added support for field sizes8// Localized "ok" texts9// 2010-05-09 kartu - Fixed "All bookmarks" "+ 1" bug10// 2010-05-15 kartu - Fixed "set date" bug ("mAX" typo)11// 2010-05-15 kartu - Moved getDateAndClock function to core lang (since English locale might also need it)12// 2010-05-18 kravitz - Replaced "PAGE" with "FUNC_PAGE_X"13// 2010-05-20 kartu - Removed script reference from about string14// 2010-06-26 kartu - Removed dependency on menu customizer1516var tmp = function() {17 //--------------------------------------------------------------------------------------18 // utility functions19 //--------------------------------------------------------------------------------------20 var L, LF, setStr, getPageChangedFunc, settingsComment, localizeDefaultUI, standardNodes, log,21 toDoubleDigit, FUNC_GET_DATE, FUNC_GET_TIME, FUNC_GET_DATE_TIME;22 log = Core.log.getLogger("defaultUILocalizer");2324 // Create list of nodes for simpler referencing 25 standardNodes = {};26 createListOfStandardNodes = function () {27 var key, path, node, j, m, standardMenuLayout;28 standardMenuLayout = Core.config.compat.standardMenuLayout;29 for (key in standardMenuLayout) {30 try {31 path = standardMenuLayout[key];32 if (path !== undefined) {33 node = kbook.root;34 for (j = 0, m = path.length; j < m; j++) {35 node = node.nodes[path[j]];36 }37 standardNodes[key] = node;38 }39 } catch (e) {40 log.error("Failed to find node: " + key + " " + e);41 }42 }43 };44 createListOfStandardNodes();4546 // Utility function, no need to localize47 toDoubleDigit = function (num) {48 if (num < 10) {49 return "0" + num;50 }51 return num;52 };53 54 FUNC_GET_DATE = function (date) {55 var day, month, year;56 day = toDoubleDigit(date.getDate());57 month = toDoubleDigit(date.getMonth() + 1);58 year = date.getFullYear();59 return month + "/" + day + "/" + year;60 };61 62 FUNC_GET_TIME = function (date) {63 var hour, minute;64 hour = toDoubleDigit(date.getHours());65 minute = toDoubleDigit(date.getMinutes());66 return hour + ":" + minute;67 };68 69 FUNC_GET_DATE_TIME = function (date) {70 return date.toLocaleDateString() + " " + FUNC_GET_TIME(date);71 }; 72 73 //--------------------------------------------------------------------------------------74 // "Localizing" functions75 //--------------------------------------------------------------------------------------7677 var localizeDate = function() {78 var sony = _strings.Sony;79 // Set date related stuff80 //81 // FIXME side effects!!!82 if (typeof sony.FUNC_GET_DATE === "function") {83 Date.prototype.toLocaleDateString = function() {84 return sony.FUNC_GET_DATE(this);85 };86 }87 };8889 var localizeRoot = function() {90 try {91 var nodes = standardNodes;92 var getSoValue = Core.system.getSoValue;93 94 setStr(nodes["continue"], "CONTINUE");95 96 nodes["continue"]._mycomment = function (arg) {97 var bookNode = kbook.model.currentBook;98 return bookNode !== null ? getSoValue(bookNode, "media.title") : L("NO_BOOK");99 };100 101 // Books by ?102 setStr(nodes.booksByTitle, "BOOKS_BY_TITLE");103 setStr(nodes.booksByAuthor, "BOOKS_BY_AUTHOR");104 setStr(nodes.booksByDate, "BOOKS_BY_DATE");105 nodes.booksByTitle._mycomment = nodes.booksByAuthor._mycomment = nodes.booksByDate._mycomment = function () {106 return LF("BOOKS", this.nodes.length - 10);107 };108 109 // Collections110 setStr(nodes.collections, "COLLECTIONS");111 nodes.collections._mycomment = function () {112 return LF("COLLECTIONS", this.length);113 };114 // Books inside collections115 kbook.root.children.collections.prototype._mycomment = function() {116 return LF("BOOKS", this.playlist.items.length);117 };118 119 // Bookmarks120 setStr(nodes.bookmarks, "ALL_BOOKMARKS");121 nodes.bookmarks._mycomment = function () {122 return LF("BOOKMARKS", this.nodes.length);123 };124 125 // Now Playing126 setStr(nodes.nowPlaying, "NOW_PLAYING");127 nodes.nowPlaying._mycomment = function () {128 return kbook.model.currentSong === null ? L("NO_SONG") : this.comment();129 };130 131 // Music132 setStr(nodes.music, "MUSIC");133 nodes.music._mycomment = function () {134 return LF("SONGS", this.length);135 };136 137 // Pictures138 setStr(nodes.pictures, "PICTURES");139 nodes.pictures._mycomment = function () {140 return LF("PICTURES", this.length);141 };142 143 // Settings144 setStr(nodes.settings, "SETTINGS");145 nodes.settings._mycomment = settingsComment;146 147 } catch (e) {148 log.error("localizing root", e);149 }150 };151152 var localizeSettings = function() {153 try {154 // Settings - Orientation155 var settingsNode = standardNodes.settings;156 var settingsChildren = settingsNode.children;157 setStr(settingsChildren.orientation, "ORIENTATION");158 settingsChildren.orientation._mycomment = function () {159 return kbook.model.container.getVariable('ORIENTATION') ? L("HORIZONTAL") : L("VERTICAL");160 };161 162 // Settings - Set Date163 setStr(settingsChildren.setdate_clock, "SET_DATE");164 settingsChildren.setdate_clock._mycomment = function() {165 return FUNC_GET_DATE_TIME(new Date());166 };167 var setDateNodes = settingsNode.nodes[1].nodes;168 setDateNodes[0].name = L("YEAR"); //year169 setDateNodes[1].name = L("MONTH"); // month170 setDateNodes[2].name = L("DATE"); // day171 setDateNodes[3].name = L("HOUR"); // hour172 setDateNodes[4].name = L("MINUTE"); // minute173 setDateNodes[5].min = setDateNodes[5].max = L("SETDATE_OK");174 setDateNodes[5].kind = -parseFloat(L("SETDATE_OK_SIZE", 2));175 176 // Settings - Slideshow177 var slideshow = standardNodes.settings.nodes[2];178 setStr(slideshow, "SLIDESHOW");179 slideshow._mycomment = function() {180 return kbook.model.slideshowFlag ? L("SS_ON") : L("SS_OFF");181 };182 var slideshowNodes = slideshow.nodes;183 slideshowNodes[0].name= L("SS_TURN");184 slideshowNodes[0].min = L("SS_OFF") ;185 slideshowNodes[0].max = L("SS_ON") ;186 slideshowNodes[0].kind = -parseFloat(L("SS_SIZE", 2));187 slideshowNodes[1].name= L("SS_DURATION");188 slideshowNodes[1].comment = L("SECONDS");189 slideshowNodes[2].min = slideshowNodes[2].max = L("SS_OK");190 slideshowNodes[2].kind = -parseFloat(L("SS_OK_SIZE", 2));191 192 // Settings - Auto Standby193 var autoStandby = standardNodes.settings.nodes[3];194 setStr(autoStandby, "AUTOSTANDBY");195 autoStandby._mycomment = function() {196 return kbook.model.autoStandbyFlag ? L("AS_ON") : L("AS_OFF");197 };198 199 var autoStandbyNodes = autoStandby.nodes;200 autoStandbyNodes[0].name = L("AS_TURN");201 autoStandbyNodes[0].min = L("AS_OFF");202 autoStandbyNodes[0].max = L("AS_ON");203 autoStandbyNodes[0].kind = -parseFloat(L("AS_SIZE", 2));204 autoStandbyNodes[1].min = autoStandbyNodes[1].max = L("AS_OK");205 autoStandbyNodes[1].kind = -parseFloat(L("AS_OK_SIZE", 2));206 207 // Settings - About208 setStr(settingsChildren.about, "ABOUT");209 setStr(settingsChildren.resetToFactorySettings, "RESET_TO_FACTORY");210 } catch (e) {211 log.error("Error localizing settings", e);212 }213 };214215 var localizeAdvancedSettings = function() {216 try {217 var nodes = standardNodes;218219 // Settings - Advanced Settings220 setStr(nodes.advancedSettings, "ADVANCED_SETTINGS");221 nodes.advancedSettings._mycomment = settingsComment;222 var advancedSettingsChildren = nodes.advancedSettings.children;223 224 // Settings - Advanced Settings - Screen Lock225 var screenLockSettings = kbook.screenLock;226 var screenLockSettingsNodes = screenLockSettings.nodes;227 setStr(screenLockSettings, "SCREEN_LOCK");228 screenLockSettingsNodes[0].name = L("SL_TURN");229 screenLockSettingsNodes[0].min = L("SL_OFF");230 screenLockSettingsNodes[0].max = L("SL_ON");231 screenLockSettingsNodes[0].kind = -parseFloat(L("SL_SIZE", 2));232 screenLockSettingsNodes[1].name = L("SL_CODE");233 screenLockSettingsNodes[2].min = screenLockSettingsNodes[2].max = L("SL_OK");234 screenLockSettingsNodes[2].kind = -parseFloat(L("SL_OK_SIZE", 2));235236 // Shown to unlock settings237 var screenLock = standardNodes.advancedSettings.nodes[0];238 var screenLockNodes = screenLock.nodes;239 screenLock._mycomment = function () {240 return kbook.model.screenLockFlag ? L("SL_ON") : L("SL_OFF");241 };242 setStr(screenLock, "SCREEN_LOCK");243 screenLockNodes[0].name = L("SL_CODE");244 screenLockNodes[1].min = screenLockNodes[1].max = L("SL_OK_UNLOCK");245 screenLockNodes[1].kind = -parseFloat(L("SL_OK_UNLOCK_SIZE", 2));246 247 // Shown to unlock device after it was connected to USB / restart248 var unlockNodes = kbook.screenUnlock.nodes;249 unlockNodes[0].name = L("SL_CODE");250 unlockNodes[1].min = unlockNodes[1].max = L("SL_OK_UNLOCK");251 unlockNodes[1].kind = -parseFloat(L("SL_OK_UNLOCK_SIZE", 2));252253 // Settings - Advanced Settings - Format Device254 setStr(advancedSettingsChildren.formatDevice, "FORMAT_DEVICE");255 256 // Settings - Advanced Settings - Shutdown257 setStr(advancedSettingsChildren.deviceShutdown, "DEVICE_SHUTDOWN");258 } catch (e) {259 log.error("in localizeAdvancedSettings: " + e);260 }261 };262263 var localizeBook = function() {264 // Book265 var bookChildren = kbook.children;266 setStr(bookChildren["continue"], "CONTINUE");267 setStr(bookChildren.begin, "BEGIN");268 setStr(bookChildren.end, "END");269 var getSoValue = Core.system.getSoValue;270 bookChildren["continue"]._mycomment = bookChildren.begin._mycomment = bookChildren.end._mycomment = function () {271 if (this.bookmark) {272 return L("PAGE") + " " + (getSoValue(this.bookmark, "page") + 1);273 }274 return "";275 };276277 setStr(bookChildren.bookmarks, "BOOKMARKS");278 bookChildren.bookmarks._mycomment = function () {279 return LF("BOOKMARKS", this.bookmarks.length);280 };281282 setStr(bookChildren.contents, "CONTENTS");283 bookChildren.contents._mycomment = function () {284 return LF("ITEMS", this.bookmarks.length);285 };286287 setStr(bookChildren.history, "HISTORY");288 bookChildren.history._mycomment = function () {289 return LF("PAGES", this.bookmarks.length);290 };291292 setStr(bookChildren.info, "INFO");293 Core.system.setSoValue(getSoValue(kbook, "strings"), "infoTitles", L("INFO_TITLES"));294295 setStr(kbook.children.utilities, "UTILITIES");296 kbook.children.utilities._mycomment = settingsComment;297 };298299 var localizeBookUtils = function() {300 // Book.Utilities301 var bookUtilChildren = kbook.children.utilities.children;302 var getSoValue = Core.system.getSoValue;303 setStr(bookUtilChildren.removeAllBookmarks, "REMOVE_ALL_BOOKMARKS");304 bookUtilChildren.removeAllBookmarks._mycomment = function () {305 return LF("BOOKMARKS", getSoValue(this.parent.parent, "media.bookmarks.length"));306 };307308 setStr(bookUtilChildren.clearHistory, "CLEAR_HISTORY");309 bookUtilChildren.clearHistory._mycomment = function () {310 return LF("PAGES", getSoValue(this.parent.parent, "media.history.length"));311 };312313 setStr(bookUtilChildren.deleteBook, "DELETE_BOOK");314 };315316 var localizeBookByDate = function() {317 try {318 // BooksByDate child children319 var children = standardNodes.booksByDate.children;320 setStr(children._1, "TODAY");321 setStr(children._2, "EARLIER_THIS_WEEK");322 setStr(children._3, "LAST_WEEK");323 setStr(children._4, "EARLIER_THIS_MONTH");324 setStr(children._5, "LAST_MONTH");325 setStr(children._6, "EARLIER_THIS_QUARTER");326 setStr(children._7, "LAST_QUARTER");327 setStr(children._8, "EARLIER_THIS_YEAR");328 setStr(children._9, "LAST_YEAR");329 setStr(children._0, "OLDER");330 } catch (e) {331 log.error("In localizeBookByDate: " + e);332 }333 };334335 var localizeBookByTitleAndAuthor = function() {336 var setSoValue, childrenTitle, childrenAuthor, i, obj1, obj2, criterion, title;337 try {338 if (L("CUSTOM_SORT") === true) {339 setSoValue = Core.system.setSoValue;340 childrenTitle = standardNodes.booksByTitle.children;341 childrenAuthor = standardNodes.booksByAuthor.children;342 for (i = 0; i < 10; i++) {343 obj1 = childrenTitle["_" + i];344 obj2 = childrenAuthor["_" + i];345 criterion = L("CRITERION_" + i);346 title = L("TITLE_" + i);347 setSoValue(obj1, "criterion", criterion);348 setSoValue(obj1, "name", title);349 setSoValue(obj1, "title", title);350 setSoValue(obj2, "criterion", criterion);351 setSoValue(obj2, "name", title);352 setSoValue(obj2, "title", title);353 }354 }355 } catch (e) {356 log.error("In localizeBookByTitleAndAuthor: " + e);357 }358 };359360 var localizeComments = function() {361 var getSoValue = Core.system.getSoValue;362 var getFastSoValue = Core.system.getFastSoValue;363364 // BooksBy* comment365 //366 var obj = getSoValue("FskCache.tree.bookItemNode");367 obj._mycomment = function() {368 var offsets, offset, index, c, result;369 index = getFastSoValue(this, "index");370 offsets = getSoValue(this, "parent.offsets");371 offset = offsets[index];372 c = offsets[index + 1] - offset;373 offset = offset - offset % 10;374 offset = offset / 10;375 offset++;376 result = LF("BOOKS", c);377 if (c > 0) {378 result = result + " - " + L("PAGE") + " " + offset;379 }380 return result;381 };382383 // Global bookmarks node384 //385 obj = getSoValue("FskCache.tree.globalBookmarkItemNode");386 obj._mycomment = function() {387 var bookmark, comment, part;388 bookmark = getFastSoValue(this, "bookmark");389 comment = (new Date(getFastSoValue(bookmark, "date"))).toLocaleDateString();390 comment = comment + ' - ' + getSoValue(this, "book.name");391 part = getFastSoValue(bookmark, "part");392 if (part) {393 comment = comment + ' - ' + L("PART") + ' ' + part;394 }395 comment = comment + ' - ' + L("PAGE") + " " + (getFastSoValue(bookmark, "page") + 1) + ' ' + L("OF") + ' ' + getFastSoValue(bookmark, "pages");396 return comment;397 };398399 // Bookmarks in book's "Bookmarks" and "History"400 //401 obj = getSoValue("FskCache.tree.bookmarkNode.prototype");402 obj._mycomment = function() {403 var part, page, pages, bookmark, result;404 bookmark = getFastSoValue(this, "bookmark");405 if (bookmark !== undefined) {406 part = getFastSoValue(bookmark, "part");407 page = getFastSoValue(bookmark, "page");408 page++;409 pages = getFastSoValue(bookmark, "pages");410 result = '';411 if (part) {412 result = result + L("PART") + ' ' + part + ' - ';413 }414 result = result + L("PAGE") + " " + page;415 if (pages) {416 result = result + ' ' + L("OF") + ' ' + pages;417 }418 return result;419 }420 return '?';421 };422423 // Bookmarks in book's "Contents"424 //425 obj = getSoValue("FskCache.tree.markReferenceNode.prototype");426 obj._mycomment = function() {427 var part, page, bookmark;428 bookmark = getSoValue(this, "bookmark");429 page = getFastSoValue(bookmark, "page") + 1;430 part = getFastSoValue(bookmark, "part");431 if (part) {432 return L("PART") + ' ' + part + ' - ' + L("PAGE") + " " + page;433 } else {434 return L("PAGE") + " " + page;435 }436 };437 };438439 var localizeStatic = function() {440 try {441 var obj;442 var container = kbook.model.container;443 // Invalid Format!444 container.sandbox.INVALID_FORMAT_GROUP.sandbox.LB_INVALID_FORMAT.setValue(L("INVALID_FORMAT"));445 // Formatting...446 container.sandbox.PROGRESS_GROUP.sandbox.LB_FORMATTING.setValue(L("FORMATTING"));447 container.sandbox.FORMAT_GROUP.sandbox.LB_FORMATTING.setValue(L("FORMATTING"));448 // Loading...449 container.sandbox.DISK_GROUP.sandbox.LB_LOADING.setValue(L("LOADING"));450 // Low Battery!451 container.sandbox.LOW_BATTERY_GROUP.sandbox.LB_LOW_BATTERY.setValue(L("LOW_BATTERY"));452 453 // Reset All454 obj = container.sandbox.HARD_RESET_GROUP;455 obj.sandbox.RESET_ALL.setValue(L("RESET_ALL"));456 // "Do you want to DELETE all content, restore all factory settings,457 // and clear the DRM authorization state? Yes - Press 5 No - Press MENU"458 obj.sandbox.HARD_RESET.sandbox.HR_WARNING.setValue(L("HR_WARNING"));459 460 // Device Shutdown461 obj = container.sandbox.DEVICE_SHUTDOWN_GROUP;462 obj.sandbox.LB_TITLE.setValue(L("DEVICE_SHUTDOWN"));463 // Press MARK to shutdown464 obj.sandbox.DEVICE_SHUTDOWN.sandbox.LB_MESSAGE1.setValue(L("PRESS_MARK_TO_SHUTDOWN"));465 // this device.466 obj.sandbox.DEVICE_SHUTDOWN.sandbox.LB_MESSAGE2.setValue(L("THIS_DEVICE"));467 468 // Delete Book469 obj = container.sandbox.DELETE_BOOK_GROUP;470 obj.sandbox.LB_TITLE.setValue(L("DELETE_BOOK"));471 // Press MARK to472 obj.sandbox.DELETE_BOOK.sandbox.LB_MESSAGE1.setValue(L("PRESS_MARK_TO_DELETE"));473 // delete book.474 obj.sandbox.DELETE_BOOK.sandbox.LB_MESSAGE2.setValue(L("THIS_BOOK"));475 476 // Format Internal Memory477 obj = container.sandbox.FORMAT_DEVICE_GROUP;478 obj.sandbox.LB_TITLE.setValue(L("FORMAT_INTERNAL_MEMORY"));479 // Press MARK to format480 obj.sandbox.FORMAT_DEVICE.sandbox.LB_MESSAGE1.setValue(L("PRESS_MARK_TO_FORMAT"));481 // internal memory.482 obj.sandbox.FORMAT_DEVICE.sandbox.LB_MESSAGE2.setValue(L("MSG_INTERNAL_MEMORY"));483 484 // Restore Defaults485 obj = container.sandbox.SOFT_RESET_GROUP;486 obj.sandbox.LB_TITLE.setValue(L("RESTORE_DEFAULTS"));487 // Press MARK to restore488 obj.sandbox.SOFT_RESET.sandbox.LB_MESSAGE1.setValue(L("PRESS_MARK_TO_RESTORE"));489 // default settings.490 obj.sandbox.SOFT_RESET.sandbox.LB_MESSAGE2.setValue(L("DEFAULT_SETTINGS"));491 492 // Now Playing493 container.sandbox.SONG_GROUP.sandbox.LB_TITLE.setValue(L("NOW_PLAYING"));494 // Uppercase PAGE (goto)495 container.sandbox.GOTO_GROUP.sandbox.GROUP.sandbox.LB_MESSAGE.setValue(L("UPPER_PAGE"));496 497 // 1 of 1498 var oneOfOne = L("ONE_OF_ONE");499 container.sandbox.HARD_RESET_GROUP.sandbox.LB_STATUS.setValue(oneOfOne);500 container.sandbox.DEVICE_SHUTDOWN_GROUP.sandbox.LB_STATUS.setValue(oneOfOne);501 container.sandbox.DELETE_BOOK_GROUP.sandbox.LB_STATUS.setValue(oneOfOne);502 container.sandbox.FORMAT_DEVICE_GROUP.sandbox.LB_STATUS.setValue(oneOfOne);503 container.sandbox.SOFT_RESET_GROUP.sandbox.LB_STATUS.setValue(oneOfOne);504 container.sandbox.SETTING_GROUP.sandbox.LB_STATUS.setValue(oneOfOne);505 506 // Info page507 var oldPageChanged = container.sandbox.INFO_GROUP.sandbox.INFO.pageChanged;508 container.sandbox.INFO_GROUP.sandbox.INFO.pageChanged = getPageChangedFunc("INFO_INDEX_COUNT", oldPageChanged, L);509 } catch (e) {510 log.error("localizeStatic", e);511 }512 };513514 var localizeKbook = function () {515 // SHUTDOWN_MSG related stuff516 // No battery!517 kbook.model.SHUTDOWN_MSG = L("NO_BATTERY");518 var oldDoFormatFlash = kbook.model.doFormatFlash;519 kbook.model.doFormatFlash = function () {520 oldDoFormatFlash.apply(this, arguments);521 this.setVariable('SHUTDOWN_MSG', L("FORMATTING_INTERNAL_MEMORY"));522 };523 var oldDoDeviceShutdown = kbook.model.doDeviceShutdown;524 kbook.model.doDeviceShutdown = function () {525 oldDoDeviceShutdown.apply(this, arguments);526 this.setVariable('SHUTDOWN_MSG', L("SHUTTING_DOWN"));527 };528529 // Pictures530 var oldOnEnterPicture = kbook.model.onEnterPicture;531 kbook.model.onEnterPicture = getPageChangedFunc("PICTURE_INDEX_COUNT", oldOnEnterPicture, L);532533 // Songs534 var oldPlaySong = kbook.model.playSong;535 kbook.model.playSong = getPageChangedFunc("SONG_INDEX_COUNT", oldPlaySong, L);536 };537538 var localizeMisc = function () {539 // mime types540 var obj = Core.system.getSoValue("FskCache.tree.infoListNode.prototypes.mime");541 var func = function (value) {542 if (value === 'application/rtf') {543 return L("RICH_TEXT_FORMAT");544 }545 if (value === 'application/pdf') {546 return L("ADOBE_PDF");547 }548 if (value === 'application/epub+zip') {549 return L("EPUB_DOCUMENT");550 }551 if (value === 'application/x-sony-bbeb') {552 return L("BBEB_BOOK");553 }554 if (value === 'text/plain') {555 return L("PLAIN_TEXT");556 }557 return value;558 };559 Core.system.setSoValue(obj, "format", func);560561 // internal memory / mem card562 obj = Core.system.getSoValue("FskCache.tree.infoListNode.prototypes.location");563 var oldFunc = Core.system.getFastSoValue(obj, "format");564 func = function () {565 var s = oldFunc.apply(this, arguments);566 switch (s) {567 case "Internal memory":568 return L("INTERNAL_MEMORY");569 case "Memory Stick":570 return L("MEMORY_STICK");571 case "SD Memory":572 return L("SD_CARD");573 }574 return s;575 };576 Core.system.setSoValue(obj, "format", func);577 };578579 var localizeAbout = function () {580 var setSoValue, getFastSoValue, about, records, i, n, sandbox, key, text;581 setSoValue = Core.system.setSoValue;582 getFastSoValue = Core.system.getFastSoValue;583 about = kbook.model.container.sandbox.ABOUT_GROUP.sandbox.ABOUT;584585 // Localize records586 records = Core.system.getSoValue(about, "data.records");587 for (i = 0, n = records.length; i < n; i++) {588 589 sandbox = getFastSoValue(records[i], "sandbox");590 if (i === 0) {591 // translate PRSP entry592 // kartu: not needed any more, done by core593 // key = "ABOUT_PRSP";594 // text = L(key);595 // text = text.replace("@@@firmware@@@", Core.version.firmware);596 } else {597 key = "ABOUT_" + i;598 text = L(key);599 setSoValue(sandbox, "text", text);600 }601 602 }603604 var oldGetValue = about.getValue;605 var authorizedSony = L("AUTHORIZED_SONY");606 var notAuthorizedSony = L("NOT_AUTHORIZED_SONY");607 var authorizedAdobe = L("AUTHORIZED_ADOBE");608 var notAuthorizedAdobe = L("NOT_AUTHORIZED_ADOBE");609 var sonyVersion = L("SONY_FW_VERSION") + ":";610 var deviceID = L("DEVICE_ID") + ":";611 about.getValue = function (record, field) {612 var result = oldGetValue.apply(this, arguments);613 if (field === "text") {614 if (record.kind === 0) {615 result = result.replace("Authorized for the eBook Store.", authorizedSony);616 result = result.replace("Not authorized for the eBook Store.", notAuthorizedSony);617 result = result.replace("Version:", sonyVersion);618 result = result.replace("Device:", deviceID);619 } else if (record.kind === 1) {620 result = result.replace("This device is authorized for Adobe DRM protected content.", authorizedAdobe);621 result = result.replace("This device is not authorized for Adobe DRM protected content.", notAuthorizedAdobe);622 }623 }624 return result;625 };626627 // Localize page index628 var oldPageChanged = about.pageChanged;629 about.pageChanged = getPageChangedFunc("ABOUT_INDEX_COUNT", oldPageChanged, L);630631 // Localize title632 var aboutTitle = L("ABOUT");633 about.getTitle = function() {634 return aboutTitle;635 };636637 // Recalculate box sizes638 about.dataChanged();639 };640641 localizeDefaultUI = function () {642 var sony_str =_strings.Sony;643 var X = _strings.X;644 // Helper functions645 L = function (key, defValue) {646 if (sony_str.hasOwnProperty(key)) {647 return sony_str[key];648 } else {649 if (defValue !== undefined) {650 return defValue;651 } else {652 return key;653 }654 }655 };656 LF = function (key, param) {657 try {658 var strings = X[key]; 659 if (typeof strings !== undefined) {660 return xFunc(strings, param);661 }662 } catch (e) {663 log.error("when calling " + key + " with param " + param + ": " + e);664 }665 return key;666 };667 668 setStr = function (node, strID) {669 node._myname = node.title = L(strID);670 };671 settingsComment = function () {672 return LF("SETTINGS", this.length);673 };674 getPageChangedFunc = function(varName, oldFunc, L) {675 var model = kbook.model;676 var of = L("OF");677 return function() {678 oldFunc.apply(this, arguments);679 var s = model.getVariable(varName);680 if (s) {681 model.setVariable(varName, s.replace("of", of));682 }683 };684 };685686 localizeRoot();687 localizeSettings();688 localizeAdvancedSettings();689 localizeBook();690 localizeBookUtils();691 localizeBookByDate();692 localizeBookByTitleAndAuthor();693 localizeComments();694 localizeStatic();695 localizeKbook();696 localizeMisc();697 localizeAbout();698 localizeDate();699 };700701 localizeDefaultUI();702};
...
Settings.js
Source:Settings.js
1FccTVApp.frames.Settings = new Ext.Panel({2 scroll: 'vertical',3 items: [{4 xtype: 'form',5 items: [{6 xtype: 'fieldset',7 title: bundle.getText('app.setting.expire.title'),8 // instructions: 'Please enter the information above.',9 defaults: {10 labelWidth: '35%'11 },12 items: [{13 xtype: 'spinnerfield',14 id: 'settingExpireDate',15 label: bundle.getText('app.setting.expire.label'),16 minValue: 0,17 maxValue: 14,18 cycle: true,19 listeners: {20 change : function( cmp, newValue, oldValue ){21 FccTVApp.loadMask.show();22 Ext.Ajax.request({23 url: './changeMovieExpire.action',24 params: {25 expiredDate: newValue26 },27 success: function(response, opts) {28 FccTVApp.loadMask.hide();29 },30 failure: function(){31 FccTVApp.loadMask.hide();32 }33 });34 },35 spin : function( cmp, value, direction ){36 FccTVApp.loadMask.show();37 Ext.Ajax.request({38 url: './changeMovieExpire.action',39 params: {40 expiredDate: value41 },42 success: function(response, opts) {43 FccTVApp.loadMask.hide();44 },45 failure: function(){46 FccTVApp.loadMask.hide();47 }48 });49 } 50 }51 }]52 },{53 xtype: 'fieldset',54 title: bundle.getText('app.setting.hdd.format.title'),55 // instructions: 'Please enter the information above.',56 defaults: {57 labelWidth: '35%'58 },59 items: [{60 xtype: 'selectfield',61 id: 'settingHddId',62 name : 'settingHddId',63 label: bundle.getText('app.setting.hdd.list.label'),64 valueField : 'key',65 displayField : 'name',66 store : new Ext.data.JsonStore({67 model: 'HddModel',68 proxy: {69 type: 'ajax',70 url: './hddList.action'71 },72 autoLoad: true73 }),74 listeners:{75 change: function(){76 Ext.getCmp('settingHddFormat').setValue(0);77 }78 }79 },{80 xtype: 'togglefield',81 id: 'settingHddFormat',82 label: bundle.getText('app.setting.hdd.format.label'),83 listeners: {84 change : function (cmp, thumb, newValue, oldValue ){85 if(newValue == 1){86 87 Ext.Msg.confirm(bundle.getText('common.dialog.confirm'), bundle.getText('app.setting.hdd.format.confirmation'), function(clickedBtn){88 if (clickedBtn == "yes"){89 FccTVApp.loadMask.show();90 Ext.Ajax.request({91 url: './hddFormat.action',92 params: {93 key: Ext.getCmp('settingHddId').getValue()94 },95 success: function(response, opts) {96 FccTVApp.loadMask.hide();97 },98 failure: function(){99 FccTVApp.loadMask.hide();100 }101 });102 }else{103 cmp.setValue(0);104 }105 });106 }107 }108 }109 }]110 },{111 xtype: 'fieldset',112 title: bundle.getText('app.setting.device.reset.title'),113 // instructions: 'Please enter the information above.',114 defaults: {115 labelWidth: '35%'116 },117 items: [{118 xtype: 'togglefield',119 id: 'settingDeviceReset',120 label: bundle.getText('app.setting.device.reset.label'),121 listeners: {122 change : function (cmp, thumb, newValue, oldValue ){123 if(newValue == 1){124 Ext.Msg.confirm(bundle.getText('common.dialog.confirm'), bundle.getText('app.setting.device.reset.confirmation'), function(clickedBtn){125 if (clickedBtn == "yes"){126 FccTVApp.loadMask.show();127 Ext.Ajax.request({128 url: './deviceReset.action',129 success: function(response, opts) {130 FccTVApp.loadMask.hide();131 },132 failure: function(){133 FccTVApp.loadMask.hide();134 }135 });136 }else{137 cmp.setValue(0);138 }139 });140 141 }142 }143 }144 }]145 },{146 xtype: 'fieldset',147 title: bundle.getText('app.setting.device.shutdown.title'),148 // instructions: 'Please enter the information above.',149 defaults: {150 labelWidth: '35%'151 },152 items: [{153 xtype: 'togglefield',154 id: 'settingDeviceShutdown',155 label: bundle.getText('app.setting.device.shutdown.label'),156 listeners: {157 change : function (cmp, thumb, newValue, oldValue ){158 if(newValue == 1){159 Ext.Msg.confirm(bundle.getText('common.dialog.confirm'), bundle.getText('app.setting.device.shutdown.confirmation'), function(clickedBtn){160 if (clickedBtn == "yes"){161 FccTVApp.loadMask.show();162 Ext.Ajax.request({163 url: './deviceShutdown.action',164 success: function(response, opts) {165 FccTVApp.loadMask.hide();166 },167 failure: function(){168 FccTVApp.loadMask.hide();169 }170 });171 }else{172 cmp.setValue(0);173 }174 });175 }176 }177 }178 }]179 }]180 }],181 listeners: {182 activate: function(cmp){183 Ext.Ajax.request({184 url: './getMovieExpire.action',185 success: function(response, opts) {186 var obj = Ext.decode(response.responseText);187 Ext.getCmp('settingExpireDate').setValue(obj.value);188 },189 failure: function(){190 191 }192 });193 194 Ext.Ajax.request({195 url: './getMovieExpire.action',196 success: function(response, opts) {197 var obj = Ext.decode(response.responseText);198 Ext.getCmp('settingExpireDate').setValue(obj.value);199 },200 failure: function(){201 202 }203 });204 }205 }...
shutdown_menu.js
Source:shutdown_menu.js
1/*2behavioural layer for the `shutdown.html.tera` template,3corresponding to the web route `/shutdown`4 - intercept button clicks for reboot & shutdown5 - perform json api calls6 - update the dom7methods:8 PEACH_DEVICE.reboot();9 PEACH_DEVICE.shutdown();10 PEACH_DEVICE.flashMsg(status, msg);11*/12var PEACH_DEVICE = {};13// catch click of 'Reboot' button and make POST request14PEACH_DEVICE.reboot = function() {15 document.addEventListener('DOMContentLoaded', function() {16 var rebootDevice = document.getElementById('rebootBtn');17 if (rebootDevice) {18 rebootDevice.addEventListener('click', function(e) {19 // prevent redirect on button press (default behavior)20 e.preventDefault();21 // write reboot flash message22 PEACH_DEVICE.flashMsg("success", "Rebooting the device...");23 // send reboot_device POST request24 fetch("/api/v1/device/reboot", {25 method: "post",26 headers: {27 'Accept': 'application/json',28 'Content-Type': 'application/json'29 },30 })31 .then( (response) => {32 return response.json()33 })34 .then( (jsonData) => {35 console.log(jsonData.msg);36 // write json response message to ui37 PEACH_DEVICE.flashMsg(jsonData.status, jsonData.msg);38 })39 }, false);40 }41 });42}43// catch click of 'Shutdown' button and make POST request44PEACH_DEVICE.shutdown = function() {45 document.addEventListener('DOMContentLoaded', function() {46 var shutdownDevice = document.getElementById('shutdownBtn');47 if (shutdownDevice) {48 shutdownDevice.addEventListener('click', function(e) {49 // prevent form submission (default behavior)50 e.preventDefault();51 // write shutdown flash message52 PEACH_DEVICE.flashMsg("success", "Shutting down the device...");53 // send shutdown_device POST request54 fetch("/api/v1/device/shutdown", {55 method: "post",56 headers: {57 'Accept': 'application/json',58 'Content-Type': 'application/json'59 },60 })61 .then( (response) => {62 return response.json()63 })64 .then( (jsonData) => {65 console.log(jsonData.msg);66 // write json response message to ui67 PEACH_DEVICE.flashMsg(jsonData.status, jsonData.msg);68 })69 }, false);70 }71 });72}73// display a message by appending a paragraph element74PEACH_DEVICE.flashMsg = function(status, msg) {75 // set the class of the element according to status76 var elementClass;77 if (status === "success") {78 elementClass = "capsule center-text flash-message font-success";79 } else if (status === "info") {80 elementClass = "capsule center-text flash-message font-info";81 } else {82 elementClass = "capsule center-text flash-message font-failure";83 };84 var flashElement = document.getElementById("flashMsg");85 // if flashElement exists, update the class & text86 if (flashElement) {87 flashElement.className = elementClass;88 flashElement.innerText = msg;89 // if flashElement does not exist, create it, set id, class, text & append90 } else {91 // create new div for flash message92 var flashDiv = document.createElement("DIV");93 // set div attributes94 flashDiv.id = "flashMsg";95 flashDiv.className = elementClass;96 // add json response message to flash message div97 var flashMsg = document.createTextNode(msg);98 flashDiv.appendChild(flashMsg);99 // insert the flash message div below the button div100 var buttonDiv = document.getElementById("buttonDiv");101 // flashDiv will be added to the end since buttonDiv is the last102 // child within the parent element (card-container div)103 buttonDiv.parentNode.insertBefore(flashDiv, buttonDiv.nextSibling);104 }105}106var deviceInstance = PEACH_DEVICE;107deviceInstance.reboot();...
webdriveragent-e2e-specs.js
Source:webdriveragent-e2e-specs.js
...33 device = await getSimulator(simUdid);34 });35 after(async function () {36 this.timeout(MOCHA_TIMEOUT);37 await device.shutdown();38 await deleteDevice(device.udid);39 });40 describe('with running sim', function () {41 this.timeout(6 * 60 * 1000);42 beforeEach(async () => {43 await device.run();44 });45 afterEach(async () => {46 await device.shutdown();47 });48 it('should launch agent on a sim', async function () {49 let agent = new WebDriverAgent(xcodeVersion, getStartOpts(device));50 await agent.launch('sessionId');51 await request(testUrl);52 await agent.quit();53 });54 it('should fail if xcodebuild fails', async function () {55 // short timeout56 this.timeout(35 * 1000);57 let agent = new WebDriverAgent(xcodeVersion, getStartOpts(device));58 agent.createXcodeBuildSubProcess = async function () {59 let args = [60 '-workspace',...
index.js
Source:index.js
1import adb from 'adbkit'2const client = adb.createClient()3const debug = require('debug')('scrcpy')4const onDevices = sender => {5 client.trackDevices()6 .then(function (tracker) {7 tracker.on('add', function (device) {8 debug('Device %s was plugged in', device.id)9 client.listDevices().then(function (devices) {10 debug(devices)11 sender.send('devices', devices)12 })13 })14 tracker.on('remove', function (device) {15 debug('Device %s was unplugged', device.id)16 client.listDevices().then(function (devices) {17 debug(devices)18 sender.send('devices', devices)19 })20 })21 tracker.on('end', function () {22 debug('Tracking stopped')23 })24 })25 .catch(function (err) {26 debugor('Something went wrong:', err.stack)27 })28}29const connect = ({ sender }, args) => {30 const { id, ip } = args31 const success = 'Successfully opened wireless connection'32 const fail = 'Failed to open wireless connection'33 if (id) {34 client.tcpip(id)35 .then(function (port) {36 client.connect(ip, port).then(function (err) {37 if (err) {38 sender.send('connect', { success: false, message: fail })39 return40 }41 sender.send('connect', { success: true, message: success })42 }).catch(() => {43 sender.send('connect', { success: false, message: fail })44 })45 }).catch(() => {46 client.connect(ip).then(function (err) {47 if (err) {48 sender.send('connect', { success: false, message: fail })49 return50 }51 sender.send('connect', { success: true, message: success })52 }).catch(() => {53 sender.send('connect', { success: false, message: fail })54 })55 })56 } else {57 client.connect(ip).then(function (err) {58 if (err) {59 sender.send('connect', { success: false, message: fail })60 return61 }62 sender.send('connect', { success: true, message: success })63 }).catch(() => {64 sender.send('connect', { success: false, message: fail })65 })66 }67}68const disconnect = ({ sender }, ip) => {69 client.disconnect(ip).then(id => {70 debug(id)71 sender.send('connect', { success: false, message: 'Device shutdown succeeded' })72 }).catch(err => {73 debug(err)74 sender.send('connect', { success: false, message: 'Device shutdown failed' })75 })76}77export default {78 connect, disconnect, onDevices...
functions_3.js
Source:functions_3.js
1var searchData=2[3 ['delete_5fincarnation_138',['delete_incarnation',['../session__manager_8c.html#a18273cf2fcf61730e36b611412c0700d',1,'session_manager.c']]],4 ['delete_5fsession_139',['delete_session',['../session__manager_8c.html#a018bae728d08b5091b906f491019b6c6',1,'session_manager.c']]],5 ['delete_5fsession_5frcu_140',['delete_session_rcu',['../session__manager_8c.html#a34e2a89cc6c7c38749c5da0ef5c18fd8',1,'session_manager.c']]],6 ['device_5fioctl_141',['device_ioctl',['../device__sessionfs_8c.html#a72e3cac371d57c08b7a62d2cb9e13fb3',1,'device_sessionfs.c']]],7 ['device_5fread_142',['device_read',['../device__sessionfs_8c.html#a17d464f6af03df59ad31c4573d0ab986',1,'device_sessionfs.c']]],8 ['device_5fshutdown_143',['device_shutdown',['../libsessionfs_8c.html#a90056fe0af1a3324f823b6d9424a1824',1,'device_shutdown(void): libsessionfs.c'],['../libsessionfs_8h.html#a90056fe0af1a3324f823b6d9424a1824',1,'device_shutdown(void): libsessionfs.c']]],9 ['device_5fwrite_144',['device_write',['../device__sessionfs_8c.html#a2d6bff2892b490d459e42974bfd4be12',1,'device_sessionfs.c']]]...
device.js
Source:device.js
1// const path = require("path");2// const fs = require('fs');3const exec = require('child_process').exec;4// // const constants = require('./constants');5const device = {};6device.shutdown = function(cb) {7 exec('sudo shutdown -h now', {}, function(error, stdout, stderr) {8 console.log("device.shutdown");9 if (stdout)10 console.log(stdout);11 if (stderr)12 console.log(stderr);13 cb(error ? "Failed to shut down!" : false);14 });15};16device.setupWifi = function(ssid, password, cb) {17 if (!ssid)18 return cb("SSID is empty!");19 20 if (!password)21 return cb("Password is empty!");22 exec('sh wifi.sh "' + ssid + '" "' + password + '"', {}, function(error, stdout, stderr) {23 console.log("device.setupWifi");24 console.log(error ? stdout : stderr);25 cb(error ? "Failed to save WiFi credentials!" : "WiFi credentials saved: " + stdout.toString());26 });27};28device.getIp = function() {29 exec('ifconfig wlan0 | grep -oE "inet addr:([0-9.]+)\b" | sed -rn "s/inet addr:([0-9.]+)/\1/p"', {},30 function(error, stdout, stderr) {31 32 });33}...
devices.js
Source:devices.js
1import gql from 'graphql-tag'2// Subs3import { withFilter } from 'graphql-subscriptions'4import channels from '../channels'5import devices from '../connectors/devices'6export const types = gql`7extend type Query {8 devices: [Device]9}10extend type Mutation {11 deviceBoot (udid: String!): Device12 deviceShutdown (udid: String!): Device13 openUrl (udid: String!, url: String!): Boolean14}15extend type Subscription {16 devicesChanged: [Device]17}18type Device {19 name: String!20 udid: String!21 state: String!22}23`24export const resolvers = {25 Query: {26 devices: async () => await devices.getDevices(),27 },28 Mutation: {29 deviceBoot: (root, { udid }, context) => devices.boot(udid, context),30 deviceShutdown: (root, { udid }, context) => devices.shutdown(udid, context),31 openUrl: (root, { udid, url }, context) => devices.openUrl(udid, url)32 },33 Subscription: {34 devicesChanged: {35 subscribe: withFilter(36 (parent, args, { pubsub }) => pubsub.asyncIterator(channels.DEVICEDS_CHANGED),37 (payload, vars) => true38 )39 }40 }...
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 }).build();5 .executeScript('mobile: shutdown')6 .then(function () {7 console.log("Device has been shutdown");8 })9 .catch(function (err) {10 console.log("Error occurred while shutting down device");11 });12driver.quit();13var webdriver = require('selenium-webdriver');14var driver = new webdriver.Builder()15 .withCapabilities({16 }).build();17 .executeScript('mobile: reboot')18 .then(function () {19 console.log("Device has been rebooted");20 })21 .catch(function (err) {22 console.log("Error occurred while rebooting device");23 });24driver.quit();25var webdriver = require('selenium-webdriver');26var driver = new webdriver.Builder()27 .withCapabilities({28 }).build();
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6driver.sleep(3000);7driver.quit();8var webdriver = require('selenium-webdriver');9var driver = new webdriver.Builder()10 .withCapabilities({11 })12 .build();13driver.sleep(3000);14driver.quit();15var webdriver = require('selenium-webdriver');16var driver = new webdriver.Builder()17 .withCapabilities({18 })19 .build();20driver.sleep(3000);21driver.quit();22var webdriver = require('selenium-webdriver');23var driver = new webdriver.Builder()24 .withCapabilities({25 })26 .build();27driver.sleep(3000);28driver.quit();29var webdriver = require('selenium-webdriver');30var driver = new webdriver.Builder()31 .withCapabilities({
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .element('name', 'q')9 .setValue('Appium')10 .click()11 .pause(1000)12 .element('name', 'btnK')13 .click()14 .pause(1000)15 .element('name', 'btnK')16 .click()17 .pause(1000)18 .element('name', 'btnK')19 .click()20 .pause(1000)21 .element('name', 'btnK')22 .click()23 .pause(1000)24 .element('name', 'btnK')25 .click()26 .pause(1000)27 .element('name', 'btnK')28 .click()29 .pause(1000)30 .element('name', 'btnK')31 .click()32 .pause(1000)33 .element('name', 'btnK')34 .click()35 .pause(1000)36 .element('name', 'btnK')37 .click()38 .pause(1000)39 .element('name', 'btnK')40 .click()41 .pause(1000)42 .deviceShutdown()43 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .then(function() {9 return client.execute('mobile: shutdown');10 })11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 }16};17var client = webdriverio.remote(options);18 .init()19 .then(function() {20 return client.execute('mobile: reboot');21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28var client = webdriverio.remote(options);29 .init()30 .then(function() {31 return client.execute('mobile: launchApp', {bundleId: 'com.apple.Preferences'});32 })33 .end();34var webdriverio = require('webdriverio');35var options = {36 desiredCapabilities: {37 }38};39var client = webdriverio.remote(options);40 .init()41 .then(function() {42 return client.execute('mobile: terminateApp
Using AI Code Generation
1const wdio = require('webdriverio');2const opts = {3 capabilities: {4 }5};6const client = wdio.remote(opts);7client.init().then(() => {8 client.execute('mobile: shutdown');9 client.deleteSession();10});11const wdio = require('webdriverio');12const opts = {13 capabilities: {14 }15};16const client = wdio.remote(opts);17client.init().then(() => {18 client.execute('mobile: reboot');19 client.deleteSession();20});21const wdio = require('webdriverio');22const opts = {23 capabilities: {24 }25};26const client = wdio.remote(opts);27client.init().then(() => {28 client.execute('mobile: lock');29 client.deleteSession();30});31const wdio = require('webdriverio');32const opts = {33 capabilities: {
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('xcuitest')4 .build();5driver.executeScript('mobile: device: shutdown', {});6driver.quit();7var webdriver = require('selenium-webdriver');8var driver = new webdriver.Builder()9 .forBrowser('xcuitest')10 .build();11driver.executeScript('mobile: device: lock', {});12driver.quit();13var webdriver = require('selenium-webdriver');14var driver = new webdriver.Builder()15 .forBrowser('xcuitest')16 .build();17driver.executeScript('mobile: device: unlock', {});18driver.quit();19var webdriver = require('selenium-webdriver');20var driver = new webdriver.Builder()21 .forBrowser('xcuitest')22 .build();23driver.executeScript('mobile: device: isLocked', {});24driver.quit();25var webdriver = require('selenium-webdriver');26var driver = new webdriver.Builder()27 .forBrowser('xcuitest')28 .build();29driver.executeScript('mobile: device: openNotifications', {});30driver.quit();31var webdriver = require('selenium-webdriver');32var driver = new webdriver.Builder()33 .forBrowser('xcuitest')34 .build();35driver.executeScript('mobile: device: hideKeyboard', {});36driver.quit();37var webdriver = require('selenium-webdriver');38var driver = new webdriver.Builder()39 .forBrowser('xcuitest')40 .build();
Using AI Code Generation
1driver.device.shutdown();2driver.device.restart();3driver.device.lock();4driver.device.unlock();5driver.device.isLocked();6driver.device.isUnlocked();7driver.device.toggleAirplaneMode();8driver.device.toggleData();9driver.device.toggleWifi();10driver.device.toggleLocationServices();11driver.device.openNotifications();12driver.device.sendSMS();13driver.device.gsmCall();14driver.device.gsmSignal();15driver.device.gsmVoice();16driver.device.installApp();17driver.device.removeApp();18driver.device.activateApp();
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6 .executeScript('mobile: deviceShutdown', {timeout: 5000})7 .then(function () {8 console.log('Device shutdown');9 })10 .catch(function (err) {11 console.log('Error occurred while shutting down device', err);12 })13 .then(function () {14 driver.quit();15 });16appium --log-level debug --log-timestamp --show-ios-log --platform-version 10.2 --platform-name iOS --automation-name XCUITest --app /Users/username/Library/Developer/Xcode/DerivedData/MyApp-dwzqgjxqjzqzvzgjyfzqjzqzqjxq/Build/Products/Debug-iphonesimulator/MyApp.app --native-instruments-lib --default-capabilities '{"bundleId":"com.mycompany.myapp"}' --session-override --no-reset --full-reset
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!