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

Side by Side Diff: extensions/test/data/app_view/apitest/main.js

Issue 643703007: Adding app_view tests to app_shell_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multiple_apps
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
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 = '';
8 embedder.emptyGuestURL = '';
9 embedder.windowOpenGuestURL = '';
10 embedder.noReferrerGuestURL = '';
11 embedder.redirectGuestURL = '';
12 embedder.redirectGuestURLDest = '';
13 embedder.closeSocketURL = '';
14 embedder.tests = {};
15
16 embedder.setUp_ = function(config) {
17 if (!config || !config.testServer) {
18 return;
19 }
20 embedder.baseGuestURL = 'http://localhost:' + config.testServer.port;
21 embedder.emptyGuestURL = embedder.baseGuestURL +
22 '/extensions/platform_apps/web_view/shim/empty_guest.html';
23 };
24 7
25 window.runTest = function(testName, appToEmbed) { 8 window.runTest = function(testName, appToEmbed) {
26 if (!embedder.test.testList[testName]) { 9 if (!embedder.test.testList[testName]) {
27 window.console.log('Incorrect testName: ' + testName); 10 window.console.log('Incorrect testName: ' + testName);
28 embedder.test.fail(); 11 embedder.test.fail();
29 return; 12 return;
30 } 13 }
31 14
32 // Run the test. 15 // Run the test.
33 embedder.test.testList[testName](appToEmbed); 16 embedder.test.testList[testName](appToEmbed);
(...skipping 27 matching lines...) Expand all
61 }; 44 };
62 45
63 embedder.test.assertFalse = function(condition) { 46 embedder.test.assertFalse = function(condition) {
64 if (condition) { 47 if (condition) {
65 console.log('assertion failed: false != ' + condition); 48 console.log('assertion failed: false != ' + condition);
66 embedder.test.fail(); 49 embedder.test.fail();
67 } 50 }
68 }; 51 };
69 52
70 // Tests begin. 53 // Tests begin.
71 function testAppViewWithUndefinedDataShouldSucceed(appToEmbed) { 54 function testAppViewGoodDataShouldSucceed(appToEmbed) {
72 var appview = new AppView(); 55 var appview = new AppView();
73 LOG('appToEmbed ' + appToEmbed); 56 LOG('appToEmbed ' + appToEmbed);
74 document.body.appendChild(appview); 57 document.body.appendChild(appview);
75 // Step 1: Attempt to connect to a non-existant app. 58 LOG('Attempting to connect to app with good params.');
76 LOG('attempting to connect to non-existant app.'); 59 // Step 2: Attempt to connect to an app with good params.
77 appview.connect('abc123', undefined, function(success) { 60 appview.connect(appToEmbed, { 'foo': 'bleep' }, function(success) {
lazyboy 2014/10/24 20:13:25 Here and below: no space after { or before }
lfg 2014/10/24 20:24:30 Done.
78 // Make sure we fail. 61 // Make sure we don't fail.
79 if (success) { 62 if (!success) {
80 LOG('UNEXPECTED CONNECTION.'); 63 LOG('FAILED TO CONNECT.');
81 embedder.test.fail(); 64 embedder.test.fail();
82 return; 65 return;
83 } 66 }
84 LOG('failed to connect to non-existant app.'); 67 LOG('CONNECTED.');
85 LOG('attempting to connect to known app.'); 68 embedder.test.succeed();
86 // Step 2: Attempt to connect to an app we know exists.
87 appview.connect(appToEmbed, undefined, function(success) {
88 // Make sure we don't fail.
89 if (!success) {
90 LOG('FAILED TO CONNECT.');
91 embedder.test.fail();
92 return;
93 }
94 LOG('CONNECTED.');
95 embedder.test.succeed();
96 });
97 }); 69 });
98 }; 70 };
99 71
100 function testAppViewRefusedDataShouldFail(appToEmbed) { 72 function testAppViewRefusedDataShouldFail(appToEmbed) {
101 var appview = new AppView(); 73 var appview = new AppView();
102 LOG('appToEmbed ' + appToEmbed); 74 LOG('appToEmbed ' + appToEmbed);
103 document.body.appendChild(appview); 75 document.body.appendChild(appview);
104 LOG('Attempting to connect to app with refused params.'); 76 LOG('Attempting to connect to app with refused params.');
105 appview.connect(appToEmbed, { 'foo': 'bar' }, function(success) { 77 appview.connect(appToEmbed, { 'foo': 'bar' }, function(success) {
106 // Make sure we fail. 78 // Make sure we fail.
107 if (success) { 79 if (success) {
108 LOG('UNEXPECTED CONNECTION.'); 80 LOG('UNEXPECTED CONNECTION.');
109 embedder.test.fail(); 81 embedder.test.fail();
110 return; 82 return;
111 } 83 }
112 LOG('FAILED TO CONNECT.'); 84 LOG('FAILED TO CONNECT.');
113 embedder.test.succeed(); 85 embedder.test.succeed();
114 }); 86 });
115 }; 87 };
116 88
117 function testAppViewGoodDataShouldSucceed(appToEmbed) { 89 function testAppViewWithUndefinedDataShouldSucceed(appToEmbed) {
118 var appview = new AppView(); 90 var appview = new AppView();
119 LOG('appToEmbed ' + appToEmbed); 91 LOG('appToEmbed ' + appToEmbed);
120 document.body.appendChild(appview); 92 document.body.appendChild(appview);
121 LOG('Attempting to connect to app with good params.'); 93 // Step 1: Attempt to connect to a non-existant app.
lazyboy 2014/10/24 20:13:25 s/non-existant/non-existent Also add note that "ab
lfg 2014/10/24 20:24:29 Done.
122 // Step 2: Attempt to connect to an app with good params. 94 LOG('attempting to connect to non-existant app.');
lazyboy 2014/10/24 20:13:25 nit: s/attempting/Attempting
lfg 2014/10/24 20:24:30 Done.
123 appview.connect(appToEmbed, { 'foo': 'bleep' }, function(success) { 95 appview.connect('abc123', undefined, function(success) {
124 // Make sure we don't fail. 96 // Make sure we fail.
125 if (!success) { 97 if (success) {
126 LOG('FAILED TO CONNECT.'); 98 LOG('UNEXPECTED CONNECTION.');
127 embedder.test.fail(); 99 embedder.test.fail();
128 return; 100 return;
129 } 101 }
130 LOG('CONNECTED.'); 102 LOG('failed to connect to non-existant app.');
131 embedder.test.succeed(); 103 LOG('attempting to connect to known app.');
104 // Step 2: Attempt to connect to an app we know exists.
105 appview.connect(appToEmbed, undefined, function(success) {
106 // Make sure we don't fail.
107 if (!success) {
108 LOG('FAILED TO CONNECT.');
109 embedder.test.fail();
110 return;
111 }
112 LOG('CONNECTED.');
lazyboy 2014/10/24 20:13:25 nit: s/CONNECTED/Connected, SHOUT only when things
lfg 2014/10/24 20:24:30 Done.
113 embedder.test.succeed();
114 });
132 }); 115 });
133 }; 116 };
134 117
135 embedder.test.testList = { 118 embedder.test.testList = {
119 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed,
120 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail,
136 'testAppViewWithUndefinedDataShouldSucceed': 121 'testAppViewWithUndefinedDataShouldSucceed':
137 testAppViewWithUndefinedDataShouldSucceed, 122 testAppViewWithUndefinedDataShouldSucceed
138 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail,
139 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed
140 }; 123 };
141 124
142 onload = function() { 125 onload = function() {
143 chrome.test.getConfig(function(config) { 126 chrome.test.sendMessage('LAUNCHED');
144 embedder.setUp_(config);
145 chrome.test.sendMessage('Launched');
146 });
147 }; 127 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698