diff options
Diffstat (limited to 'chrome/test')
6 files changed, 97 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json b/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json new file mode 100644 index 0000000..6898e1c --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "packaged_app", + "version": "1", + "app": { + "background": { + "scripts": ["test.js"] + } + } +} diff --git a/chrome/test/data/extensions/api_test/management/packaged_app/test.js b/chrome/test/data/extensions/api_test/management/packaged_app/test.js new file mode 100644 index 0000000..829a7e0 --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/packaged_app/test.js @@ -0,0 +1,7 @@ +// Copyright 2014 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. + +chrome.app.runtime.onLaunched.addListener(function() { + // Do nothing. +}); diff --git a/chrome/test/data/extensions/api_test/management/test/createAppShortcut.html b/chrome/test/data/extensions/api_test/management/test/createAppShortcut.html new file mode 100644 index 0000000..720005b --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/test/createAppShortcut.html @@ -0,0 +1,7 @@ +<!-- + * Copyright 2014 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. +--> +<script src="common.js"></script> +<script src="createAppShortcut.js"></script> diff --git a/chrome/test/data/extensions/api_test/management/test/createAppShortcut.js b/chrome/test/data/extensions/api_test/management/test/createAppShortcut.js new file mode 100644 index 0000000..f01a8d4 --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/test/createAppShortcut.js @@ -0,0 +1,55 @@ +// Copyright 2014 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 testCreateAppShortcut(id, error) { + chrome.test.runWithUserGesture(function() { + if (!error) + chrome.management.createAppShortcut(id, callback(function() {})); + else + chrome.management.createAppShortcut(id, callback(function() {}, error)); + }); +} + +var enabled_app_id, disabled_app_id, enabled_extension_id, packaged_app_id; +var isMac = /Mac/.test(navigator.platform); +var ONLY_PACKAGED_APP_MAC = + "Shortcuts can only be created for new-style packaged apps on Mac."; + +var tests = [ + function createEnabledAppShortcutWithoutUserGesture() { + chrome.management.createAppShortcut(enabled_app_id, callback(function() {}, + "chrome.management.createAppShortcut requires a user gesture.")); + }, + + function createEnabledAppShortcut() { + testCreateAppShortcut(enabled_app_id, isMac? ONLY_PACKAGED_APP_MAC : null); + }, + + function createDisabledAppShortcut() { + testCreateAppShortcut(disabled_app_id, + isMac? ONLY_PACKAGED_APP_MAC : null); + }, + + function createPackagedAppShortcut() { + testCreateAppShortcut(packaged_app_id); + }, + + function createExtensionShortcut() { + testCreateAppShortcut(enabled_extension_id, + "Extension " + enabled_extension_id + " is not an App."); + }, + + function createNotExistAppShortcut() { + testCreateAppShortcut("abcd", "Failed to find extension with id abcd."); + } +]; + +chrome.management.getAll(callback(function(items) { + enabled_app_id = getItemNamed(items, "enabled_app").id; + disabled_app_id = getItemNamed(items, "disabled_app").id; + enabled_extension_id = getItemNamed(items, "enabled_extension").id; + packaged_app_id = getItemNamed(items, "packaged_app").id; + + chrome.test.runTests(tests); +})); diff --git a/chrome/test/data/extensions/api_test/management/test/createAppShortcutNotInStable.html b/chrome/test/data/extensions/api_test/management/test/createAppShortcutNotInStable.html new file mode 100644 index 0000000..6acdea1 --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/test/createAppShortcutNotInStable.html @@ -0,0 +1,7 @@ +<!-- + * Copyright 2014 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. +--> +<script src="common.js"></script> +<script src="createAppShortcutNotInStable.js"></script> diff --git a/chrome/test/data/extensions/api_test/management/test/createAppShortcutNotInStable.js b/chrome/test/data/extensions/api_test/management/test/createAppShortcutNotInStable.js new file mode 100644 index 0000000..0e7bf8d --- /dev/null +++ b/chrome/test/data/extensions/api_test/management/test/createAppShortcutNotInStable.js @@ -0,0 +1,12 @@ +// Copyright 2014 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 tests = [ + function createAppShortcutNotInStable() { + assertEq(chrome.management.createAppShortcut, undefined); + succeed(); + } +]; + +chrome.test.runTests(tests); |