Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/notification.js

Issue 29501607: Issue 5459 - Add support to show a notification based on the number of ads blocked (Closed)
Patch Set: Show notification for blockedTotal* only if Prefs.show_statsinpopup Created Aug. 24, 2017, 4:35 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/notification.js ('k') | test/stub-modules/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/notification.js
diff --git a/test/notification.js b/test/notification.js
index 4a5bc61d1baf99953c245d4441cb02c09944d909..ab673ca7f3cb598ef616179d886ccdbcc64d8da8 100644
--- a/test/notification.js
+++ b/test/notification.js
@@ -140,6 +140,30 @@ exports.testNoType = function(test)
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
+function testTargetSelectionFunc(propName, value, result)
+{
+ return function(test)
+ {
+ let targetInfo = {};
+ targetInfo[propName] = value;
+
+ let information = {
+ id: 1,
+ type: "information",
+ message: {"en-US": "Information"},
+ targets: [targetInfo]
+ };
+
+ registerHandler.call(this, [information]);
+ this.runScheduledTasks(1).then(() =>
+ {
+ let expected = (result ? [information] : []);
+ test.deepEqual(showNotifications(), expected, "Selected notification for " + JSON.stringify(information.targets));
+ test.deepEqual(showNotifications(), [], "No notification on second call");
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+ };
+}
+
exports.testTargetSelection = {};
for (let [propName, value, result] of [
@@ -174,29 +198,40 @@ for (let [propName, value, result] of [
["platformMaxVersion", "12.0", true],
["platformMaxVersion", "12", true],
["platformMaxVersion", "13", true],
- ["platformMaxVersion", "11", false]
+ ["platformMaxVersion", "11", false],
+ ["blockedTotalMin", "11", false],
+ ["blockedTotalMin", "10", true],
+ ["blockedTotalMax", "10", true],
+ ["blockedTotalMax", "1", false],
+ ["locales", ["en-US"], true],
+ ["locales", ["en-US", "de-DE"], true],
+ ["locales", ["de-DE"], false],
+ ["locales", ["en-GB", "de-DE"], false]
])
{
- exports.testTargetSelection[`${propName}=${value}`] = function(test)
- {
- let targetInfo = {};
- targetInfo[propName] = value;
+ exports.testTargetSelection[`${propName}=${value}`] = testTargetSelectionFunc(propName, value, result);
+}
- let information = {
- id: 1,
- type: "information",
- message: {"en-US": "Information"},
- targets: [targetInfo]
- };
+exports.testTargetSelectionNoShowStats = {
- registerHandler.call(this, [information]);
- this.runScheduledTasks(1).then(() =>
- {
- let expected = (result ? [information] : []);
- test.deepEqual(showNotifications(), expected, "Selected notification for " + JSON.stringify(information.targets));
- test.deepEqual(showNotifications(), [], "No notification on second call");
- }).catch(unexpectedError.bind(test)).then(() => test.done());
- };
+ setUp(callback)
+ {
+ this.show_statsinpopup_orig = Prefs.show_statsinpopup;
+ Prefs.show_statsinpopup = false;
+ callback();
+ },
+ tearDown(callback)
+ {
+ Prefs.show_statsinpopup = this.show_statsinpopup_orig;
+ callback();
+ }
+};
+for (let [propName, value, result] of [
+ ["blockedTotalMin", "10", false],
+ ["blockedTotalMax", "10", false]
+])
+{
+ exports.testTargetSelectionNoShowStats[`${propName}=${value}`] = testTargetSelectionFunc(propName, value, result);
}
exports.testMultipleTargets = {};
@@ -213,7 +248,8 @@ for (let [[propName1, value1, result1], [propName2, value2, result2]] of pairs([
["platform", "chromium", true],
["platform", "gecko", false],
["platformMinVersion", "12", true],
- ["platformMinVersion", "13", false]
+ ["platformMinVersion", "13", false],
+ ["unkown", "unknown", false]
]))
{
exports.testMultipleTargets[`${propName1}=${value1},${propName2}=${value2}`] = function(test)
« no previous file with comments | « lib/notification.js ('k') | test/stub-modules/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld