Chromium Code Reviews| Index: chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/test.js |
| diff --git a/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/test.js b/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9ad46372f3f0e174a6eff416be0663a33e06156f |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/test.js |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var gNbTests = 0; |
| +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.
|
| + |
| +function done(success) { |
| + gFailed |= !success; |
| + gNbTests--; |
| + |
| + if (!gNbTests) |
| + gFailed ? chrome.test.notifyFail('test failed') : chrome.test.notifyPass(); |
| +} |
| + |
| +function testChromeStorage(backend) { |
| + backend.get('foo', function(result) { |
| + if (result.foo) { |
| + done(false); |
| + return; |
| + } |
| + |
| + // We set the value but also want to make sure it is correctly saved. |
| + 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.
|
| + backend.get('foo', function(result) { |
| + done(result.foo == 'bar'); |
| + }); |
| + }); |
| + }); |
| +} |
| + |
| +function testChromeStorageLocal() { |
| + testChromeStorage(chrome.storage.local); |
| +} |
| + |
| +function testChromeStorageSync() { |
| + testChromeStorage(chrome.storage.sync); |
| +} |
| + |
| +chrome.app.runtime.onLaunched.addListener(function() { |
| + chrome.test.sendMessage('Launched', function() { |
| + gNbTests = 2; |
| + // done() will have to be called <gNbTests> times to finish this test. |
| + |
| + testChromeStorageLocal(); |
| + testChromeStorageSync(); |
| + }); |
| +}); |