123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486 |
- /*!
- * ngCordova
- * v0.1.27-alpha
- * Copyright 2015 Drifty Co. http://drifty.com/
- * See LICENSE in this repository for license information
- */
- (function(){
- var ngCordovaMocks = angular.module('ngCordovaMocks', []);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaActionSheet
- *
- * @description
- * A service for testing action sheet
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaActionSheet', ['$q', function ($q) {
- var throwsError = false;
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaActionSheet
- * @type Boolean
- *
- * @description
- * A flag that signals whether a promise should be rejected.
- * This property should only be used in automated tests
- */
- throwsError: throwsError,
- show: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error on showing action sheet');
- } else {
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- ngCordovaMocks.factory('$cordovaAppVersion', ['$q', function ($q) {
- var throwsError = false;
- return {
- throwsError: throwsError,
- getAppName: function () {
- var q = $q.defer();
- q.resolve('mock app name');
- return q.promise;
- },
- getPackageName: function () {
- var q = $q.defer();
- q.resolve('com.package.mock');
- return q.promise;
- },
- getVersionNumber: function () {
- var q = $q.defer();
- q.resolve('1.2.3');
- return q.promise;
- },
- getVersionCode: function () {
- var q = $q.defer();
- q.resolve('4.5.6');
- return q.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaBarcodeScanner
- *
- * @description
- * A service for testing barcode scanner features
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaBarcodeScanner', ['$q', function ($q) {
- var throwsError = false;
- var scannedText = '';
- var scannedFormat = '';
- var wasCancelled = false;
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaBarcodeScanner
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- /**
- * @ngdoc property
- * @name scannedText
- * @propertyOf ngCordovaMocks.cordovaBarcodeScanner
- *
- * @description
- * Used to simulate the result.text property of a
- * successful scan. For more information, see the text at
- * https://github.com/wildabeast/BarcodeScanner/#using-the-plugin
- * This property should only be used in automated tests.
- **/
- scannedText: scannedText,
- /**
- * @ngdoc property
- * @name scannedFormat
- * @propertyOf ngCordovaMocks.cordovaBarcodeScanner
- * @description
- * Used to simulate the result.format property of a
- * successful scan. For more information, see the text at
- * https://github.com/wildabeast/BarcodeScanner/#using-the-plugin
- * This property should only be used in automated tests.
- **/
- scannedFormat: scannedFormat,
- /**
- * @ngdoc property
- * @name wasCancelled
- * @propertyOf ngCordovaMocks.cordovaBarcodeScanner
- *
- * @description
- * Used to simulate the result.cancelled property of a
- * successful scan. For more information, see the text at
- * https://github.com/wildabeast/BarcodeScanner/#using-the-plugin
- * This property should only be used in automated tests.
- **/
- wasCancelled: wasCancelled,
- scan: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error scanning.');
- } else {
- defer.resolve({text: this.scannedText, format: this.scannedFormat, cancelled: this.wasCancelled});
- }
- return defer.promise;
- },
- encode: function (type, data) {
- this.scannedFormat = type;
- this.scannedText = data;
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error encoding the data.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaBLE
- *
- * @description
- * A service for ble features
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaBLE', ['$q', '$timeout', '$interval', '$log', function ($q, $timeout, $interval, $log) {
- var deviceScan = {
- name: 'Test Device',
- id: 'AA:BB:CC:DD:EE:FF',
- advertising: [2, 1, 6, 3, 3, 15, 24, 8, 9, 66, 97, 116, 116, 101, 114, 121],
- rssi: -55
- };
- var deviceConnect = {
- name: 'Test Device',
- id: 'AA:BB:CC:DD:EE:FF',
- advertising: [2, 1, 6, 3, 3, 15, 24, 8, 9, 66, 97, 116, 116, 101, 114, 121],
- rssi: -55,
- services: [
- '1800',
- '1801',
- '180f'
- ],
- characteristics: [
- {
- service: '1800',
- characteristic: '2a00',
- properties: ['Read']
- },
- {
- service: '1800',
- characteristic: '2a01',
- properties: ['Read']
- },
- {
- service: '1801',
- characteristic: '2a05',
- properties: ['Read']
- },
- {
- service: '180f',
- characteristic: '2a19',
- properties: ['Read'],
- descriptors: [{'uuid': '2901'}, {'uuid': '2904'}]
- }
- ]
- };
- var readData = new ArrayBuffer(8);
- return {
- scan: function (services, seconds) {
- var q = $q.defer();
- // first notify about discovered device
- $timeout(function () {
- q.notify(deviceScan);
- }, Math.round(seconds * 1000 * Math.random()));
- // end scan
- $timeout(function () {
- q.resolve();
- }, seconds * 1000);
- return q.promise;
- },
- startScan: function (services, callback, errorCallback) {
- $timeout(function () {
- callback(deviceScan);
- }, Math.round(1000 * Math.random()));
- },
- stopScan: function () {
- var q = $q.defer();
- $timeout(function () {
- q.resolve();
- }, 500);
- return q.promise;
- },
- connect: function (deviceID) {
- var q = $q.defer();
- $timeout(function () {
- q.resolve(deviceConnect);
- }, 1500);
- return q.promise;
- },
- disconnect: function (deviceID) {
- var q = $q.defer();
- $timeout(function () {
- q.resolve(true);
- }, 500);
- return q.promise;
- },
- read: function (deviceID, serviceUUID, characteristicUUID) {
- var q = $q.defer();
- $timeout(function () {
- q.resolve(readData);
- }, 100);
- return q.promise;
- },
- write: function (deviceID, serviceUUID, characteristicUUID, data) {
- var q = $q.defer();
- $timeout(function () {
- q.resolve(true);
- }, 100);
- return q.promise;
- },
- writeWithoutResponse: function (deviceID, serviceUUID, characteristicUUID, data) {
- var q = $q.defer();
- $timeout(function () {
- q.resolve(true);
- }, 100);
- return q.promise;
- },
- writeCommand: function (deviceID, serviceUUID, characteristicUUID, data) {
- $log.warning('writeCommand is deprecated, use writeWithoutResponse');
- return this.writeWithoutResponse(deviceID, serviceUUID, characteristicUUID, data);
- },
- startNotification: function (deviceID, serviceUUID, characteristicUUID, callback, errorCallback) {
- $interval(function () {
- var data = new Uint8Array([Math.round(255 * Math.random())]); // one byte with random number
- callback(data);
- }, 200, 10); // repeat 10 times with 200 ms delay for each
- },
- stopNotification: function (deviceID, serviceUUID, characteristicUUID) {
- var q = $q.defer();
- $timeout(function () {
- q.resolve();
- }, 100);
- return q.promise;
- },
- isConnected: function (deviceID) {
- var q = $q.defer();
- q.resolve(true);
- return q.promise;
- },
- enable: function () {
- var q = $q.defer();
- $timeout(function () {
- q.resolve();
- }, 1500);
- return q.promise;
- },
- isEnabled: function () {
- var q = $q.defer();
- q.resolve(true);
- return q.promise;
- }
- };
- }]);
- ngCordovaMocks.factory('$cordovaBrightness', ['$q', function ($q) {
- var currentBrightness = 100;
- return {
- get: function () {
- var q = $q.defer();
- q.resolve(currentBrightness);
- return q.promise;
- },
- set: function (data) {
- var q = $q.defer();
- currentBrightness = data;
- q.resolve('OK');
- return q.promise;
- },
- setKeepScreenOn: function (bool) {
- var q = $q.defer();
- q.resolve('OK');
- return q.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaCamera
- *
- * @description
- * A service for testing camera features
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaCamera', ['$q', function ($q) {
- var throwsError = false;
- var imageData = '';
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaCamera
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- /**
- * @ngdoc property
- * @name imageData
- * @propertyOf ngCordovaMocks.cordovaCamera
- *
- * @description
- * The imagedata (e.g. an url) which will be returned from the device.
- * This property should only be used in automated tests.
- **/
- imageData: imageData,
- getPicture: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the picture.');
- } else {
- if (options) {
- options = options; // This is just to get by JSHint.
- }
- defer.resolve(this.imageData);
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaCapture
- *
- * @description
- * A service for testing media capture
- * in an app build with ngCordova.
- *
- * @example
- */
- ngCordovaMocks.factory('$cordovaCapture', ['$q', function ($q) {
- var throwsError = false;
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaCapture
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- captureAudio: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error capturing the audio.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- captureImage: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error capturing the image.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- captureVideo: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error capturing the video.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaContacts
- *
- * @description
- * A service for testing features related with contacts
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaContacts', ['$q', function ($q) {
- var throwsError = false;
- var contacts = [];
- return {
- /**
- @ngdoc property
- @name throwsError
- @propertyOf ngCordovaMocks.cordovaContacts
- @description
- A flag that signals whether a promise should be rejected or not.
- This property should only be used in automated tests.
- */
- throwsError: throwsError,
- /**
- @ngdoc contacts
- @name throwsError
- @propertyOf ngCordovaMocks.cordovaContacts
- @description
- An in-memory collection of contacts.
- This property should only be used in automated tests.
- */
- contacts: contacts,
- save: function (contact) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error saving the contact.');
- } else {
- var existingIndex = null;
- for (var i = 0; i < this.contacts.length; i++) {
- // The actual implementation relies on the entire object match.
- // we're gong to rely on the ID.
- if (this.contacts[i].id === contact.id) {
- existingIndex = i;
- break;
- }
- }
- if (existingIndex === null) {
- this.contacts.push(contact);
- defer.resolve();
- } else {
- defer.reject('Contact already exists.');
- }
- }
- return defer.promise;
- },
- remove: function (contact) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error saving the contact.');
- } else {
- var toRemove = null;
- for (var i = 0; i < this.contacts.length; i++) {
- // The actual implementation relies on the entire object match.
- // we're gong to rely on the ID.
- if (this.contacts[i].id === contact.id) {
- toRemove = i;
- break;
- }
- }
- if (toRemove === null) {
- defer.reject('Unable to find contact.');
- } else {
- this.contacts.splice(toRemove, 1);
- defer.resolve();
- }
- }
- return defer.promise;
- },
- find: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error finding the contact.');
- } else {
- var fields = options.fields || ['id', 'displayName'];
- delete options.fields;
- if (!fields) {
- defer.reject('ContactError.INVALID_ARGUMENT_ERROR');
- } else {
- if (fields === '*') {
- defer.resolve(this.contacts);
- } else {
- // Implement a very rudimentary search approach for testing purposes.
- // This is NOT exhaustive.
- var results = [];
- for (var i = 0; i < this.contacts.length; i++) {
- for (var key in this.contacts[i]) {
- var propertyValue = this.contacts[i][key];
- }
- }
- // TODO: Search by individual fields
- defer.resolve(results);
- }
- }
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaDatePicker
- *
- * @description
- * A service for testing datepicker features
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaDatePicker', ['$q', function ($q) {
- return {
- show: function (options) {
- var q = $q.defer();
- options = options || {date: new Date(), mode: 'date'};
- q.resolve(options.date);
- return q.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaDevice
- *
- * @description
- * A service for testing device information
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaDevice', function () {
- var device = '';
- var cordova = '';
- var model = '';
- var platform = '';
- var uuid = '';
- var version = '';
- return {
- /**
- @ngdoc property
- @name device
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The name of the 'device'.
- This property should only be used in automated tests.
- */
- device: device,
- /**
- @ngdoc property
- @name cordova
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The version of cordova in use.
- This property should only be used in automated tests.
- */
- cordova: cordova,
- /**
- @ngdoc property
- @name model
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The model of the device using the app.
- This property should only be used in automated tests.
- */
- model: model,
- /**
- @ngdoc property
- @name platform
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The name of the operating system in use.
- This property should only be used in automated tests.
- */
- platform: platform,
- /**
- @ngdoc property
- @name uuid
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The unique identifier of a device.
- This property should only be used in automated tests.
- */
- uuid: uuid,
- /**
- @ngdoc property
- @name version
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The version of the operating system.
- This property should only be used in automated tests.
- */
- version: version,
- /**
- @ngdoc property
- @name manufacturer
- @propertyOf ngCordovaMocks.cordovaDevice
- @description
- The manufacturer of the device.
- This property should only be used in automated tests.
- */
- version: version,
- getDevice: function () {
- return this.device;
- },
- getCordova: function () {
- return this.cordova;
- },
- getModel: function () {
- return this.model;
- },
- getPlatform: function () {
- return this.platform;
- },
- getUUID: function () {
- return this.uuid;
- },
- getVersion: function () {
- return this.version;
- },
- getManufacturer: function () {
- return this.manufacturer;
- }
- };
- });
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaDeviceMotion
- *
- * @description
- * A service for mocking the accelerometer
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaDeviceMotion', ['$interval', '$q', function ($interval, $q) {
- var currentAcceleration = null;
- var throwsError = false;
- var positions = [];
- var watchIntervals = [];
- return {
- /**
- * @ngdoc property
- * @name currentAcceleration
- * @propertyOf ngCordovaMocks.cordovaDeviceMotion
- *
- * @description
- * The current acceleration.
- * This property should only be used in automated tests.
- **/
- currentAcceleration: currentAcceleration,
- /**
- @ngdoc property
- @name throwsError
- @propertyOf ngCordovaMocks.cordovaDeviceMotion
- @description
- A flag that signals whether a promise should be rejected or not.
- This property should only be used in automated tests.
- */
- throwsError: throwsError,
- /**
- @ngdoc property
- @name positions
- @propertyOf ngCordovaMocks.cordovaDeviceMotion
- @description
- The collection of 'positions' that have been logged.
- This property should only be used in automated tests.
- */
- positions: positions,
- /**
- @ngdoc property
- @name watchIntervals
- @propertyOf ngCordovaMocks.cordovaDeviceMotion
- @description
- The collection of watchers that are currently active.
- This property should only be used in automated tests.
- */
- watchIntervals: watchIntervals,
- getCurrentAcceleration: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the current acceleration.');
- } else {
- defer.resolve(this.currentAcceleration);
- }
- return defer.promise;
- },
- watchAcceleration: function (options) {
- var defer = $q.defer();
- var watchId = Math.floor((Math.random() * 1000000) + 1);
- this.positions = [];
- self = this;
- if (this.throwsError) {
- defer.reject('There was an error watching the current acceleration.');
- } else {
- var delay = 10000; // The default based on https://github.com/apache/cordova-plugin-device-motion
- if (options && options.frequency) {
- delay = options.frequency;
- }
- this.watchIntervals.push($interval(
- function () {
- if (self.throwsError) {
- defer.reject('There was an error watching the acceleration.');
- }
- // Generate a random position
- var randomX = Math.floor((Math.random() * 100) + 1);
- var randomY = Math.floor((Math.random() * 100) + 1);
- var randomZ = Math.floor((Math.random() * 100) + 1);
- var result = {x: randomX, y: randomY, z: randomZ, timestamp: Date.now()};
- self.positions.push(result);
- defer.notify(result);
- },
- delay
- ));
- }
- return {
- watchId: watchId,
- promise: defer.promise
- };
- },
- clearWatch: function (watchId) {
- var defer = $q.defer();
- if (watchId) {
- if (this.throwsError) {
- defer.reject('Unable to clear watch.');
- } else {
- var removed = -1;
- for (var i = 0; i < this.watchIntervals.length; i++) {
- if (this.watchIntervals[i].watchId === watchId) {
- $interval.cancel(watchIntervals[i].interval);
- removed = i;
- break;
- }
- }
- if (removed !== -1) {
- this.watchIntervals.splice(removed, 1);
- }
- }
- } else {
- defer.reject('Unable to clear watch. No watch ID provided.');
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaDeviceOrientation
- *
- * @description
- * A service for testing compass fetures
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaDeviceOrientation', ['$interval', '$q', function ($interval, $q) {
- var currentHeading = null;
- var throwsError = false;
- var readings = [];
- var watchIntervals = [];
- return {
- /**
- * @ngdoc property
- * @name currentHeading
- * @propertyOf ngCordovaMocks.cordovaDeviceOrientation
- *
- * @description
- * The current heading.
- * This property should only be used in automated tests.
- **/
- currentHeading: currentHeading,
- /**
- @ngdoc property
- @name throwsError
- @propertyOf ngCordovaMocks.cordovaDeviceOrientation
- @description
- A flag that signals whether a promise should be rejected or not.
- This property should only be used in automated tests.
- */
- throwsError: throwsError,
- /**
- @ngdoc property
- @name positions
- @propertyOf ngCordovaMocks.cordovaDeviceOrientation
- @description
- The collection of compass 'readings' that have been logged.
- This property should only be used in automated tests.
- */
- readings: readings,
- /**
- @ngdoc property
- @name watchIntervals
- @propertyOf ngCordovaMocks.cordovaDeviceOrientation
- @description
- The collection of watchers that are currently active.
- This property should only be used in automated tests.
- */
- watchIntervals: watchIntervals,
- getCurrentHeading: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the current heading.');
- } else {
- defer.resolve(this.currentHeading);
- }
- return defer.promise;
- },
- watchHeading: function (options) {
- var defer = $q.defer();
- var watchID = Math.floor((Math.random() * 1000000) + 1);
- var self = this;
- self.readings = [];
- if (self.throwsError) {
- defer.reject('There was an error getting the compass heading.');
- } else {
- var delay = 100; // The default based on https://github.com/apache/cordova-plugin-device-orientation
- if (options && options.frequency) {
- delay = options.frequency;
- }
- self.watchIntervals.push({
- watchID: watchID,
- interval: $interval(
- function () {
- if (self.throwsError) {
- defer.reject('There was an error watching the acceleration.');
- }
- // Generate a random position
- var magneticHeading = (Math.random() * 359.99) + 1;
- var trueHeading = (Math.random() * 359.99) + 1;
- var headingAccuracy = Math.floor((Math.random() * 360) + 1);
- var result = {magneticHeading: magneticHeading, trueHeading: trueHeading, headingAccuracy: headingAccuracy, timestamp: Date.now()};
- self.readings.push(result);
- defer.notify(result);
- },
- delay
- )
- });
- }
- var cancel = function (id) {
- var removed = -1;
- for (var i = 0; i < self.watchIntervals.length; i++) {
- if (self.watchIntervals[i].watchID === id) {
- $interval.cancel(watchIntervals[i].interval);
- removed = i;
- break;
- }
- }
- if (removed !== -1) {
- self.watchIntervals.splice(removed, 1);
- }
- };
- defer.promise.cancel = function () {
- cancel(watchID);
- };
- defer.promise.clearWatch = function (id) {
- cancel(id || watchID);
- };
- defer.promise.watchID = watchID;
- return defer.promise;
- },
- clearWatch: function (watchId) {
- var defer = $q.defer();
- if (watchId) {
- if (this.throwsError) {
- defer.reject('Unable to clear watch.');
- } else {
- var removed = -1;
- for (var i = 0; i < this.watchIntervals.length; i++) {
- if (this.watchIntervals[i].watchId === watchId) {
- $interval.cancel(watchIntervals[i].interval);
- removed = i;
- break;
- }
- }
- if (removed !== -1) {
- this.watchIntervals.splice(removed, 1);
- }
- }
- } else {
- defer.reject('Unable to clear watch. No watch ID provided.');
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaDialogs
- *
- * @description
- * A service for testing dialogs
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaDialogs', ['$q', function ($q) {
- var dialogText = false;
- var dialogTitle = '';
- var defaultValue = '';
- var promptResponse = '';
- var beepCount = 0;
- var useHostAbilities = true;
- return {
- /**
- @ngdoc property
- @name dialogText
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- The main content in the dialog.
- This property should only be used in automated tests.
- */
- dialogText: dialogText,
- /**
- @ngdoc property
- @name dialogTitle
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- The title of the dialog.
- This property should only be used in automated tests.
- */
- dialogTitle: dialogTitle,
- /**
- @ngdoc property
- @name defaultValue
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- The default value to be used in a prompt.
- This property should only be used in automated tests.
- */
- defaultValue: defaultValue,
- /**
- @ngdoc property
- @name promptResponse
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- Used to simulate a user's response to a prompt.
- This property should only be used in automated tests.
- */
- promptResponse: promptResponse,
- /**
- @ngdoc property
- @name buttonLabels
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- An array of the text of each button in the dialog.
- This property should only be used in automated tests.
- */
- buttonLabels: [],
- /**
- @ngdoc property
- @name beepCount
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- The number of times a beep has occurred.
- This property should only be used in automated tests.
- */
- beepCount: beepCount,
- /**
- @ngdoc property
- @name useHostAbilities
- @propertyOf ngCordovaMocks.cordovaDialogs
- @description
- A flag that signals whether or not to try and use the host's
- (browser or otherwise) prompting capabilities.
- This property should only be used in automated tests.
- */
- useHostAbilities: useHostAbilities,
- alert: function (message, title, buttonName) {
- var d = $q.defer();
- if (this.useHostAbilities) {
- // NOTE: The window.alert method doesn't support a title or callbacks.
- alert(message);
- d.resolve();
- } else {
- this.dialogText = message;
- this.dialogTitle = title;
- this.buttonLabels.push(buttonName);
- d.resolve();
- }
- return d.promise;
- },
- confirm: function (message, title, buttonName) {
- var d = $q.defer();
- if (this.useHostAbilities) {
- // NOTE: The window.confirm method doesn't support a title or custom button naming.
- var result = confirm(message);
- d.resolve(result ? 2 : 1);
- } else {
- this.dialogText = message;
- this.dialogTitle = title;
- this.buttonLabels.push(buttonName);
- d.resolve(0);
- }
- return d.promise;
- },
- prompt: function (message, title, buttonLabels, defaultText) {
- var d = $q.defer();
- if (this.useHostAbilities) {
- // NOTE: The window.prompt method doesn't support a title or custom button naming.
- var result = prompt(message, defaultText);
- d.resolve(result);
- } else {
- this.dialogText = message;
- this.dialogTitle = title;
- this.defaultValue = defaultText;
- for (var i = 0; i < buttonLabels.length; i++) {
- this.buttonLabels.push(buttonLabels[i]);
- }
- d.resolve(this.promptResponse);
- }
- return d.promise;
- },
- beep: function (times) {
- this.beepCount = times;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaFacebook
- *
- * @description
- * A service for testing Facebook features
- * in an app built with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaFacebook', ['$q', function ($q) {
- return {
- /**
- * These properties are here for the purpose of automated testing only.
- **/
- loginShouldSucceedWith: null,
- showDialogShouldSucceedWith: null,
- apiShouldSucceedWith: null,
- getAccessTokenShouldSucceedWith: null,
- getLoginStatusShouldSucceedWith: null,
- logoutShouldSuceedWith: null,
- login: function (permissions) {
- if (this.loginShouldSucceedWith !== null) {
- return $q.when(this.loginShouldSucceedWith);
- } else {
- return $q.reject();
- }
- },
- showDialog: function (options) {
- if (this.showDialogShouldSucceedWith !== null) {
- return $q.when(this.showDialogShouldSucceedWith);
- } else {
- return $q.reject();
- }
- },
- api: function (path, permissions) {
- if (this.apiShouldSucceedWith !== null) {
- return $q.when(this.apiShouldSucceedWith);
- } else {
- return $q.reject();
- }
- },
- getAccessToken: function () {
- if (this.getAccessTokenShouldSucceedWith !== null) {
- return $q.when(this.getAccessTokenShouldSucceedWith);
- } else {
- return $q.reject();
- }
- },
- getLoginStatus: function () {
- if (this.getLoginStatusShouldSucceedWith !== null) {
- return $q.when(this.getLoginStatusShouldSucceedWith);
- } else {
- return $q.reject();
- }
- },
- logout: function () {
- if (this.logoutShouldSuceedWith !== null) {
- return $q.when(this.logoutShouldSuceedWith);
- } else {
- return $q.reject();
- }
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaFile
- *
- * @description
- * A service for testing interaction with device directories and files
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaFile', ['$q', function ($q) {
- var throwsError = false;
- var fileSystem = {};
- var shouldMockFiles = false;
- var files = {};
- var mockIt = function (errorMessage) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject(errorMessage);
- } else {
- defer.resolve();
- }
- return defer.promise;
- };
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaFile
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- /**
- * @ngdoc property
- * @name fileSystem
- * @propertyOf ngCordovaMocks.cordovaFile
- *
- * @description
- * A fake, in-memory file system. This is incomplete at this time.
- * This property should only be used in automated tests.
- **/
- fileSystem: fileSystem,
- /**
- * @ngdoc property
- * @name shouldMockFiles
- * @propertyOf ngCordovaMocks.cordovaFile
- *
- * @description
- * A flag that signals whether one wish to mock files.
- * This is useful if you need mocks specific file scenarios.
- * This property should only be used in automated tests.
- **/
- shouldMockFiles: shouldMockFiles,
- /**
- * @ngdoc property
- * @name files
- * @propertyOf ngCordovaMocks.cordovaFile
- *
- * @description
- * An object that may be used for mocking files on the device.
- * This property should only be used in automated tests.
- *
- * **/
- files: files,
- checkDir: function (directory) {
- if (this.shouldMockFiles) {
- var defer = $q.defer();
- if (this.files[directory] && !this.files[directory].isFile) {
- defer.resolve();
- } else {
- defer.reject();
- }
- return defer.promise;
- }
- return mockIt.call(this, 'There was an error checking the directory.');
- },
- createDir: function (directory, overwrite) {
- if (this.shouldMockFiles) {
- var defer = $q.defer();
- this.files[directory] = {isFile: false};
- defer.resolve();
- return defer.promise;
- }
- return mockIt.call(this, 'There was an error creating the directory.');
- },
- listDir: function (filePath) {
- return mockIt.call(this, 'There was an error listing the directory');
- },
- checkFile: function (filePath) {
- if (this.shouldMockFiles) {
- var defer = $q.defer();
- if (this.files[filePath] && this.files[filePath].isFile) {
- defer.resolve();
- } else {
- defer.reject();
- }
- return defer.promise;
- }
- return mockIt.call(this, 'There was an error checking for the file.');
- },
- createFile: function (filePath, overwrite) {
- if (this.shouldMockFiles) {
- var defer = $q.defer();
- this.files[filePath] = {
- isFile: true,
- fileContent: ''
- };
- defer.resolve();
- return defer.promise;
- }
- return mockIt.call(this, 'There was an error creating the file.');
- },
- removeFile: function (directory, file) {
- return mockIt.call(this, 'There was an error removng the file.');
- },
- writeFile: function (filePath, data, options) {
- if (this.shouldMockFiles && filePath && data) {
- this.files[filePath] = {
- isFile: true,
- fileContent: data
- };
- }
- return mockIt.call(this, 'There was an error writing the file.');
- },
- readFile: function (filePath) {
- return this.readAsText(filePath);
- },
- readAsText: function (filePath) {
- if (this.shouldMockFiles) {
- var defer = $q.defer();
- if (files[filePath] && files[filePath].isFile) {
- defer.resolve(files[filePath].fileContent);
- } else {
- defer.reject();
- }
- return defer.promise;
- }
- return mockIt.call(this, 'There was an error reading the file as text.');
- },
- readAsDataURL: function (filePath) {
- return mockIt.call(this, 'There was an error reading the file as a data url.');
- },
- readAsBinaryString: function (filePath) {
- return mockIt.call(this, 'There was an error reading the file as a binary string.');
- },
- readAsArrayBuffer: function (filePath) {
- return mockIt.call(this, 'There was an error reading the file as an array buffer.');
- },
- readFileMetadata: function (filePath) {
- return mockIt.call(this, 'There was an error reading the file metadata');
- },
- readFileAbsolute: function (filePath) {
- return mockIt.call(this, 'There was an error reading the file from the absolute path');
- },
- readFileMetadataAbsolute: function (filePath) {
- return mockIt.call(this, 'There was an error reading the file metadta from the absolute path');
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaFileOpener2
- *
- * @description
- * A service for testing fileOpener2
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaFileOpener2', ['$q', function ($q) {
- var throwsError = false;
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaFileOpener2
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- open: function (file, type) {
- var defer = $q.defer();
- if (this.throwError) {
- defer.reject({
- status: 0,
- message: 'There was an error capturing the file.'
- });
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- uninstall: function (pack) {
- var defer = $q.defer();
- if (this.throwError) {
- defer.reject({
- status: 0,
- message: 'There was an error capturing the packageId.'
- });
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- appIsInstalled: function (pack) {
- var defer = $q.defer();
- if (this.throwError) {
- defer.reject({
- status: 0,
- message: 'There was an error capturing the packageId.'
- });
- } else {
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaFileTransfer
- *
- * @description
- * A service for testing download and upload
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaFileTransfer', ['$q', function ($q) {
- var throwsError = false;
- var mockIt = function (errorMessage) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject(errorMessage);
- } else {
- defer.resolve();
- }
- return defer.promise;
- };
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaFileTransfer
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- download: function (source, filePath, options, trust) {
- return mockIt.call(this, 'There was an error downloading the file.');
- },
- upload: function (server, filePath, options) {
- return mockIt.call(this, 'There was an error uploading the file.');
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaGeolocation
- *
- * @description
- * A service for testing location services
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaGeolocation', ['$interval', '$q', function ($interval, $q) {
- var throwsError = false;
- var useHostAbilities = true;
- var watchIntervals = [];
- var locations = [];
- var currentPosition = null;
- var nextPosition = null;
- return {
- /**
- @ngdoc property
- @name throwsError
- @propertyOf ngCordovaMocks.cordovaGeolocation
- @description
- A flag that signals whether a promise should be rejected or not.
- This property should only be used in automated tests.
- */
- throwsError: throwsError,
- /**
- @ngdoc property
- @name watchIntervals
- @propertyOf ngCordovaMocks.cordovaGeolocation
- @description
- The collection of watchers that are currently active.
- This property should only be used in automated tests.
- */
- watchIntervals: watchIntervals,
- /**
- @ngdoc property
- @name locations
- @propertyOf ngCordovaMocks.cordovaGeolocation
- @description
- The collection of 'locations' that have been logged.
- This property should only be used in automated tests.
- */
- locations: locations,
- /**
- @ngdoc property
- @name currentPosition
- @propertyOf ngCordovaMocks.cordovaGeolocation
- @description
- The last location logged.
- This property should only be used in automated tests.
- */
- currentPosition: currentPosition,
- /**
- @ngdoc property
- @name nextPosition
- @propertyOf ngCordovaMocks.cordovaGeolocation
- @description
- The position to be logged the next time that a watcher
- gets the location.
- This property should only be used in automated tests.
- */
- nextPosition: nextPosition,
- /**
- @ngdoc property
- @name useHostAbilities
- @propertyOf ngCordovaMocks.cordovaGeolocation
- @description
- A flag that signals whether or not to try and use the host's
- (browser or otherwise) geolocation capabilities.
- This property should only be used in automated tests.
- */
- useHostAbilities: useHostAbilities,
- getCurrentPosition: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the location.');
- } else {
- if (options) {
- options = options; // This is just to get by JSHint.
- }
- if (this.useHostAbilities) {
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(
- function (position) {
- this.currentPosition = position;
- defer.resolve(this.currentPosition);
- },
- function (error) {
- defer.reject(error);
- }
- );
- } else {
- defer.reject('Geolocation is not supported by this browser.');
- }
- } else {
- defer.resolve(this.currentPosition);
- }
- }
- return defer.promise;
- },
- watchPosition: function (options) {
- var defer = $q.defer();
- var watchID = Math.floor((Math.random() * 1000000) + 1);
- var self = this;
- self.locations = [];
- if (self.throwsError) {
- defer.reject('There was an error getting the geolocation.');
- } else {
- var delay = 1000;
- if (options && options.timeout) {
- delay = options.timeout;
- }
- self.watchIntervals.push({
- watchID: watchID,
- interval: $interval(
- function () {
- if (self.throwsError) {
- defer.reject('There was an error watching the geolocation.');
- }
- // Attempt to use nextPosition.
- var result = self.nextPosition;
- if (result === null) {
- // Determine whether to use the host's geolocation capabilities or not
- if (self.useHostAbilities) {
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(
- function (position) {
- self.currentPosition = position;
- self.locations.push(position);
- defer.resolve(position);
- },
- function (error) {
- defer.reject(error);
- }
- );
- } else {
- defer.reject('Geolocation is not supported by this browser.');
- }
- } else {
- result = {
- coords: {
- latitude: ((Math.random() * 180) + 1) - 90,
- longitude: ((Math.random() * 360) + 1) - 180,
- altitude: ((Math.random() * 100) + 1),
- accuracy: ((Math.random() * 10) + 1),
- altitudeAccuracy: ((Math.random() * 10) + 1),
- heading: ((Math.random() * 360) + 1),
- speed: ((Math.random() * 100) + 1)
- },
- timestamp: Date.now()
- };
- self.currentPosition = result;
- self.locations.push(result);
- defer.notify(result);
- }
- }
- },
- delay
- )
- });
- }
- var cancel = function (id) {
- var removed = -1;
- for (var i = 0; i < self.watchIntervals.length; i++) {
- if (self.watchIntervals[i].watchID === id) {
- $interval.cancel(watchIntervals[i].interval);
- removed = i;
- break;
- }
- }
- if (removed !== -1) {
- self.watchIntervals.splice(removed, 1);
- }
- };
- defer.promise.cancel = function () {
- cancel(watchID);
- };
- defer.promise.clearWatch = function (id) {
- cancel(id || watchID);
- };
- defer.promise.watchID = watchID;
- return defer.promise;
- },
- clearWatch: function (watchID) {
- var defer = $q.defer();
- if (watchID) {
- if (this.throwsError) {
- defer.reject('Unable to clear watch.');
- } else {
- var removed = -1;
- for (var i = 0; i < this.watchIntervals.length; i++) {
- if (this.watchIntervals[i].watchID === watchID) {
- $interval.cancel(watchIntervals[i].interval);
- removed = i;
- break;
- }
- }
- if (removed !== -1) {
- this.watchIntervals.splice(removed, 1);
- }
- }
- } else {
- defer.reject('Unable to clear watch. No watch ID provided.');
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaGlobalization
- *
- * @description
- * A service for testing features related to a user's locale and timezone.
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaGlobalization', ['$q', function ($q) {
- var throwsError = false;
- var language = (navigator.language) ? navigator.language : 'en-US';
- var preferredLanguage = {value: language};
- var firstDayOfWeek = 'Sunday';
- var localeName = {value: language};
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaGlobalization
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- /**
- * @ngdoc property
- * @name preferredLanguage
- * @propertyOf ngCordovaMocks.cordovaGlobalization
- *
- * @description
- * The user's preferred language.
- * This property should only be used in automated tests.
- **/
- preferredLanguage: preferredLanguage,
- /**
- * @ngdoc property
- * @name localeName
- * @propertyOf ngCordovaMocks.cordovaGlobalization
- *
- * @description
- * The name of the user's locale.
- * This property should only be used in automated tests.
- **/
- localeName: localeName,
- /**
- * @ngdoc property
- * @name firstDayOfWeek
- * @propertyOf ngCordovaMocks.cordovaGlobalization
- *
- * @description
- * The first day of the week based on the user's locale.
- * This property should only be used in automated tests.
- **/
- firstDayOfWeek: firstDayOfWeek,
- getPreferredLanguage: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the preferred language.');
- } else {
- defer.resolve(this.preferredLanguage);
- }
- return defer.promise;
- },
- getLocaleName: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the locale name.');
- } else {
- defer.resolve(this.localeName);
- }
- return defer.promise;
- },
- getFirstDayOfWeek: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the first day of week.');
- } else {
- defer.resolve(this.firstDayOfWeek);
- }
- return defer.promise;
- },
- dateToString: function (date, options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the string from the date.');
- } else {
- var result = '';
- // TODO: Review
- date = date;
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- stringToDate: function (dateString, options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the date from the string.');
- } else {
- var result = '';
- // TODO: Review
- dateString = dateString;
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- getDatePattern: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the date pattern.');
- } else {
- var result = '';
- // TODO: Review
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- getDateNames: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting the date names.');
- } else {
- var result = '';
- // TODO: Review
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- isDayLightSavingsTime: function (date) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error getting if this is in daylight savings time mode.');
- } else {
- var result = '';
- // TODO: Review
- date = date;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- numberToString: function (number, options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error convertng the number to a string.');
- } else {
- var result = '';
- // TODO: Review
- number = number;
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- stringToNumber: function (numberString, options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error convertng the string to a number.');
- } else {
- var result = '';
- // TODO: Review
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- getNumberPattern: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error convertng the string to a number.');
- } else {
- var result = '';
- // TODO: Review
- options = options;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- },
- getCurrencyPattern: function (currencyCode) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error convertng the string to a number.');
- } else {
- var result = '';
- // TODO: Review
- currencyCode = currencyCode;
- // END TODO: Review
- defer.resolve(result);
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaGoogleAnalytics
- *
- * @description
- * A service for testing google analytics services
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaGoogleAnalytics', ['$q', function ($q) {
- var throwsError = false;
- var methods = {};
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaGeolocation
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- methods.throwsError = throwsError;
- var methodsName = [
- 'startTrackerWithId',
- 'setUserId',
- 'debugMode',
- 'trackView',
- 'addCustomDimension',
- 'trackEvent',
- 'trackException',
- 'trackTiming',
- 'addTransaction',
- 'addTransactionItem'
- ];
- methodsName.forEach(function (funcName) {
- methods[funcName] = function () {
- var defer = $q.defer();
- (this.throwsError) ?
- defer.reject() :
- defer.resolve();
- return defer.promise;
- };
- });
- return methods;
- }]);
- 'use strict';
- /**
- * @ngdoc service
- * @name ngCordovaMocks.googlePlayGame
- *
- * @description
- * A service for testing Google Play Game features
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaGooglePlayGame', ['$q', function ($q) {
- var throwsError = false;
- var isSignedIn = false;
- var displayName = '';
- return {
- /**
- * @ngdoc property
- * @name _throwsError
- * @propertyOf ngCordovaMocks.googlePlayGame
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- _throwsError: throwsError,
- /**
- * @ngdoc property
- * @name _isSignedIn
- * @propertyOf ngCordovaMocks.googlePlayGame
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- _isSignedIn: isSignedIn,
- /**
- * @ngdoc property
- * @name _displayName
- * @propertyOf ngCordovaMocks.googlePlayGame
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- _displayName: displayName,
- auth: function () {
- var defer = $q.defer();
- if (this._throwsError) {
- defer.reject('There was a auth error.');
- } else {
- this.isSignedIn = true;
- defer.resolve('SIGN IN SUCCESS');
- }
- return defer.promise;
- },
- signout: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was a signout error.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- isSignedIn: function () {
- var defer = $q.defer();
- if (this._throwsError) {
- defer.reject('There was a isSignedIn error.');
- } else {
- defer.resolve({
- 'isSignedIn': this._isSignedIn
- });
- }
- return defer.promise;
- },
- showPlayer: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was a showPlayer error.');
- } else {
- defer.resolve({
- 'displayName': this._displayName
- });
- }
- return defer.promise;
- },
- submitScore: function (data) {
- var defer = $q.defer();
- if (this._throwsError) {
- defer.reject('There was a submitScore error.');
- } else {
- defer.resolve('OK');
- }
- return defer.promise;
- },
- showAllLeaderboards: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was a showAllLeaderboards error.');
- } else {
- defer.resolve('OK');
- }
- return defer.promise;
- },
- showLeaderboard: function (data) {
- var defer = $q.defer();
- if (this._throwsError) {
- defer.reject('There was a showLeaderboard error.');
- } else {
- defer.resolve('OK');
- }
- return defer.promise;
- },
- unlockAchievement: function (data) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was a unlockAchievement error.');
- } else {
- defer.resolve('OK');
- }
- return defer.promise;
- },
- incrementAchievement: function (data) {
- var defer = $q.defer();
- if (this._throwsError) {
- defer.reject('There was a incrementAchievement error.');
- } else {
- defer.resolve('OK');
- }
- return defer.promise;
- },
- showAchievements: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was a showAchievements error.');
- } else {
- defer.resolve('OK');
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaKeyboard
- *
- * @description
- * A service for testing device keyboard features
- * in an app build with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaKeyboard', function () {
- var isVisible = false;
- return {
- hideAccessoryBar: function (bool) {
- },
- close: function () {
- isVisible = false;
- },
- show: function () {
- isVisible = true;
- },
- disableScroll: function (bool) {
- },
- isVisible: function () {
- return isVisible;
- }
- };
- });
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaKeychain
- *
- * @description
- * A service for testing Keychain features
- * in an app built with ngCordova.
- **/
- ngCordovaMocks.factory('$cordovaKeychain', ['$q', function ($q) {
- var keychains = {};
- return {
- /**
- * @ngdoc property
- * @name keychains
- * @propertyOf ngCordovaMocks.cordovaKeychain
- *
- * @description
- * The collection of 'keychains' that have been saved.
- * This property should only be used in automated tests.
- **/
- keychains: keychains,
- getForKey: function (key, serviceName) {
- var defer = $q.defer();
- if (this.keychains[serviceName]) {
- defer.resolve(this.keychains[serviceName][key]);
- } else {
- defer.reject();
- }
- return defer.promise;
- },
- setForKey: function (key, serviceName, value) {
- var defer = $q.defer();
- if (!this.keychains[serviceName]) {
- this.keychains[serviceName] = {};
- }
- this.keychains[serviceName][key] = value;
- defer.resolve();
- return defer.promise;
- },
- removeForKey: function (key, serviceName) {
- var defer = $q.defer();
- if (this.keychains[serviceName]) {
- delete this.keychains[serviceName][key];
- }
- defer.resolve();
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.localNotification
- *
- * @description
- * A service for testing LocalNotificatio
- * in an app build with ngCordovaMocks.
- */
- ngCordovaMocks.factory('$cordovaLocalNotification', ['$q', function ($q) {
- var storageKeyPfx = "ngCordLocNotif-";
-
- function pfxId(id) {
- return storageKeyPfx + id;
- }
- function getAllIds(){
- var defer = $q.defer();
- var locNotifIds = [];
- for ( var i = 0, len = localStorage.length; i < len; ++i ) {
- if (localStorage.key( i ).indexOf(storageKeyPfx) > -1)
- locNotifIds.push(parseInt(localStorage.key( i ).split("-")[1]));
- }
- defer.resolve(locNotifIds);
- return defer.promise;
- }
- return {
- cancel: function (ids) {
- var defer = $q.defer();
- if (typeof(ids) == "number") ids = [ids];
- ids.forEach(function (id){
- localStorage.removeItem([pfxId(id)]);
- });
- defer.resolve();
- return defer.promise;
- },
- cancelAll: function () {
- var defer = $q.defer();
- // TODO
- defer.resolve();
- return defer.promise;
- },
- clear: function (ids) {
- if (typeof(ids) == "number") ids = [ids];
- var defer = $q.defer();
- ids.forEach(function (id){
- localStorage.removeItem([pfxId(id)]);
- });
- defer.resolve();
- return defer.promise;
- },
- clearAll: function () {
- var defer = $q.defer();
- // TODO
- // defer.resolve();
- return defer.promise;
- },
- isScheduled: function (id){
- var defer = $q.defer();
- if (localStorage[pfxId(id)]) {
- defer.resolve(true);
- } else {
- defer.resolve(false);
- }
- return defer.promise;
- },
- isPresent: function (id){
- var defer = $q.defer();
- if (localStorage[pfxId(id)]) {
- defer.resolve(true);
- } else {
- defer.resolve(false);
- }
- return defer.promise;
- },
- isTriggered: function (id){
- var defer = $q.defer();
- if (localStorage[pfxId(id)]) {
- defer.resolve(false);
- } else {
- defer.resolve(true);
- }
- return defer.promise;
- },
- getAllIds: function () {
- return getAllIds();
- },
- getIds: function () {
- return getAllIds();
- },
- getScheduledIds: function () {
- return getAllIds();
- },
- getTriggeredIds: function () {
- var defer = $q.defer();
- defer.resolve([]);
- return defer.promise;
- },
- hasPermission: function (id){
- var defer = $q.defer();
- defer.resolve(true);
- return defer.promise;
- },
- schedule: function (data){
- var defer = $q.defer();
- var id = pfxId(data.id);
- localStorage[id] = JSON.stringify(data);
- defer.resolve();
- return defer.promise;
- },
- update: function (data){
- var defer = $q.defer();
- var id = pfxId(data.id);
- localStorage[id] = JSON.stringify(data);
- defer.resolve();
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaNetwork
- *
- * @description
- * A service for testing networked fetures
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaNetwork', ['$rootScope',function ($rootScope) {
- var connectionType = 'WiFi connection';
- var isConnected = true;
- return {
- /**
- * @ngdoc property
- * @name connectionType
- * @propertyOf ngCordovaMocks.cordovaNetwork
- *
- * @description
- * They type of connection. Values should match those found at
- * https://github.com/apache/cordova-plugin-network-information
- * This property should only be used in automated tests.
- **/
- connectionType: connectionType,
- /**
- * @ngdoc property
- * @name isConnected
- * @propertyOf ngCordovaMocks.cordovaNetwork
- *
- * @description
- * A flag that signals whether the app is connected to a network.
- * This property should only be used in automated tests.
- **/
- isConnected: isConnected,
- switchToOnline: function (){
- this.isConnected = true;
- $rootScope.$broadcast('$cordovaNetwork:online');
- },
- switchToOffline: function (){
- this.isConnected = false;
- $rootScope.$broadcast('$cordovaNetwork:offline');
- },
- getNetwork: function () {
- return this.connectionType;
- },
- isOnline: function () {
- return this.isConnected;
- },
- isOffline: function () {
- return !this.isConnected;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaProgress
- *
- * @description
- * A service for testing Progress Indicator
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaProgress', [
- '$timeout', function ($timeout) {
- return {
- show: function (_message) {
- var message = _message || 'Please wait...';
- console.info('$cordovaProgress.message', message);
- },
- showSimple: function (_dim) {
- var dim = _dim || false;
- console.info('$cordovaProgress.dim', dim);
- },
- showSimpleWithLabel: function (_dim, _label) {
- var dim = _dim || false;
- var label = _label || 'Loading...';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.label', label);
- console.groupEnd();
- },
- showSimpleWithLabelDetail: function (_dim, _label, _detail) {
- var dim = _dim || false;
- var label = _label || 'Loading...';
- var detail = _detail || 'Please wait';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.label', label);
- console.info('$cordovaProgress.detail', detail);
- console.groupEnd();
- },
- showDeterminate: function (_dim, _timeout) {
- var dim = _dim || false;
- var timeout = _timeout || 50000;
- console.group();
- console.info('$cordovaProgress.dim show', dim);
- console.info('$cordovaProgress.timeout', timeout);
- console.groupEnd();
- $timeout(function () {
- console.info('$cordovaProgress.dim timeout', dim);
- }, timeout);
- },
- showDeterminateWithLabel: function (_dim, _timeout, _label) {
- var dim = _dim || false;
- var timeout = _timeout || 50000;
- var label = _label || 'Loading...';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.timeout', timeout);
- console.info('$cordovaProgress.label', label);
- console.groupEnd();
- $timeout(function () {
- console.info('$cordovaProgress[dim, label] timeout', [dim, label]);
- }, timeout);
- },
- showAnnular: function (_dim, _timeout) {
- var dim = _dim || false;
- var timeout = _timeout || 50000;
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.timeout', timeout);
- console.groupEnd();
- $timeout(function () {
- console.info('$cordovaProgress.dim timeout', dim);
- }, timeout);
- },
- showAnnularWithLabel: function (_dim, _timeout, _label) {
- var dim = _dim || false;
- var timeout = _timeout || 50000;
- var label = _label || 'Loading...';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.timeout', timeout);
- console.info('$cordovaProgress.label', label);
- console.groupEnd();
- $timeout(function () {
- console.info('$cordovaProgress[dim, label] timeout', [dim, label]);
- }, timeout);
- },
- showBar: function (_dim, _timeout) {
- var dim = _dim || false;
- var timeout = _timeout || 50000;
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.timeout', timeout);
- console.groupEnd();
- $timeout(function () {
- console.info('$cordovaProgress.dim timeout', dim);
- }, timeout);
- },
- showBarWithLabel: function (_dim, _timeout, _label) {
- var dim = _dim || false;
- var timeout = _timeout || 50000;
- var label = _label || 'Loading...';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.label', label);
- console.info('$cordovaProgress.timeout', timeout);
- console.groupEnd();
- $timeout(function () {
- console.info('$cordovaProgress[dim, label] timeout', [dim, label]);
- }, timeout);
- },
- showSuccess: function (_dim, _label) {
- var dim = _dim || false;
- var label = _label || 'Success';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.label', label);
- console.groupEnd();
- },
- showText: function (_dim, _text, _position) {
- var dim = _dim || false;
- var text = _text || 'Warning';
- var position = _position || 'center';
- console.group();
- console.info('$cordovaProgress.dim', dim);
- console.info('$cordovaProgress.text', text);
- console.info('$cordovaProgress.position', position);
- console.groupEnd();
- },
- hide: function () {
- console.info('$cordovaProgress.hide');
- }
- };
- }
- ]);
- 'use strict';
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaPush
- *
- * @description
- * A service for testing push notifications features
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaPush', ['$q', '$timeout', '$rootScope', function ($q, $timeout, $rootScope) {
- var throwsError = false;
- var deviceToken = '';
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaPush
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- /**
- * @ngdoc property
- * @name deviceToken
- * @propertyOf ngCordovaMocks.cordovaPush
- *
- * @description
- * Token send when service register device
- * This property should only be used in automated tests.
- **/
- deviceToken: deviceToken,
- onNotification: function (notification) {
- $timeout(function () {
- $rootScope.$broadcast('$cordovaPush:notificationReceived', notification);
- });
- },
- register: function (config) {
- var _self = this;
- var defer = $q.defer();
- if (config !== undefined && config.ecb === undefined) {
- config.ecb = this.onNotification;
- }
- if (this.throwsError) {
- defer.reject('There was a register error.');
- } else {
- defer.resolve(this.deviceToken);
- if (config && config.ecb) {
- config.ecb({
- event: 'registered',
- regid: _self.deviceToken
- });
- }
- }
- return defer.promise;
- },
- unregister: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was a register error.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaScreenshot
- *
- * @description
- * A service for test app screenshot
- * in an app build with ngCordova.
- *
- * @example
- */
- ngCordovaMocks.factory('$cordovaScreenshot', ['$q', function ($q) {
- var throwsError = false;
- var DATA_URI_MOCK = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAABYCAYAAADLGnoRAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAKLJJREFUeNrsfQmcXFWV/qmtqzudpLd0upN0kk46IQsJ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E5tw0wDDl0aIFb6OBm4LslU47l00+A21XAC7dMQBWNFHhCObu9kh8x5y9/6eBHQwdNUd8FvJ8na1YPsUTyK1h4esPXmxJxPSu0IkXjgtbHHfQRAC1r/N5QPGcTh5wEEDTv7DdvMugF06UgAMCopuDM+oauMcghyQ4dEKYQNHbu7y0sbdiT2QAF7LCFUco5llEQvAAd+ggLtAfvczlO733SugRcLvYXfjdAHs0pEEYEUwFMHQhfxMpca5u4UjW66UsFJjwzPotNB1fYPfmQEWcSQxh4HK3KHufkrECW88XDfqAtilIxHAipDs7loun6T0RGp9whWx6dZQE8XlC7eFgcrcBxeuoNcL1z+s5ALYpSMZwIpOFb30Qhu99GeU2LC7Jdf7oISLJ7bsON44t1G4O7j8iLiSuAB2aVQAXLur3S6A/XATdoC7jgYmu4PrIiKU4EwRynD9WcJZVxjHEQKJfFC/Eu4+YuQC2KWRorToH2zxGRt5d0ds44hlpysoPYMlRO3fUGJjpw/aXIfskkiT+rwBXsQBwzC2TDh5n/uaXToqAPxsbZC2A8Qjn6YNa6/YZhIxxvBH1veeOYkSnlGPC5eG1xf27MEu6rrfMnr9W6kDHbjJfb0uHVUi9MduidOM0gidMT9kOUn4vaO2jxHySSvXzALtOERpBCmaqWcfEz33xdF+oHBCWVztitAujQIHhitjfaufXngnSBt2B6g/PGrboGBtFktA2GD5Ae14ngFe7GqOnc8vHG3wYqoL8fPa2+ZzR5VLowNgxUEa23308tagVTp6vKPZv/UC0HMFoK1S4Pp4lQ3ARxy0sBlgomvt8tLmRj89sznfHVUujRj9nwADAFIAdCgbzMwPAAAAAElFTkSuQmCC";
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaScreenshot
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- captureToFile: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error capturing the screenshot.');
- } else {
- defer.resolve("path");
- }
- return defer.promise;
- },
- captureToUri: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error capturing the screenshot.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * A service for testing via social services
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaSocialSharing', ['$q', function ($q) {
- var throwsError = false;
- var message = '';
- var image = '';
- var link = '';
- var number = '';
- var socialService = '';
- var subject = '';
- var toAddresses = [];
- var bccAddresses = [];
- var attachments = [];
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- /**
- * @ngdoc property
- * @name message
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * The message to be shared via a social service.
- * This property should only be used in automated tests.
- **/
- message: message,
- /**
- * @ngdoc property
- * @name image
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * An image to be shared via a social service.
- * This property should only be used in automated tests.
- **/
- image: image,
- /**
- * @ngdoc property
- * @name link
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * A link to be shared via a social service.
- * This property should only be used in automated tests.
- **/
- link: link,
- /**
- * @ngdoc property
- * @name number
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * A comma-delimited list of phone numbers to send a social message to.
- * This property should only be used in automated tests.
- **/
- number: number,
- /**
- * @ngdoc property
- * @name subject
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * The subject of an email.
- * This property should only be used in automated tests.
- **/
- subject: subject,
- /**
- * @ngdoc property
- * @name toAddresses
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * An array of email addresses to send an email to.
- * This property should only be used in automated tests.
- **/
- toAddresses: toAddresses,
- /**
- * @ngdoc property
- * @name bccAddresses
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * An array of email addresses to blind carbon-copy an email to.
- * This property should only be used in automated tests.
- **/
- bccAddresses: bccAddresses,
- /**
- * @ngdoc property
- * @name socialService
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * The name of a social service to share content through.
- * This property should only be used in automated tests.
- **/
- socialService: socialService,
- /**
- * @ngdoc property
- * @name attachments
- * @propertyOf ngCordovaMocks.cordovaSocialSharing
- *
- * @description
- * An array of attachments to include with an email to be sent.
- * This property should only be used in automated tests.
- **/
- attachments: attachments,
- shareViaTwitter: function (message, image, link) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via Twitter.');
- } else {
- this.message = message;
- this.image = image;
- this.link = link;
- defer.resolve();
- }
- return defer.promise;
- },
- shareViaWhatsApp: function (message, image, link) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via WhatsApp.');
- } else {
- this.message = message;
- this.image = image;
- this.link = link;
- defer.resolve();
- }
- return defer.promise;
- },
- shareViaFacebook: function (message, image, link) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via Facebook.');
- } else {
- this.message = message;
- this.image = image;
- this.link = link;
- defer.resolve();
- }
- return defer.promise;
- },
- shareViaSMS: function (message, number) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via SMS.');
- } else {
- this.message = message;
- this.number = number;
- defer.resolve();
- }
- return defer.promise;
- },
- shareViaEmail: function (message, subject, toArr, bccArr, file) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via SMS.');
- } else {
- // These are added to get by JSHINT for now
- this.message = message;
- this.subject = subject;
- this.toAddresses = toArr;
- this.bccAddressesc = bccArr;
- this.attachments = file;
- defer.resolve();
- }
- return defer.promise;
- },
- canShareViaEmail: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject(false);
- } else {
- defer.resolve(true);
- }
- return defer.promise;
- },
- canShareVia: function (via, message, subject, file, link) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via SMS.');
- } else {
- // These are added to get by JSHINT for now
- this.message = message;
- this.socialService = via;
- this.subject = subject;
- this.attachments = file;
- this.link = link;
- defer.resolve();
- }
- return defer.promise;
- },
- shareVia: function (via, message, subject, file, link) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via SMS.');
- } else {
- this.socialService = via;
- this.message = message;
- this.subject = subject;
- this.attachments = file;
- this.link = link;
- defer.resolve();
- }
- return defer.promise;
- },
- share: function (message, subject, file, link) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via SMS.');
- } else {
- this.message = message;
- this.subject = subject;
- this.attachments = file;
- this.link = link;
- defer.resolve();
- }
- return defer.promise;
- },
- shareWithOptions: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error sharing via SMS.');
- } else {
- this.message = options.message;
- this.subject = options.subject;
- this.attachments = options.files;
- this.link = options.url;
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaSplashscreen
- *
- * @description
- * A service for testing the splash screen
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaSplashscreen', function () {
- var isVisible = false;
- return {
- /**
- * @ngdoc property
- * @name isVisible
- * @propertyOf ngCordovaMocks.cordovaSplashscreen
- *
- * @description
- * A flag that signals whether the splash screen is visible or not.
- * This property should only be used in automated tests.
- **/
- isVisible: isVisible,
- hide: function () {
- // do nothing. everything happens behind the scenes in this case.
- // its a stub that is present for completeness.
- this.isVisible = false;
- return true;
- },
- show: function () {
- // do nothing. everything happens behind the scenes in this case.
- // its a stub that is present for completeness.
- this.isVisible = true;
- return true;
- }
- };
- });
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaSQLite
- *
- * @description
- * A service for testing SQLite
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaSQLite', ['$q', function ($q) {
- return {
- /**
- * These properties are here for the purpose of automated testing only.
- **/
- openDBShouldSucceedWith: null,
- executeShouldSucceedWith: null,
- insertCollectionShouldSucceedWith: null,
- nestedExecuteShouldSucceedWith: null,
- deleteDBShouldSucceedWith : null,
- openDB: function (options, background) {
- if (this.openDBShouldSucceedWith !== null) {
- $q.when(this.openDBShouldSucceedWith)
- } else {
- $q.reject()
- }
- },
- execute: function (db, query, binding) {
- if (this.executeShouldSucceedWith !== null) {
- $q.when(this.executeShouldSucceedWith)
- } else {
- $q.reject()
- }
- },
- insertCollection: function (db, query, bindings) {
- if (this.insertCollectionShouldSucceedWith !== null) {
- $q.when(this.insertCollectionShouldSucceedWith)
- } else {
- $q.reject()
- }
- },
- nestedExecute: function (db, query1, query2, binding1, binding2) {
- if (this.nestedExecuteShouldSucceedWith !== null) {
- $q.when(this.nestedExecuteShouldSucceedWith)
- } else {
- $q.reject()
- }
- },
- deleteDB: function (dbName) {
- if (this.deleteDBShouldSucceedWith !== null) {
- $q.when(this.deleteDBShouldSucceedWith)
- } else {
- $q.reject()
- }
- }
- }
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaStatusbar
- *
- * @description
- * A service for testing the status bar
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaStatusbar', function () {
- var isStatusBarVisible = true;
- var canOverlayWebView = true;
- return {
- /**
- * @ngdoc property
- * @name isStatusBarVisible
- * @propertyOf ngCordovaMocks.cordovaStatusbar
- *
- * @description
- * A flag that signals whether the status bar is visible or not.
- * This property should only be used in automated tests.
- **/
- isStatusBarVisible: isStatusBarVisible,
- /**
- * @ngdoc property
- * @name canOverlayWebView
- * @propertyOf ngCordovaMocks.cordovaStatusbar
- *
- * @description
- * A flag that signals whether the status bar can overlay the web view.
- * This property should only be used in automated tests.
- **/
- canOverlayWebView: canOverlayWebView,
- overlaysWebView: function (bool) {
- this.canOverlayWebView = bool;
- },
- style: function (style) {
- // TODO: Review
- return style;
- },
- styleHex: function (colorHex) {
- // TODO: review
- return colorHex;
- },
- styleColor: function (color) {
- // TODO: review
- return color;
- },
- hide: function () {
- this.isStatusBarVisible = false;
- },
- show: function () {
- this.isStatusBarVisible = true;
- },
- isVisible: function () {
- return this.isStatusBarVisible;
- }
- };
- });
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaToast
- *
- * @description
- * A service for testing toasts
- * in an app build with ngCordova.
- *
- * @example
- */
- ngCordovaMocks.factory('$cordovaToast', ['$q', function ($q) {
- var throwsError = false;
- return {
- /**
- * @ngdoc property
- * @name throwsError
- * @propertyOf ngCordovaMocks.cordovaToast
- *
- * @description
- * A flag that signals whether a promise should be rejected or not.
- * This property should only be used in automated tests.
- **/
- throwsError: throwsError,
- showShortTop: function (message) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- showShortCenter: function (message) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- showShortBottom: function (message) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- showLongTop: function (message) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- showLongCenter: function (message) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- showLongBottom: function (message) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- showWithOptions: function (options) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- show: function (message, duration, position) {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error showing the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- },
- hide: function () {
- var defer = $q.defer();
- if (this.throwsError) {
- defer.reject('There was an error hiding the toast.');
- } else {
- defer.resolve();
- }
- return defer.promise;
- }
- };
- }]);
- /**
- * @ngdoc service
- * @name ngCordovaMocks.cordovaVibration
- *
- * @description
- * A service for testing vibration
- * in an app build with ngCordova.
- */
- ngCordovaMocks.factory('$cordovaVibration', ['$timeout', function ($timeout) {
- var isVibrating = false;
- var vibrateTimer = null;
- return {
- /**
- * @ngdoc property
- * @name vibrateTimer
- * @propertyOf ngCordovaMocks.cordovaVibration
- *
- * @description
- * Access to the timer associated with vibration.
- * This property should only be used in automated tests.
- **/
- vibrateTimer: vibrateTimer,
- /**
- * @ngdoc property
- * @name isVibrating
- * @propertyOf ngCordovaMocks.cordovaVibration
- *
- * @description
- * A flag that signals whether vibration is active.
- * This property should only be used in automated tests.
- **/
- isVibrating: isVibrating,
- vibrate: function (time) {
- if (time > 0) {
- this.isVibrating = true;
- self = this;
- if (time instanceof Array) {
- // TODO: Implement pattern here.
- // The following is a temporary timer that just looks at the first value
- this.vibrateTimer = $timeout(
- function () {
- self.isVibrating = false;
- self.vibrateTimer = null;
- },
- time[0]
- );
- } else {
- this.vibrateTimer = $timeout(
- function () {
- self.isVibrating = false;
- self.vibrateTimer = null;
- },
- time
- );
- }
- }
- },
- /* jshint ignore:start */
- vibrateWithPattern: function (pattern, repeat) {
- // Based on the documentation (https://github.com/apache/cordova-plugin-vibration)
- // This method is deprecated. For that reason, this isn't implemented at this time.
- },
- /* jshint ignore:end */
- cancelVibration: function () {
- if (this.vibrateTimer !== null) {
- if (this.isVibrating === true) {
- $timeout.cancel(this.vibrateTimer);
- this.isVibrating = false;
- }
- }
- }
- };
- }]);
- })();
|