Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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. | |
| 4 | |
| 5 var gNbTests = 0; | |
| 6 var gFailed = false; | |
|
not at google - send to devlin
2014/01/08 02:49:17
instead of all this global state can testChromeSto
mlamouri (slow - plz ping)
2014/01/08 17:42:31
Sure. I did the change, it is quite better.
| |
| 7 | |
| 8 function done(success) { | |
| 9 gFailed |= !success; | |
| 10 gNbTests--; | |
| 11 | |
| 12 if (!gNbTests) | |
| 13 gFailed ? chrome.test.notifyFail('test failed') : chrome.test.notifyPass(); | |
| 14 } | |
| 15 | |
| 16 function testChromeStorage(backend) { | |
| 17 backend.get('foo', function(result) { | |
| 18 if (result.foo) { | |
| 19 done(false); | |
| 20 return; | |
| 21 } | |
| 22 | |
| 23 // We set the value but also want to make sure it is correctly saved. | |
| 24 backend.set( { 'foo': 'bar'}, function() { | |
|
not at google - send to devlin
2014/01/08 02:49:17
nit: whitespace
mlamouri (slow - plz ping)
2014/01/08 17:42:31
Done.
| |
| 25 backend.get('foo', function(result) { | |
| 26 done(result.foo == 'bar'); | |
| 27 }); | |
| 28 }); | |
| 29 }); | |
| 30 } | |
| 31 | |
| 32 function testChromeStorageLocal() { | |
| 33 testChromeStorage(chrome.storage.local); | |
| 34 } | |
| 35 | |
| 36 function testChromeStorageSync() { | |
| 37 testChromeStorage(chrome.storage.sync); | |
| 38 } | |
| 39 | |
| 40 chrome.app.runtime.onLaunched.addListener(function() { | |
| 41 chrome.test.sendMessage('Launched', function() { | |
| 42 gNbTests = 2; | |
| 43 // done() will have to be called <gNbTests> times to finish this test. | |
| 44 | |
| 45 testChromeStorageLocal(); | |
| 46 testChromeStorageSync(); | |
| 47 }); | |
| 48 }); | |
| OLD | NEW |