Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3078)

Unified Diff: chrome/test/data/extensions/api_test/management/test/generateAppForLink.js

Issue 266353006: Add generateAppForLink function in chrome.management (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,78 @@
+// 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, error, func) {
+ chrome.test.runWithUserGesture(function() {
+ if (error)
+ chrome.management.generateAppForLink(
+ url, title, callback(function(data) {}, error));
+ else
+ chrome.management.generateAppForLink(url, title, callback(func));
+ });
+}
+
+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, null, function(data) {
+ assertEq("http://google.com/", data.appLaunchUrl);
+ assertEq(title, data.name);
+ // There is no favicon in the test browser, so only 4 icons will
+ // be created.
+ assertEq(4, data.icons.length);
+ assertEq(32, data.icons[0].size);
+ assertEq(48, data.icons[1].size);
+ assertEq(64, data.icons[2].size);
+ assertEq(96, data.icons[3].size);
+
+ 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, null, function(data) {
+ assertEq(url, data.appLaunchUrl);
+ assertEq(title, data.name);
+ assertEq(4, data.icons.length);
+ assertEq(32, data.icons[0].size);
+ assertEq(48, data.icons[1].size);
+ assertEq(64, data.icons[2].size);
+ assertEq(96, data.icons[3].size);
+
+ chrome.management.getAll(callback(function(items) {
+ assertTrue(getItemNamed(items, title) != null);
+ }));
+ });
+ }
+];
+
+chrome.test.runTests(tests);
+

Powered by Google App Engine
This is Rietveld 408576698