From e3b6652d0553ce0db860b6bad082b4ea40b1e799 Mon Sep 17 00:00:00 2001 From: Rafal Galka Date: Wed, 10 Dec 2014 14:27:49 +0100 Subject: [PATCH] [Power] Fixed calls to validator Change-Id: I8677ff7ffef6164005183674852cb2db8eaaa0f1 --- src/power/power_api.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/power/power_api.js b/src/power/power_api.js index 5e3cd31..37e9a00 100644 --- a/src/power/power_api.js +++ b/src/power/power_api.js @@ -4,6 +4,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +var validator_ = xwalk.utils.validator; +var types_ = validator_.Types; + var listener_ = undefined; function throwException_(err) { @@ -71,9 +74,9 @@ function PowerManager() { * is desired to be. */ PowerManager.prototype.request = function() { - var args = xwalk.utils.validator.validateArgs(arguments, [ - {name: 'resource', type: 'string'}, - {name: 'state', type: 'string'} + var args = validator_.validateArgs(arguments, [ + {name: 'resource', type: types_.STRING}, + {name: 'state', type: types_.STRING} ]); if (!PowerResource.hasOwnProperty(args.resource)) @@ -98,8 +101,8 @@ PowerManager.prototype.request = function() { * be removed. */ PowerManager.prototype.release = function() { - var args = xwalk.utils.validator.validateArgs(arguments, [ - {name: 'resource', type: 'string'} + var args = validator_.validateArgs(arguments, [ + {name: 'resource', type: types_.STRING} ]); if (!PowerResource.hasOwnProperty(args.resource)) @@ -116,8 +119,8 @@ PowerManager.prototype.release = function() { * @param {!function} listener The screen state change callback. */ PowerManager.prototype.setScreenStateChangeListener = function() { - var args = xwalk.utils.validator.validateArgs(arguments, [ - {name: 'listener', type: 'function'} + var args = validator_.validateArgs(arguments, [ + {name: 'listener', type: types_.FUNCTION} ]); listener_ = args.listener; @@ -147,11 +150,11 @@ PowerManager.prototype.getScreenBrightness = function() { * @param {!number} brightness The screen brightness value to set. */ PowerManager.prototype.setScreenBrightness = function() { - var args = xwalk.utils.validator.validateArgs([ - {name: 'brightness', type: 'double'} + var args = validator_.validateArgs(arguments, [ + {name: 'brightness', type: types_.DOUBLE} ]); - if (brightness < 0 || brightness > 1) + if (args.brightness < 0 || args.brightness > 1) throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); callSync_({ -- 2.7.4