OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // In case of exception the override won't be called. | 217 // In case of exception the override won't be called. |
218 try { | 218 try { |
219 override.apply(this, arguments); | 219 override.apply(this, arguments); |
220 } catch (e) { | 220 } catch (e) { |
221 test.fail("Exception in overriden method '" + methodName + "': " + e
); | 221 test.fail("Exception in overriden method '" + methodName + "': " + e
); |
222 } | 222 } |
223 return result; | 223 return result; |
224 }; | 224 }; |
225 }; | 225 }; |
226 | 226 |
| 227 /** |
| 228 * Waits for current throttler invocations, if any. |
| 229 * @param {!WebInspector.Throttler} throttler |
| 230 * @param {!function} callback |
| 231 */ |
| 232 TestSuite.prototype.waitForThrottler = function(throttler, callback) |
| 233 { |
| 234 var test = this; |
| 235 var scheduleShouldFail = true; |
| 236 test.addSniffer(throttler, "schedule", onSchedule); |
| 237 |
| 238 function hasSomethingScheduled() |
| 239 { |
| 240 return throttler._isRunningProcess || throttler._process; |
| 241 } |
| 242 |
| 243 function checkState() |
| 244 { |
| 245 if (!hasSomethingScheduled()) { |
| 246 scheduleShouldFail = false; |
| 247 callback(); |
| 248 return; |
| 249 } |
| 250 |
| 251 test.addSniffer(throttler, "_processCompletedForTests", checkState); |
| 252 } |
| 253 |
| 254 function onSchedule() |
| 255 { |
| 256 if (scheduleShouldFail) |
| 257 test.fail("Unexpected Throttler.schedule"); |
| 258 } |
| 259 |
| 260 checkState(); |
| 261 }; |
227 | 262 |
228 // UI Tests | 263 // UI Tests |
229 | 264 |
230 | 265 |
231 /** | 266 /** |
232 * Tests that scripts tab can be open and populated with inspected scripts. | 267 * Tests that scripts tab can be open and populated with inspected scripts. |
233 */ | 268 */ |
234 TestSuite.prototype.testShowScriptsTab = function() | 269 TestSuite.prototype.testShowScriptsTab = function() |
235 { | 270 { |
236 this.showPanel("sources"); | 271 this.showPanel("sources"); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 function step4() | 643 function step4() |
609 { | 644 { |
610 testOverrides({width: 1200, height: 1000, deviceScaleFactor: 3, mobile:
false, fitWindow: false}, {width: 1200, height: 1000, deviceScaleFactor: 3}, fin
ish); | 645 testOverrides({width: 1200, height: 1000, deviceScaleFactor: 3, mobile:
false, fitWindow: false}, {width: 1200, height: 1000, deviceScaleFactor: 3}, fin
ish); |
611 } | 646 } |
612 | 647 |
613 function finish() | 648 function finish() |
614 { | 649 { |
615 test.releaseControl(); | 650 test.releaseControl(); |
616 } | 651 } |
617 | 652 |
618 step1(); | 653 WebInspector.overridesSupport._deviceMetricsChangedListenerMuted = true; |
619 test.takeControl(); | 654 test.takeControl(); |
| 655 this.waitForThrottler(WebInspector.overridesSupport._deviceMetricsThrottler,
step1); |
620 }; | 656 }; |
621 | 657 |
622 TestSuite.prototype.waitForTestResultsInConsole = function() | 658 TestSuite.prototype.waitForTestResultsInConsole = function() |
623 { | 659 { |
624 var messages = WebInspector.multitargetConsoleModel.messages(); | 660 var messages = WebInspector.multitargetConsoleModel.messages(); |
625 for (var i = 0; i < messages.length; ++i) { | 661 for (var i = 0; i < messages.length; ++i) { |
626 var text = messages[i].messageText; | 662 var text = messages[i].messageText; |
627 if (text === "PASS") | 663 if (text === "PASS") |
628 return; | 664 return; |
629 else if (/^FAIL/.test(text)) | 665 else if (/^FAIL/.test(text)) |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 delete uiTests._pendingTestName; | 919 delete uiTests._pendingTestName; |
884 if (name) | 920 if (name) |
885 new TestSuite().runTest(name); | 921 new TestSuite().runTest(name); |
886 } | 922 } |
887 | 923 |
888 WebInspector.notifications.addEventListener(WebInspector.NotificationService.Eve
nts.InspectorAgentEnabledForTests, runTests); | 924 WebInspector.notifications.addEventListener(WebInspector.NotificationService.Eve
nts.InspectorAgentEnabledForTests, runTests); |
889 | 925 |
890 })(); | 926 })(); |
891 | 927 |
892 } | 928 } |
OLD | NEW |