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

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

Issue 2141313002: Settings Router Refactor: Implement new Route class w/ test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 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
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/route_tests.js
diff --git a/chrome/test/data/webui/settings/route_tests.js b/chrome/test/data/webui/settings/route_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..728ddfe9f94f674d388c7614c7aa120f3d791283
--- /dev/null
+++ b/chrome/test/data/webui/settings/route_tests.js
@@ -0,0 +1,49 @@
+// Copyright 2016 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.
+
+suite('route', function() {
+ test('tree structure', function() {
+ // Set up root page routes.
+ var BASIC = new settings.Route('/');
+ BASIC.page = 'basic';
+ var ADVANCED = new settings.Route('/advanced');
+ ADVANCED.page = 'advanced';
+ assertDeepEquals([], ADVANCED.subpage);
+
+ // Test a section route.
+ var PRIVACY = ADVANCED.createChild('/privacy');
+ PRIVACY.section = 'privacy';
+ assertEquals('advanced', PRIVACY.page);
+ assertDeepEquals([], PRIVACY.subpage);
+ assertFalse(PRIVACY.isDescendantOf(BASIC));
+ assertTrue(PRIVACY.isDescendantOf(ADVANCED));
+ assertFalse(PRIVACY.isDescendantOf(PRIVACY));
+ assertFalse(ADVANCED.isDescendantOf(PRIVACY));
+
+ // Test a subpage route.
+ var SITE_SETTINGS = PRIVACY.createChild('/siteSettings', 'site-settings');
+ assertFalse(SITE_SETTINGS.dialog);
+ assertDeepEquals(['site-settings'], SITE_SETTINGS.subpage);
+ assertEquals('advanced', SITE_SETTINGS.page);
+ assertEquals('privacy', SITE_SETTINGS.section);
+ assertFalse(SITE_SETTINGS.isDescendantOf(BASIC));
+ assertTrue(SITE_SETTINGS.isDescendantOf(ADVANCED));
+ assertTrue(SITE_SETTINGS.isDescendantOf(PRIVACY));
+
+ // Test a sub-subpage route.
+ var SITE_SETTINGS_ALL =
+ SITE_SETTINGS.createChild('/siteSettings/all', 'all-sites');
+ assertDeepEquals(['site-settings', 'all-sites'], SITE_SETTINGS_ALL.subpage);
+
+ // Test a dialog route.
+ var CLEAR_BROWSING_DATA = PRIVACY.createDialog('/clearBrowsingData');
+ assertTrue(CLEAR_BROWSING_DATA.dialog);
+ assertEquals('privacy', CLEAR_BROWSING_DATA.section);
+ assertEquals('advanced', CLEAR_BROWSING_DATA.page);
+ assertEquals('privacy', CLEAR_BROWSING_DATA.section);
+ assertFalse(CLEAR_BROWSING_DATA.isDescendantOf(BASIC));
+ assertTrue(CLEAR_BROWSING_DATA.isDescendantOf(ADVANCED));
+ assertTrue(CLEAR_BROWSING_DATA.isDescendantOf(PRIVACY));
+ });
+});
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698