OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function createMessage() { | 5 function createMessage() { |
6 return { | 6 return { |
7 messageId: "message-id", | 7 messageId: "message-id", |
8 destinationId: "destination-id", | 8 destinationId: "destination-id", |
9 timeToLive: 2419200, | 9 timeToLive: 86400, |
10 data: { | 10 data: { |
11 "key1": "value1", | 11 "key1": "value1", |
12 "key2": "value" | 12 "key2": "value" |
13 } | 13 } |
14 }; | 14 }; |
15 } | 15 } |
16 | 16 |
17 function successfulSend(message) { | 17 function successfulSend(message) { |
18 chrome.gcm.send(message, function(messageId) { | 18 chrome.gcm.send(message, function(messageId) { |
19 chrome.test.assertEq(message.messageId, messageId); | 19 chrome.test.assertEq(message.messageId, messageId); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 function successWhenTtlIsZero() { | 54 function successWhenTtlIsZero() { |
55 expectSuccessWhen(function(message) { message.timeToLive = 0; }); | 55 expectSuccessWhen(function(message) { message.timeToLive = 0; }); |
56 }, | 56 }, |
57 function successWhenTtlIsMissing() { | 57 function successWhenTtlIsMissing() { |
58 expectSuccessWhen(function(message) { delete message.timeToLive; }); | 58 expectSuccessWhen(function(message) { delete message.timeToLive; }); |
59 }, | 59 }, |
60 function failureWhenTtlIsNegative() { | 60 function failureWhenTtlIsNegative() { |
61 expectFailureWhen(function(message) { message.timeToLive = -1; }); | 61 expectFailureWhen(function(message) { message.timeToLive = -1; }); |
62 }, | 62 }, |
63 function failureWhenTtlIsTooLarge() { | 63 function failureWhenTtlIsTooLarge() { |
64 expectFailureWhen(function(message) { message.timeToLive = 24192001; }); | 64 expectFailureWhen(function(message) { message.timeToLive = 86401; }); |
65 }, | 65 }, |
66 function failureWhenMessageIdMissing() { | 66 function failureWhenMessageIdMissing() { |
67 expectFailureWhen(function(message) { delete message.messageId; }); | 67 expectFailureWhen(function(message) { delete message.messageId; }); |
68 }, | 68 }, |
69 function failureWhenMessageIdIsEmpty() { | 69 function failureWhenMessageIdIsEmpty() { |
70 expectFailureWhen(function(message) { message.messageId = ""; }); | 70 expectFailureWhen(function(message) { message.messageId = ""; }); |
71 }, | 71 }, |
72 function failureWhenDestinationIdMissing() { | 72 function failureWhenDestinationIdMissing() { |
73 expectFailureWhen(function(message) { delete message.destinationId; }); | 73 expectFailureWhen(function(message) { delete message.destinationId; }); |
74 }, | 74 }, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // with data put in by default is more than allowed max. | 141 // with data put in by default is more than allowed max. |
142 var entries = 8; | 142 var entries = 8; |
143 while (entries > 0) { | 143 while (entries > 0) { |
144 var s = generateString(source + entries, 256); | 144 var s = generateString(source + entries, 256); |
145 message.data[s] = s; | 145 message.data[s] = s; |
146 --entries; | 146 --entries; |
147 } | 147 } |
148 }); | 148 }); |
149 } | 149 } |
150 ]); | 150 ]); |
OLD | NEW |