Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9539)

Unified Diff: chrome/test/data/webui/settings/zoom_levels_tests.js

Issue 2323693002: Site Settings Desktop: Implement Zoom Levels category. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/settings/zoom_levels_tests.js
diff --git a/chrome/test/data/webui/settings/zoom_levels_tests.js b/chrome/test/data/webui/settings/zoom_levels_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..ced8d5e6b922ff068db37cc0cecf8188677b721a
--- /dev/null
+++ b/chrome/test/data/webui/settings/zoom_levels_tests.js
@@ -0,0 +1,105 @@
+// Copyright 2015 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.
+
+/** @fileoverview Suite of tests for zoom-levels. */
+cr.define('zoom_levels', function() {
+ function registerTests() {
+ suite('ZoomLevels', function() {
+ /**
+ * A zoom levels category created before each test.
+ * @type {ZoomLevels}
+ */
+ var testElement;
+
+ /**
+ * The mock proxy object to use during test.
+ * @type {TestSiteSettingsPrefsBrowserProxy}
+ */
+ var browserProxy = null;
+
+ /**
+ * An example zoom list.
+ * @type {!Array<ZoomLevelEntry>}
+ */
+ var zoomList = [
+ {
+ origin: 'http://www.google.com',
+ setting: '',
+ source: '',
+ zoom: '125%',
+ },
+ {
+ origin: 'http://www.chromium.org',
+ setting: '',
+ source: '',
+ zoom: '125%',
+ },
+ ];
+
+ // Import necessary html before running suite.
+ suiteSetup(function() {
+ return PolymerTest.importHtml(
+ 'chrome://md-settings/site_settings/zoom_levels.html');
+ });
+
+ setup(function() {
+ browserProxy = new TestSiteSettingsPrefsBrowserProxy();
+ settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy;
+ return initPage();
+ });
+
+ teardown(function() {
+ testElement.remove();
+ testElement = null;
+ });
+
+ /** @return {!Promise} */
+ function initPage() {
+ browserProxy.reset();
+ PolymerTest.clearBody();
+ testElement = document.createElement('zoom-levels');
+ document.body.appendChild(testElement);
+ return browserProxy.whenCalled('fetchZoomLevels');
+ }
+
+ /**
+ * Fetch the remove button from the list.
+ * @param {!HTMLElement} listContainer The list to use for the lookup.
+ * @param {number} index The index of the child element (which site) to
+ * fetch.
+ */
+ function getRemoveButton(listContainer, index) {
+ return listContainer.children[index].querySelector('paper-icon-button');
+ }
+
+ test('empty zoom state', function() {
+ var list = testElement.$.list;
+ assertTrue(!!list);
+ assertEquals(0, list.items.length);
+ });
+
+ test('non-empty zoom state', function() {
+ browserProxy.setZoomList(zoomList);
+
+ return initPage().then(function() {
+ var list = testElement.$.list;
+ assertTrue(!!list);
+ assertEquals(2, list.items.length);
+
+ var removeButton =
+ getRemoveButton(testElement.$.listContainer, 0);
+ assert(!!removeButton);
+ MockInteractions.tap(removeButton);
+ return browserProxy.whenCalled('removeZoomLevel');
+ }).then(function(arguments) {
+ assertEquals("http://www.google.com", arguments[0]);
+ });
+ });
+ });
+ }
+
+ return {
+ registerTests: registerTests,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698