From bd3d2112df365806172caa5eb48ba4a7730a9b41 Mon Sep 17 00:00:00 2001
From: Pawel Kaczmarek
Date: Mon, 16 Mar 2015 14:20:29 +0100
Subject: [PATCH] [Notification] Fix multiple TCT
[Verification]
TCT result should be much better with this patch
Tested with fake response data.
Change-Id: Ic0f5d0b3849fdb47b4a41b907bf906cc74398610
Signed-off-by: Pawel Kaczmarek
---
src/notification/notification_api.js | 38 +++++++++++++++++++---------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/notification/notification_api.js b/src/notification/notification_api.js
index f8890237..4c0e17b4 100644
--- a/src/notification/notification_api.js
+++ b/src/notification/notification_api.js
@@ -54,7 +54,7 @@ NotificationManager.prototype.post = function(notification) {
var result = native_.callSync('NotificationManager_post', data);
if (native_.isFailure(result)) {
- throw native_.getErrorObject(result);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
_edit.allow();
@@ -111,7 +111,8 @@ NotificationManager.prototype.removeAll = function() {
var result = native_.callSync('NotificationManager_removeAll', {});
if (native_.isFailure(result)) {
- throw native_.getErrorObject(result);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR,
+ native_.getErrorObject(result));
}
};
@@ -135,8 +136,10 @@ NotificationManager.prototype.get = function(id) {
native_.getErrorObject(result));
}
+ var n = native_.getResultObject(result);
+
_edit.allow();
- var returnObject = new StatusNotification(native_.getResultObject(result));
+ var returnObject = new StatusNotification(n.statusType, n.title, n);
_edit.disallow();
return returnObject;
@@ -146,7 +149,8 @@ NotificationManager.prototype.getAll = function() {
var result = native_.callSync('NotificationManager_getAll', {});
if (native_.isFailure(result)) {
- throw native_.getErrorObject(result);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
+ native_.getErrorObject(result));
}
var n = native_.getResultObject(result);
@@ -154,7 +158,7 @@ NotificationManager.prototype.getAll = function() {
_edit.allow();
for (var i = 0; i < n.length; i++) {
- notifications.push(new StatusNotification(n[i]));
+ notifications.push(new StatusNotification(n[i].statusType, n[i].title, n[i]));
}
_edit.disallow();
@@ -167,9 +171,16 @@ function NotificationInitDict(data) {
var _vibration = false;
var _isUnified = false;
var _appControl = null;
- var _appId = false;
+ var _appId = null;
var _progressType = NotificationProgressType.PERCENTAGE;
- var _progressValue = 0;
+ var _progressValue = null;
+ var checkProgressValue = function(v) {
+ if ((_progressType === NotificationProgressType.PERCENTAGE && (v >= 0 && v <= 100))
+ || (_progressType !== NotificationProgressType.PERCENTAGE && v >= 0)) {
+ return true;
+ }
+ return false;
+ };
var _number = null;
var _subIconPath = null;
var _detailInfo = [];
@@ -273,8 +284,7 @@ function NotificationInitDict(data) {
return _progressValue;
},
set: function(v) {
- _progressValue = this.statusType === StatusNotificationType.PROGRESS
- && (v >= 0 && v <= 100) ? v : _progressValue;
+ _progressValue = checkProgressValue(v) ? v : _progressValue;
},
enumerable: true
},
@@ -375,7 +385,7 @@ function Notification(data) {
return _id;
},
set: function(v) {
- _id = _edit.canEdit ? v : _id;
+ _id = _edit.canEdit && v ? v : _id;
},
enumerable: true
},
@@ -384,7 +394,7 @@ function Notification(data) {
return _type;
},
set: function(v) {
- _type = _edit.canEdit ? v : _id;
+ _type = _edit.canEdit && Object.keys(NotificationType).indexOf(v) >= 0 ? v : _type;
},
enumerable: true
},
@@ -393,7 +403,7 @@ function Notification(data) {
return _postedTime;
},
set: function(v) {
- _postedTime = _edit.canEdit ? new Date(v) : _postedTime;
+ _postedTime = _edit.canEdit && v ? new Date(v) : _postedTime;
},
enumerable: true
},
@@ -430,6 +440,10 @@ function StatusNotification(statusType, title, notificationInitDict) {
get: function() {
return _statusType;
},
+ set: function(v) {
+ _statusType = (Object.keys(StatusNotificationType)).indexOf(v) >= 0 && _edit.canEdit
+ ? v : _statusType;
+ },
enumerable: true
},
title: {
--
2.34.1