| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 5 /** |
| 6 * TestFixture for OptionsPage WebUI testing. | 6 * TestFixture for OptionsPage WebUI testing. |
| 7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
| 8 * @constructor | 8 * @constructor |
| 9 */ | 9 */ |
| 10 function OptionsWebUITest() {} | 10 function OptionsWebUITest() {} |
| 11 | 11 |
| 12 OptionsWebUITest.prototype = { | 12 OptionsWebUITest.prototype = { |
| 13 __proto__: testing.Test.prototype, | 13 __proto__: testing.Test.prototype, |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Browse to the options page & call our preLoad(). | 16 * Browse to the options page & call our preLoad(). |
| 17 */ | 17 */ |
| 18 browsePreload: 'chrome://settings', | 18 browsePreload: 'chrome://settings', |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Register a mock handler to ensure expectations are met and options pages | 21 * Register a mock handler to ensure expectations are met and options pages |
| 22 * behave correctly. | 22 * behave correctly. |
| 23 */ | 23 */ |
| 24 preLoad: function() { | 24 preLoad: function() { |
| 25 this.makeAndRegisterMockHandler( |
| 26 ['coreOptionsInitialize', |
| 27 'fetchPrefs', |
| 28 'observePrefs', |
| 29 'setBooleanPref', |
| 30 'setIntegerPref', |
| 31 'setDoublePref', |
| 32 'setStringPref', |
| 33 'setObjectPref', |
| 34 'clearPref', |
| 35 'coreOptionsUserMetricsAction', |
| 36 // TODO(scr): Handle this new message: |
| 37 // getInstantFieldTrialStatus: function() {}, |
| 38 ]); |
| 25 | 39 |
| 26 /** | 40 // Register stubs for methods expected to be called before our tests run. |
| 27 * Create handler class with empty methods to allow mocking to register | 41 // Specific expectations can be made in the tests themselves. |
| 28 * expectations and for registration of handlers with chrome.send. | 42 var mockHandler = this.mockHandler; |
| 29 */ | |
| 30 function MockOptionsHandler() {} | |
| 31 | |
| 32 MockOptionsHandler.prototype = { | |
| 33 coreOptionsInitialize: function() {}, | |
| 34 fetchPrefs: function() {}, | |
| 35 observePrefs: function() {}, | |
| 36 setBooleanPref: function() {}, | |
| 37 setIntegerPref: function() {}, | |
| 38 setDoublePref: function() {}, | |
| 39 setStringPref: function() {}, | |
| 40 setObjectPref: function() {}, | |
| 41 clearPref: function() {}, | |
| 42 coreOptionsUserMetricsAction: function() {}, | |
| 43 // TODO(scr): Handle this new message: | |
| 44 // getInstantFieldTrialStatus: function() {}, | |
| 45 }; | |
| 46 | |
| 47 // Create the actual mock and register stubs for methods expected to be | |
| 48 // called before our tests run. Specific expectations can be made in the | |
| 49 // tests themselves. | |
| 50 var mockHandler = this.mockHandler = mock(MockOptionsHandler); | |
| 51 mockHandler.stubs().fetchPrefs(ANYTHING); | 43 mockHandler.stubs().fetchPrefs(ANYTHING); |
| 52 mockHandler.stubs().observePrefs(ANYTHING); | 44 mockHandler.stubs().observePrefs(ANYTHING); |
| 53 mockHandler.stubs().coreOptionsInitialize(); | 45 mockHandler.stubs().coreOptionsInitialize(); |
| 54 | |
| 55 // Register our mock as a handler of the chrome.send messages. | |
| 56 registerMockMessageCallbacks(mockHandler, MockOptionsHandler); | |
| 57 }, | 46 }, |
| 58 }; | 47 }; |
| 59 | 48 |
| 60 // Crashes on Mac only. See http://crbug.com/79181 | 49 // Crashes on Mac only. See http://crbug.com/79181 |
| 61 GEN('#if defined(OS_MACOSX)'); | 50 GEN('#if defined(OS_MACOSX)'); |
| 62 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + | 51 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + |
| 63 'DISABLED_testSetBooleanPrefTriggers'); | 52 'DISABLED_testSetBooleanPrefTriggers'); |
| 64 GEN('#else'); | 53 GEN('#else'); |
| 65 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); | 54 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); |
| 66 GEN('#endif // defined(OS_MACOSX)'); | 55 GEN('#endif // defined(OS_MACOSX)'); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 97 item.onclick(); | 86 item.onclick(); |
| 98 window.location.reload(); | 87 window.location.reload(); |
| 99 var pageInstance = AdvancedOptions.getInstance(); | 88 var pageInstance = AdvancedOptions.getInstance(); |
| 100 var topPage = OptionsPage.getTopmostVisiblePage(); | 89 var topPage = OptionsPage.getTopmostVisiblePage(); |
| 101 var expectedTitle = pageInstance.title; | 90 var expectedTitle = pageInstance.title; |
| 102 var actualTitle = document.title; | 91 var actualTitle = document.title; |
| 103 assertEquals("chrome://settings/advanced", document.location.href); | 92 assertEquals("chrome://settings/advanced", document.location.href); |
| 104 assertEquals(expectedTitle, actualTitle); | 93 assertEquals(expectedTitle, actualTitle); |
| 105 assertEquals(pageInstance, topPage); | 94 assertEquals(pageInstance, topPage); |
| 106 }); | 95 }); |
| OLD | NEW |