OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('settings_search', function() { | 5 cr.define('settings_search', function() { |
6 /** | 6 /** |
7 * A test version of SearchEnginesBrowserProxy. Provides helper methods | 7 * A test version of SearchEnginesBrowserProxy. Provides helper methods |
8 * for allowing tests to know when a method was called, as well as | 8 * for allowing tests to know when a method was called, as well as |
9 * specifying mock responses. | 9 * specifying mock responses. |
10 * | 10 * |
11 * @constructor | 11 * @constructor |
12 * @implements {settings.SearchEnginesBrowserProxy} | 12 * @implements {settings.SearchEnginesBrowserProxy} |
13 * @extends {settings.TestBrowserProxy} | 13 * @extends {settings.TestBrowserProxy} |
14 */ | 14 */ |
15 var TestSearchEnginesBrowserProxy = function() { | 15 var TestSearchEnginesBrowserProxy = function() { |
16 settings.TestBrowserProxy.call(this, [ | 16 settings.TestBrowserProxy.call(this, [ |
17 'getSearchEnginesList', | 17 'getSearchEnginesList', |
18 'removeSearchEngine', | 18 'removeSearchEngine', |
19 'searchEngineEditCancelled', | 19 'searchEngineEditCancelled', |
20 'searchEngineEditCompleted', | 20 'searchEngineEditCompleted', |
21 'searchEngineEditStarted', | 21 'searchEngineEditStarted', |
22 'setDefaultSearchEngine', | 22 'setDefaultSearchEngine', |
23 'validateSearchEngineInput', | 23 'validateSearchEngineInput', |
24 'manageExtension', | |
25 'disableExtension', | |
26 ]); | 24 ]); |
27 | 25 |
28 /** @private {!SearchEnginesInfo} */ | 26 /** @private {!SearchEnginesInfo} */ |
29 this.searchEnginesInfo_ = {defaults: [], others: [], extensions: []}; | 27 this.searchEnginesInfo_ = {defaults: [], others: [], extensions: []}; |
30 }; | 28 }; |
31 | 29 |
32 TestSearchEnginesBrowserProxy.prototype = { | 30 TestSearchEnginesBrowserProxy.prototype = { |
33 __proto__: settings.TestBrowserProxy.prototype, | 31 __proto__: settings.TestBrowserProxy.prototype, |
34 | 32 |
35 /** @override */ | 33 /** @override */ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 getSearchEnginesList: function() { | 67 getSearchEnginesList: function() { |
70 this.methodCalled('getSearchEnginesList'); | 68 this.methodCalled('getSearchEnginesList'); |
71 return Promise.resolve(this.searchEnginesInfo_); | 69 return Promise.resolve(this.searchEnginesInfo_); |
72 }, | 70 }, |
73 | 71 |
74 /** @override */ | 72 /** @override */ |
75 validateSearchEngineInput: function(fieldName, fieldValue) { | 73 validateSearchEngineInput: function(fieldName, fieldValue) { |
76 this.methodCalled('validateSearchEngineInput'); | 74 this.methodCalled('validateSearchEngineInput'); |
77 return Promise.resolve(true); | 75 return Promise.resolve(true); |
78 }, | 76 }, |
79 | |
80 /** @override */ | |
81 manageExtension: function(extensionId) { | |
82 this.methodCalled('manageExtension', extensionId); | |
83 }, | |
84 | |
85 /** @override */ | |
86 disableExtension: function(extensionId) { | |
87 this.methodCalled('disableExtension', extensionId); | |
88 }, | |
89 }; | 77 }; |
90 | 78 |
91 /** | 79 /** |
92 * @param {boolean} canBeDefault | 80 * @param {boolean} canBeDefault |
93 * @param {boolean} canBeEdited | 81 * @param {boolean} canBeEdited |
94 * @param {boolean} canBeRemoved | 82 * @param {boolean} canBeRemoved |
95 * @return {!SearchEngine} | 83 * @return {!SearchEngine} |
96 */ | 84 */ |
97 function createSampleSearchEngine(canBeDefault, canBeEdited, canBeRemoved) { | 85 function createSampleSearchEngine(canBeDefault, canBeEdited, canBeRemoved) { |
98 return { | 86 return { |
(...skipping 10 matching lines...) Expand all Loading... |
109 url: "https://search.foo.com/search?p=%s", | 97 url: "https://search.foo.com/search?p=%s", |
110 urlLocked: false, | 98 urlLocked: false, |
111 }; | 99 }; |
112 } | 100 } |
113 | 101 |
114 return { | 102 return { |
115 createSampleSearchEngine: createSampleSearchEngine, | 103 createSampleSearchEngine: createSampleSearchEngine, |
116 TestSearchEnginesBrowserProxy: TestSearchEnginesBrowserProxy, | 104 TestSearchEnginesBrowserProxy: TestSearchEnginesBrowserProxy, |
117 }; | 105 }; |
118 }); | 106 }); |
OLD | NEW |