| Index: chrome/test/data/extensions/api_test/management/test/generateAppForLink.js
|
| ===================================================================
|
| --- chrome/test/data/extensions/api_test/management/test/generateAppForLink.js (revision 0)
|
| +++ chrome/test/data/extensions/api_test/management/test/generateAppForLink.js (revision 0)
|
| @@ -0,0 +1,67 @@
|
| +// 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 testGenerateAppForLink(url, title, arg) {
|
| + chrome.test.runWithUserGesture(function() {
|
| + if (typeof arg == "string")
|
| + chrome.management.generateAppForLink(
|
| + url, title, callback(function(data) {}, arg));
|
| + else
|
| + chrome.management.generateAppForLink(
|
| + url, title, callback(function(data) { arg(data) }));
|
| + });
|
| +}
|
| +
|
| +var tests = [
|
| + function generateAppForLinkWithoutUserGesture() {
|
| + chrome.management.generateAppForLink(
|
| + "http://google.com", "test", callback(function() {},
|
| + "chrome.management.generateAppForLink requires a user gesture."));
|
| + },
|
| +
|
| + function generateAppForInvalidLink() {
|
| + testGenerateAppForLink("", "test", "The URL \"\" is invalid.");
|
| + testGenerateAppForLink("aaaa", "test", "The URL \"aaaa\" is invalid.");
|
| + testGenerateAppForLink("http1://google.com", "test",
|
| + "The URL \"http1://google.com\" is invalid.");
|
| + testGenerateAppForLink("chrome://about", "test",
|
| + "The URL \"chrome://about\" is invalid.");
|
| + testGenerateAppForLink("chrome-extension://test/test", "test",
|
| + "The URL \"chrome-extension://test/test\" is invalid.");
|
| + },
|
| +
|
| + function generateAppWithEmptyTitle() {
|
| + testGenerateAppForLink("http://google.com", "",
|
| + "The title can not be empty.");
|
| + },
|
| +
|
| + function generateAppForLinkWithShortURL() {
|
| + var url = "http://google.com", title = "testApp";
|
| + testGenerateAppForLink(
|
| + url, title, callback(function(data) {
|
| + assertEq("http://google.com/", data.appLaunchUrl);
|
| + assertEq(title, data.name);
|
| +
|
| + chrome.management.getAll(callback(function(items) {
|
| + assertTrue(getItemNamed(items, title) != null);
|
| + }));
|
| + }));
|
| + },
|
| +
|
| + function generateAppForLinkWithLongURL() {
|
| + var url = "http://google.com/page/page?aa=bb&cc=dd", title = "test App 2";
|
| + testGenerateAppForLink(
|
| + url, title, callback(function(data) {
|
| + assertEq(url, data.appLaunchUrl);
|
| + assertEq(title, data.name);
|
| +
|
| + chrome.management.getAll(callback(function(items) {
|
| + assertTrue(getItemNamed(items, title) != null);
|
| + }));
|
| + }));
|
| + }
|
| +];
|
| +
|
| +chrome.test.runTests(tests);
|
| +
|
|
|