1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Test fixture for the notifications custom bindings adapter.
8 * @extends {testing.Test}
10 function NotificationsCustomBindingsTest() {
11 testing.Test.call(this);
14 NotificationsCustomBindingsTest.prototype = {
15 __proto__: testing.Test.prototype,
19 'notifications_test_util.js',
20 'notifications_custom_bindings.js'
24 TEST_F('NotificationsCustomBindingsTest', 'TestImageDataSetter', function () {
27 var callback = imageDataSetter(c, k);
29 expectTrue(c[k] === 'val');
32 TEST_F('NotificationsCustomBindingsTest', 'TestGetUrlSpecs', function () {
35 icon: { width: 10, height: 10 },
36 image: { width: 24, height: 32 },
37 buttonIcon: { width: 2, height: 2}
40 var notificationDetails = {};
42 var emptySpecs = getUrlSpecs(imageSizes, notificationDetails);
43 expectTrue(emptySpecs.length === 0);
45 notificationDetails.iconUrl = "iconUrl";
46 notificationDetails.imageUrl = "imageUrl";
47 notificationDetails.buttons = [
48 {iconUrl: "buttonOneIconUrl"},
49 {iconUrl: "buttonTwoIconUrl"}];
51 var allSpecs = getUrlSpecs(imageSizes, notificationDetails);
52 expectTrue(allSpecs.length === 4);
54 expectFalse(notificationDetails.iconBitmap === "test");
55 expectFalse(notificationDetails.imageBitmap === "test");
56 expectFalse(notificationDetails.buttons[0].iconBitmap === "test");
57 expectFalse(notificationDetails.buttons[1].iconBitmap === "test");
59 for (var i = 0; i < allSpecs.length; i++) {
60 var expectedKeys = ['path', 'width', 'height', 'callback'];
61 var spec = allSpecs[i];
62 for (var j in expectedKeys) {
63 expectTrue(spec.hasOwnProperty(expectedKeys[j]));
65 spec.callback(spec.path + "|" + spec.width + "|" + spec.height);
68 expectTrue(notificationDetails.iconBitmap === "iconUrl|10|10");
69 expectTrue(notificationDetails.imageBitmap === "imageUrl|24|32");
71 notificationDetails.buttons[0].iconBitmap === "buttonOneIconUrl|2|2");
73 notificationDetails.buttons[1].iconBitmap === "buttonTwoIconUrl|2|2");
76 TEST_F('NotificationsCustomBindingsTest', 'TestGetUrlSpecsScaled', function () {
79 icon: { width: 10, height: 10 },
80 image: { width: 24, height: 32 },
81 buttonIcon: { width: 2, height: 2}
83 var notificationDetails = {
87 {iconUrl: "buttonOneIconUrl"},
88 {iconUrl: "buttonTwoIconUrl"}
92 var allSpecs = getUrlSpecs(imageSizes, notificationDetails);
93 for (var i = 0; i < allSpecs.length; i++) {
94 var spec = allSpecs[i];
95 spec.callback(spec.path + "|" + spec.width + "|" + spec.height);
98 expectEquals(notificationDetails.iconBitmap, "iconUrl|20|20");
99 expectEquals(notificationDetails.imageBitmap, "imageUrl|48|64");
100 expectEquals(notificationDetails.buttons[0].iconBitmap,
101 "buttonOneIconUrl|4|4");
102 expectEquals(notificationDetails.buttons[1].iconBitmap,
103 "buttonTwoIconUrl|4|4");