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

Side by Side Diff: LayoutTests/inspector/device-emulation/device-emulation-test.js

Issue 1209013002: [DevTools] Add test for screen size and position overrides. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/inspector/device-emulation/device-emulation-restore.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function setMetaViewport() 1 function setMetaViewport()
2 { 2 {
3 var VIEWPORTS = { 3 var VIEWPORTS = {
4 "w=320": "width=320", 4 "w=320": "width=320",
5 "w=dw": "width=device-width", 5 "w=dw": "width=device-width",
6 "w=980": "width=980", 6 "w=980": "width=980",
7 "none": "no viewport (desktop site)" 7 "none": "no viewport (desktop site)"
8 }; 8 };
9 9
10 var viewport = VIEWPORTS["none"]; 10 var viewport = VIEWPORTS["none"];
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 var initialize_DeviceEmulationTest = function() { 181 var initialize_DeviceEmulationTest = function() {
182 182
183 InspectorTest.preloadPanel("network"); 183 InspectorTest.preloadPanel("network");
184 184
185 InspectorTest.getPageMetrics = function(full, callback) 185 InspectorTest.getPageMetrics = function(full, callback)
186 { 186 {
187 InspectorTest.evaluateInPage("dumpMetrics(" + full + ")", callback); 187 InspectorTest.evaluateInPage("dumpMetrics(" + full + ")", callback);
188 } 188 }
189 189
190 InspectorTest.applyEmulationAndReload = function(enabled, width, height, deviceS caleFactor, viewport, callback) 190 InspectorTest.applyEmulationAndReload = function(enabled, width, height, deviceS caleFactor, viewport, insets, callback)
191 { 191 {
192 function PageResizer()
193 {
194 }
195
196 PageResizer.prototype =
197 {
198 update: function(dipWidth, dipHeight, scale) { },
199 __proto__: WebInspector.Object.prototype
200 }
201
192 InspectorTest.addSniffer(WebInspector.overridesSupport, "_deviceMetricsOverr ideAppliedForTest", emulateCallback); 202 InspectorTest.addSniffer(WebInspector.overridesSupport, "_deviceMetricsOverr ideAppliedForTest", emulateCallback);
203 if (insets)
204 WebInspector.overridesSupport.setPageResizer(new PageResizer(), new Size (10, 10), insets);
205 else
206 WebInspector.overridesSupport.setPageResizer(null, new Size(0, 0), new I nsets(0, 0));
207
193 if (enabled) { 208 if (enabled) {
194 var device = {title: "", width: width, height: height, deviceScaleFactor : deviceScaleFactor, userAgent: "", touch: false, mobile: true}; 209 var device = {title: "", width: width, height: height, deviceScaleFactor : deviceScaleFactor, userAgent: "", touch: false, mobile: true};
195 WebInspector.overridesSupport.emulateDevice(device); 210 WebInspector.overridesSupport.emulateDevice(device);
196 } else { 211 } else {
197 WebInspector.overridesSupport.reset(); 212 WebInspector.overridesSupport.reset();
198 } 213 }
199 WebInspector.overridesSupport.settings._emulationEnabled.set(enabled); 214 WebInspector.overridesSupport.settings._emulationEnabled.set(enabled);
200 215
201 function emulateCallback() 216 function emulateCallback()
202 { 217 {
203 var warning = WebInspector.overridesSupport.warningMessage(); 218 var warning = WebInspector.overridesSupport.warningMessage();
204 if (warning) 219 if (warning)
205 InspectorTest._deviceEmulationResults.push("Emulation warning: " + w arning); 220 InspectorTest._deviceEmulationResults.push("Emulation warning: " + w arning);
206 InspectorTest.navigate(InspectorTest._deviceEmulationPageUrl + "?" + vie wport, callback); 221 InspectorTest.navigate(InspectorTest._deviceEmulationPageUrl + "?" + vie wport, callback);
207 } 222 }
208 }; 223 };
209 224
210 InspectorTest.emulateAndGetMetrics = function(width, height, deviceScaleFactor, viewport, callback) 225 InspectorTest.emulateAndGetMetrics = function(width, height, deviceScaleFactor, viewport, insets, callback)
211 { 226 {
212 InspectorTest._deviceEmulationResults.push("Emulating device: " + width + "x " + height + "x" + deviceScaleFactor + " viewport='" + viewport + "'"); 227 InspectorTest._deviceEmulationResults.push("Emulating device: " + width + "x " + height + "x" + deviceScaleFactor + " viewport='" + viewport + "'");
213 var full = !!width && !!height && !!deviceScaleFactor; 228 var full = !!width && !!height && !!deviceScaleFactor;
214 InspectorTest.applyEmulationAndReload(true, width, height, deviceScaleFactor , viewport, InspectorTest.getPageMetrics.bind(InspectorTest, full, printMetrics) ); 229 InspectorTest.applyEmulationAndReload(true, width, height, deviceScaleFactor , viewport, insets, InspectorTest.getPageMetrics.bind(InspectorTest, full, print Metrics));
215 230
216 function printMetrics(metrics) 231 function printMetrics(metrics)
217 { 232 {
218 InspectorTest._deviceEmulationResults.push(metrics.value + "\n"); 233 InspectorTest._deviceEmulationResults.push(metrics.value + "\n");
219 callback(); 234 callback();
220 } 235 }
221 }; 236 };
222 237
223 InspectorTest.testDeviceEmulation = function(pageUrl, width, height, deviceScale Factor, viewport) 238 InspectorTest.testDeviceEmulation = function(pageUrl, width, height, deviceScale Factor, viewport, insets)
224 { 239 {
225 InspectorTest._deviceEmulationPageUrl = pageUrl; 240 InspectorTest._deviceEmulationPageUrl = pageUrl;
226 InspectorTest._deviceEmulationResults = []; 241 InspectorTest._deviceEmulationResults = [];
227 InspectorTest.emulateAndGetMetrics(width, height, deviceScaleFactor, viewpor t, callback); 242 InspectorTest.emulateAndGetMetrics(width, height, deviceScaleFactor, viewpor t, insets, callback);
228 243
229 function callback() 244 function callback()
230 { 245 {
231 InspectorTest.addResult(InspectorTest._deviceEmulationResults.join("\n") ); 246 InspectorTest.addResult(InspectorTest._deviceEmulationResults.join("\n") );
232 InspectorTest.completeTest(); 247 InspectorTest.completeTest();
233 } 248 }
234 }; 249 };
235 250
236 }; 251 };
OLDNEW
« no previous file with comments | « LayoutTests/inspector/device-emulation/device-emulation-restore.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698