Chromium Code Reviews| Index: chrome/test/data/webui/settings/downloads_page_test.js |
| diff --git a/chrome/test/data/webui/settings/downloads_page_test.js b/chrome/test/data/webui/settings/downloads_page_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fa4608dc5389e284948161b53cbfe87262e34338 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/settings/downloads_page_test.js |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @constructor |
| + * @implements {settings.DownloadsBrowserProxy} |
| + * @extends {settings.TestBrowserProxy} |
| + */ |
| +var TestDownloadsBrowserProxy = function() { |
| + settings.TestBrowserProxy.call(this, [ |
| + 'initializeDownloads', |
| + 'selectDownloadLocation', |
| + 'resetAutoOpenFileTypes', |
| + ]); |
| +}; |
| + |
| +TestDownloadsBrowserProxy.prototype = { |
| + __proto__: settings.TestBrowserProxy.prototype, |
| + |
| + /** @override */ |
| + initializeDownloads: function() { |
| + this.methodCalled('initializeDownloads'); |
| + }, |
| + |
| + /** @override */ |
| + selectDownloadLocation: function() { |
| + this.methodCalled('selectDownloadLocation'); |
| + }, |
| + |
| + /** @override */ |
| + resetAutoOpenFileTypes: function() { |
| + this.methodCalled('resetAutoOpenFileTypes'); |
| + }, |
| +}; |
| + |
| +var DownloadsPage = null; |
|
Dan Beam
2017/02/28 02:36:42
jsVarsLikeThis (start with lower)
tommycli
2017/02/28 17:06:39
Done.
|
| + |
| +/** @type {?TestDownloadsBrowserProxy} */ |
| +var DownloadsBrowserProxy = null; |
| + |
| +suite('DownloadsHandler', function() { |
| + setup(function() { |
| + DownloadsBrowserProxy = new TestDownloadsBrowserProxy(); |
| + settings.DownloadsBrowserProxyImpl.instance_ = DownloadsBrowserProxy; |
| + |
| + PolymerTest.clearBody(); |
| + |
| + DownloadsPage = document.createElement('settings-downloads-page'); |
| + document.body.appendChild(DownloadsPage); |
| + |
| + // Page element must call 'initializeDownloads' upon attachment to the DOM. |
| + return DownloadsBrowserProxy.whenCalled('initializeDownloads'); |
| + }); |
| + |
| + teardown(function() { |
| + DownloadsPage.remove(); |
| + }); |
| + |
| + test('select downloads location', function() { |
| + var button = DownloadsPage.$$('#changeDownloadsPath'); |
| + assert(!!button); |
|
Dan Beam
2017/02/28 02:36:42
nit: assert -> assertTrue
tommycli
2017/02/28 17:06:39
Done.
|
| + MockInteractions.tap(button); |
| + return DownloadsBrowserProxy.whenCalled('selectDownloadLocation'); |
| + }); |
| + |
| + test('openAdvancedDownloadsettings', function() { |
| + var button = DownloadsPage.$$('#resetAutoOpenFileTypes'); |
| + assert(!button); |
| + |
| + cr.webUIListenerCallback('auto-open-downloads-changed', true); |
| + Polymer.dom.flush(); |
| + var button = DownloadsPage.$$('#resetAutoOpenFileTypes'); |
| + assert(!!button); |
| + |
| + MockInteractions.tap(button); |
| + return DownloadsBrowserProxy.whenCalled('resetAutoOpenFileTypes') |
| + .then(function() { |
| + cr.webUIListenerCallback('auto-open-downloads-changed', false); |
| + Polymer.dom.flush(); |
| + var button = DownloadsPage.$$('#resetAutoOpenFileTypes'); |
| + assert(!button); |
| + }); |
| + }); |
| +}); |