OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 dummyGetTokenCompleted(token) { | 5 function dummyGetTokenCompleted(token) { |
6 } | 6 } |
7 | 7 |
8 function deleteTokenWithoutParameters() { | 8 function deleteTokenWithoutParameters() { |
9 try { | 9 try { |
10 chrome.instanceID.deleteToken(); | 10 chrome.instanceID.deleteToken(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 return; | 103 return; |
104 } | 104 } |
105 | 105 |
106 chrome.test.succeed(); | 106 chrome.test.succeed(); |
107 } | 107 } |
108 ); | 108 ); |
109 } | 109 } |
110 ); | 110 ); |
111 } | 111 } |
112 | 112 |
113 var oldToken; | |
fgorski
2015/05/13 18:32:38
put this inside of the test.
jianli
2015/05/13 22:42:55
I can't do this because oldToken are referred from
| |
114 function getTokenDeleteTokeAndGetToken() { | |
115 chrome.instanceID.getToken( | |
116 {"authorizedEntity": "1", "scope": "GCM"}, | |
117 function(token) { | |
118 if (chrome.runtime.lastError || !token) { | |
119 chrome.test.fail( | |
120 "chrome.runtime.lastError was set or token was empty."); | |
121 return; | |
122 } | |
123 oldToken = token; | |
124 chrome.instanceID.deleteToken( | |
125 {"authorizedEntity": "1", "scope": "GCM"}, | |
126 function() { | |
127 if (chrome.runtime.lastError) { | |
128 chrome.test.fail("chrome.runtime.lastError: " + | |
129 chrome.runtime.lastError.message); | |
130 return; | |
131 } | |
132 | |
133 chrome.instanceID.getToken( | |
134 {"authorizedEntity": "1", "scope": "GCM"}, | |
135 function(token) { | |
136 if (!token || token == oldToken) { | |
137 chrome.test.fail( | |
138 "Different token should be returned after deleteToken."); | |
139 return; | |
140 } | |
141 chrome.test.succeed(); | |
142 } | |
143 ); | |
144 } | |
145 ); | |
146 } | |
147 ); | |
148 } | |
149 | |
113 chrome.test.runTests([ | 150 chrome.test.runTests([ |
114 deleteTokenWithoutParameters, | 151 deleteTokenWithoutParameters, |
115 deleteTokenWithoutCallback, | 152 deleteTokenWithoutCallback, |
116 deleteTokenWithoutAuthorizedEntity, | 153 deleteTokenWithoutAuthorizedEntity, |
117 deleteTokenWithInvalidAuthorizedEntity, | 154 deleteTokenWithInvalidAuthorizedEntity, |
118 deleteTokenWithoutScope, | 155 deleteTokenWithoutScope, |
119 deleteTokenWithInvalidScope, | 156 deleteTokenWithInvalidScope, |
120 // TODO(jianli): To be enabled when deleteToken is implemented. | 157 deleteTokenBeforeGetToken, |
121 //deleteTokenBeforeGetToken, | 158 deleteTokenAfterGetToken, |
122 //deleteTokenAfterGetToken, | 159 getTokenDeleteTokeAndGetToken, |
123 //getTokenDeleteTokeAndGetToken, | |
124 ]); | 160 ]); |
OLD | NEW |