Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var util = {}; | 5 var util = {}; |
| 6 var embedder = {}; | 6 var embedder = {}; |
| 7 embedder.baseGuestURL = ''; | 7 embedder.baseGuestURL = ''; |
| 8 embedder.emptyGuestURL = ''; | 8 embedder.emptyGuestURL = ''; |
| 9 embedder.windowOpenGuestURL = ''; | 9 embedder.windowOpenGuestURL = ''; |
| 10 embedder.noReferrerGuestURL = ''; | 10 embedder.noReferrerGuestURL = ''; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 embedder.test.fail(); | 66 embedder.test.fail(); |
| 67 } | 67 } |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Tests begin. | 70 // Tests begin. |
| 71 function testAppViewBasic(appToEmbed) { | 71 function testAppViewBasic(appToEmbed) { |
| 72 var appview = new AppView(); | 72 var appview = new AppView(); |
| 73 LOG('appToEmbed ' + appToEmbed); | 73 LOG('appToEmbed ' + appToEmbed); |
| 74 // Step 1: Attempt to connect to a non-existant app. | 74 // Step 1: Attempt to connect to a non-existant app. |
| 75 LOG('attempting to connect to non-existant app.'); | 75 LOG('attempting to connect to non-existant app.'); |
| 76 appview.connect('abc123', function(success) { | 76 appview.connect('abc123', {}, function(success) { |
| 77 // Make sure we fail. | 77 // Make sure we fail. |
| 78 if (success) { | 78 if (success) { |
| 79 embedder.test.fail(); | 79 embedder.test.fail(); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 LOG('failed to connect to non-existant app.'); | 82 LOG('failed to connect to non-existant app.'); |
| 83 LOG('attempting to connect to known app.'); | 83 LOG('attempting to connect to known app.'); |
| 84 // Step 2: Attempt to connect to an app we know exists. | 84 // Step 2: Attempt to connect to an app we know exists. |
| 85 appview.connect(appToEmbed, function(success) { | 85 appview.connect(appToEmbed, {}, function(success) { |
| 86 // Make sure we don't fail. | 86 // Make sure we don't fail. |
| 87 if (!success) { | 87 if (!success) { |
| 88 embedder.test.fail(); | 88 embedder.test.fail(); |
| 89 return; | |
| 90 } | |
| 91 embedder.test.succeed(); | |
| 92 }); | |
| 93 }); | |
| 94 document.body.appendChild(appview); | |
| 95 }; | |
| 96 | |
| 97 // Tests begin. | |
| 98 function testAppViewParams(appToEmbed) { | |
| 99 var appview = new AppView(); | |
| 100 LOG('appToEmbed ' + appToEmbed); | |
| 101 // Step 1: Attempt to connect to an app with refused params. | |
| 102 LOG('attempting to connect to app with refused params.'); | |
| 103 appview.connect(appToEmbed, { 'foo': 'bar' }, function(success) { | |
| 104 // Make sure we fail. | |
| 105 if (success) { | |
| 106 embedder.test.fail(); | |
| 107 return; | |
| 108 } | |
| 109 // Step 2: Attempt to connect to an app with good params. | |
| 110 appview.connect(appToEmbed, { 'foo': 'bleep' }, function(success) { | |
|
Xi Han
2014/08/12 18:52:18
I think the step 2 shouldn't be a part of the call
| |
| 111 // Make sure we don't fail. | |
| 112 if (!success) { | |
| 113 embedder.test.fail(); | |
| 89 return; | 114 return; |
| 90 } | 115 } |
| 91 embedder.test.succeed(); | 116 embedder.test.succeed(); |
| 92 }); | 117 }); |
| 93 }); | 118 }); |
| 94 document.body.appendChild(appview); | 119 document.body.appendChild(appview); |
| 95 }; | 120 }; |
| 96 | 121 |
| 97 embedder.test.testList = { | 122 embedder.test.testList = { |
| 98 'testAppViewBasic': testAppViewBasic | 123 'testAppViewBasic': testAppViewBasic, |
| 124 'testAppViewParams': testAppViewParams | |
|
Xi Han
2014/08/12 18:52:18
Maybe we can split the second test as two, like:
t
| |
| 99 }; | 125 }; |
| 100 | 126 |
| 101 onload = function() { | 127 onload = function() { |
| 102 chrome.test.getConfig(function(config) { | 128 chrome.test.getConfig(function(config) { |
| 103 embedder.setUp_(config); | 129 embedder.setUp_(config); |
| 104 chrome.test.sendMessage('Launched'); | 130 chrome.test.sendMessage('Launched'); |
| 105 }); | 131 }); |
| 106 }; | 132 }; |
| OLD | NEW |