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 | 7 |
8 window.runTest = function(testName, appToEmbed) { | 8 window.runTest = function(testName, appToEmbed) { |
9 if (!embedder.test.testList[testName]) { | 9 if (!embedder.test.testList[testName]) { |
10 window.console.log('Incorrect testName: ' + testName); | 10 window.console.log('Incorrect testName: ' + testName); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (!success) { | 62 if (!success) { |
63 LOG('FAILED TO CONNECT.'); | 63 LOG('FAILED TO CONNECT.'); |
64 embedder.test.fail(); | 64 embedder.test.fail(); |
65 return; | 65 return; |
66 } | 66 } |
67 LOG('Connected.'); | 67 LOG('Connected.'); |
68 embedder.test.succeed(); | 68 embedder.test.succeed(); |
69 }); | 69 }); |
70 }; | 70 }; |
71 | 71 |
| 72 function testAppViewMediaRequest(appToEmbed) { |
| 73 var appview = new AppView(); |
| 74 window.console.log('appToEmbed ' + appToEmbed); |
| 75 document.body.appendChild(appview); |
| 76 window.console.log('Attempting to connect to app.'); |
| 77 appview.connect(appToEmbed, {}, function(success) { |
| 78 // Make sure we don't fail. |
| 79 if (!success) { |
| 80 window.console.log('Failed to connect.'); |
| 81 embedder.test.fail(); |
| 82 return; |
| 83 } |
| 84 window.console.log('Connected.'); |
| 85 embedder.test.succeed(); |
| 86 }); |
| 87 }; |
| 88 |
72 function testAppViewRefusedDataShouldFail(appToEmbed) { | 89 function testAppViewRefusedDataShouldFail(appToEmbed) { |
73 var appview = new AppView(); | 90 var appview = new AppView(); |
74 LOG('appToEmbed ' + appToEmbed); | 91 LOG('appToEmbed ' + appToEmbed); |
75 document.body.appendChild(appview); | 92 document.body.appendChild(appview); |
76 LOG('Attempting to connect to app with refused params.'); | 93 LOG('Attempting to connect to app with refused params.'); |
77 appview.connect(appToEmbed, {'foo': 'bar'}, function(success) { | 94 appview.connect(appToEmbed, {'foo': 'bar'}, function(success) { |
78 // Make sure we fail. | 95 // Make sure we fail. |
79 if (success) { | 96 if (success) { |
80 LOG('UNEXPECTED CONNECTION.'); | 97 LOG('UNEXPECTED CONNECTION.'); |
81 embedder.test.fail(); | 98 embedder.test.fail(); |
(...skipping 28 matching lines...) Expand all Loading... |
110 return; | 127 return; |
111 } | 128 } |
112 LOG('Connected.'); | 129 LOG('Connected.'); |
113 embedder.test.succeed(); | 130 embedder.test.succeed(); |
114 }); | 131 }); |
115 }); | 132 }); |
116 }; | 133 }; |
117 | 134 |
118 embedder.test.testList = { | 135 embedder.test.testList = { |
119 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed, | 136 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed, |
| 137 'testAppViewMediaRequest': testAppViewMediaRequest, |
120 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail, | 138 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail, |
121 'testAppViewWithUndefinedDataShouldSucceed': | 139 'testAppViewWithUndefinedDataShouldSucceed': |
122 testAppViewWithUndefinedDataShouldSucceed | 140 testAppViewWithUndefinedDataShouldSucceed |
123 }; | 141 }; |
124 | 142 |
125 onload = function() { | 143 onload = function() { |
126 chrome.test.sendMessage('LAUNCHED'); | 144 chrome.test.sendMessage('LAUNCHED'); |
127 }; | 145 }; |
OLD | NEW |