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..e4bda52367049eb3a34654f4f2a75afbfcf1a793 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/test.js |
| @@ -0,0 +1,42 @@ |
| +// 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. |
| + |
| +function testChromeStorage(backend, callback) { |
| + backend.get('foo', function(result) { |
|
not at google - send to devlin
2014/01/08 18:01:36
wrap this function(result) in a chrome.test.callba
|
| + if (result.foo) { |
| + chrome.test.notifyFail('got data before setting!'); |
| + return; |
| + } |
| + |
| + // We set the value but also want to make sure it is correctly saved. |
| + backend.set({ 'foo': 'bar' }, function() { |
| + backend.get('foo', function(result) { |
|
not at google - send to devlin
2014/01/08 18:01:36
likewise here and the line above. often people ali
|
| + if (result.foo != 'bar') |
| + chrome.test.notifyFail('chrome storage unexpected failure'); |
|
not at google - send to devlin
2014/01/08 18:01:36
use chrome.test.assertEq('bar', result.foo) for a
|
| + else |
| + callback(); |
| + }); |
| + }); |
| + }); |
| +} |
| + |
| +function testChromeStorageLocal(callback) { |
| + testChromeStorage(chrome.storage.local, callback); |
|
not at google - send to devlin
2014/01/08 18:01:36
callback flow much nicer, and TBH not even sure if
|
| +} |
| + |
| +function testChromeStorageSync(callback) { |
| + testChromeStorage(chrome.storage.sync, callback); |
| +} |
| + |
| +chrome.app.runtime.onLaunched.addListener(function() { |
| + chrome.test.sendMessage('Launched', function() { |
| + // Test functions will call a callback if succeeded, notifyFail() otherwise. |
| + // The last test function will call notifyPass(). |
| + testChromeStorageLocal(function() { |
| + testChromeStorageSync(function() { |
| + chrome.test.notifyPass(); |
| + }); |
| + }); |
| + }); |
| +}); |