| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @implements {settings.DownloadsBrowserProxy} |
| 8 * @extends {settings.TestBrowserProxy} |
| 9 */ |
| 10 var TestDownloadsBrowserProxy = function() { |
| 11 settings.TestBrowserProxy.call(this, [ |
| 12 'initializeDownloads', |
| 13 'selectDownloadLocation', |
| 14 'resetAutoOpenFileTypes', |
| 15 ]); |
| 16 }; |
| 17 |
| 18 TestDownloadsBrowserProxy.prototype = { |
| 19 __proto__: settings.TestBrowserProxy.prototype, |
| 20 |
| 21 /** @override */ |
| 22 initializeDownloads: function() { |
| 23 this.methodCalled('initializeDownloads'); |
| 24 }, |
| 25 |
| 26 /** @override */ |
| 27 selectDownloadLocation: function() { |
| 28 this.methodCalled('selectDownloadLocation'); |
| 29 }, |
| 30 |
| 31 /** @override */ |
| 32 resetAutoOpenFileTypes: function() { |
| 33 this.methodCalled('resetAutoOpenFileTypes'); |
| 34 }, |
| 35 }; |
| 36 |
| 37 var downloadsPage = null; |
| 38 |
| 39 /** @type {?TestDownloadsBrowserProxy} */ |
| 40 var DownloadsBrowserProxy = null; |
| 41 |
| 42 suite('DownloadsHandler', function() { |
| 43 setup(function() { |
| 44 DownloadsBrowserProxy = new TestDownloadsBrowserProxy(); |
| 45 settings.DownloadsBrowserProxyImpl.instance_ = DownloadsBrowserProxy; |
| 46 |
| 47 PolymerTest.clearBody(); |
| 48 |
| 49 downloadsPage = document.createElement('settings-downloads-page'); |
| 50 document.body.appendChild(downloadsPage); |
| 51 |
| 52 // Page element must call 'initializeDownloads' upon attachment to the DOM. |
| 53 return DownloadsBrowserProxy.whenCalled('initializeDownloads'); |
| 54 }); |
| 55 |
| 56 teardown(function() { |
| 57 downloadsPage.remove(); |
| 58 }); |
| 59 |
| 60 test('select downloads location', function() { |
| 61 var button = downloadsPage.$$('#changeDownloadsPath'); |
| 62 assertTrue(!!button); |
| 63 MockInteractions.tap(button); |
| 64 return DownloadsBrowserProxy.whenCalled('selectDownloadLocation'); |
| 65 }); |
| 66 |
| 67 test('openAdvancedDownloadsettings', function() { |
| 68 var button = downloadsPage.$$('#resetAutoOpenFileTypes'); |
| 69 assertTrue(!button); |
| 70 |
| 71 cr.webUIListenerCallback('auto-open-downloads-changed', true); |
| 72 Polymer.dom.flush(); |
| 73 var button = downloadsPage.$$('#resetAutoOpenFileTypes'); |
| 74 assertTrue(!!button); |
| 75 |
| 76 MockInteractions.tap(button); |
| 77 return DownloadsBrowserProxy.whenCalled('resetAutoOpenFileTypes') |
| 78 .then(function() { |
| 79 cr.webUIListenerCallback('auto-open-downloads-changed', false); |
| 80 Polymer.dom.flush(); |
| 81 var button = downloadsPage.$$('#resetAutoOpenFileTypes'); |
| 82 assertTrue(!button); |
| 83 }); |
| 84 }); |
| 85 }); |
| OLD | NEW |