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

Side by Side Diff: chrome/test/data/webui/md_history/history_routing_test.js

Issue 2068613002: [MD History] Add URL parameter for search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@routing
Patch Set: remove_var 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 unified diff | Download patch
OLDNEW
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('md_history.history_routing_test', function() { 5 cr.define('md_history.history_routing_test', function() {
6 function registerTests() { 6 function registerTests() {
7 suite('routing-test', function() { 7 suite('routing-test', function() {
8 var app; 8 var app;
9 var list; 9 var list;
10 var toolbar;
10 11
11 suiteSetup(function() { 12 suiteSetup(function() {
12 app = $('history-app'); 13 app = $('history-app');
13 sidebar = app.$['side-bar'] 14 sidebar = app.$['side-bar']
15 toolbar = app.$['toolbar'];
14 }); 16 });
15 17
16 test('changing route changes active view', function() { 18 test('changing route changes active view', function() {
17 assertEquals('history', app.$.content.selected); 19 assertEquals('history', app.$.content.selected);
18 app.set('routeData_.page', 'syncedTabs'); 20 app.set('routeData_.page', 'syncedTabs');
19 return flush().then(function() { 21 return flush().then(function() {
20 assertEquals('syncedTabs', app.$.content.selected); 22 assertEquals('syncedTabs', app.$.content.selected);
21 assertEquals('chrome://history/syncedTabs', window.location.href); 23 assertEquals('chrome://history/syncedTabs', window.location.href);
22 }); 24 });
23 }); 25 });
24 26
25 test('route updates from sidebar', function() { 27 test('route updates from sidebar', function() {
26 var menu = sidebar.$.menu; 28 var menu = sidebar.$.menu;
27 assertEquals('', app.routeData_.page); 29 assertEquals('', app.routeData_.page);
28 assertEquals('chrome://history/', window.location.href); 30 assertEquals('chrome://history/', window.location.href);
29 31
30 MockInteractions.tap(menu.children[1]); 32 MockInteractions.tap(menu.children[1]);
31 assertEquals('syncedTabs', app.routeData_.page); 33 assertEquals('syncedTabs', app.routeData_.page);
32 assertEquals('chrome://history/syncedTabs', window.location.href); 34 assertEquals('chrome://history/syncedTabs', window.location.href);
33 35
34 MockInteractions.tap(menu.children[0]); 36 MockInteractions.tap(menu.children[0]);
35 assertEquals('', app.routeData_.page); 37 assertEquals('', app.routeData_.page);
36 assertEquals('chrome://history/', window.location.href); 38 assertEquals('chrome://history/', window.location.href);
37 }); 39 });
38 40
41 test('route updates from search', function() {
42 var searchTerm = 'McCree';
43 assertEquals('', app.routeData_.page);
44 toolbar.setSearchTerm(searchTerm);
45 assertEquals(searchTerm, app.queryParams_.q);
46 });
47
48 test('search updates from route', function() {
49 var searchTerm = 'Mei';
50 assertEquals('history', app.$.content.selected);
51 app.set('queryParams_.q', searchTerm);
52 assertEquals(searchTerm, toolbar.searchTerm);
53 });
54
55 test('search preserved across menu items', function() {
56 var searchTerm = 'Soldier 76';
57 var menu = sidebar.$.menu;
58 assertEquals('', app.routeData_.page);
59 assertEquals('history', app.$.content.selected);
60 app.set('queryParams_.q', searchTerm);
61
62 MockInteractions.tap(menu.children[1]);
63 assertEquals('syncedTabs', app.routeData_.page);
64 assertEquals(searchTerm, app.queryParams_.q);
65 assertEquals(searchTerm, toolbar.searchTerm);
66
67 MockInteractions.tap(menu.children[0]);
68 assertEquals('', app.routeData_.page);
69 assertEquals(searchTerm, app.queryParams_.q);
70 assertEquals(searchTerm, toolbar.searchTerm);
71 });
72
39 teardown(function() { 73 teardown(function() {
40 app.set('routeData_.page', ''); 74 app.set('routeData_.page', '');
75 app.set('queryParams_.q', null);
41 }); 76 });
42 }); 77 });
43 } 78 }
79 return {
80 registerTests: registerTests
81 };
82 });
83
84 cr.define('md_history.history_routing_test_with_query_param', function() {
85 function registerTests() {
86 suite('routing-with-query-param', function() {
87 var app;
88 var list;
89 var toolbar;
90 var expectedQuery;
91
92 suiteSetup(function() {
93 app = $('history-app');
94 sidebar = app.$['side-bar']
95 toolbar = app.$['toolbar'];
96 expectedQuery = 'query';
97 });
98
99 test('search initiated on load', function(done) {
100 var verifyFunction = function(info) {
101 assertEquals(expectedQuery, info[0]);
102 flush().then(function() {
103 assertEquals(
104 expectedQuery,
105 toolbar.$['main-toolbar'].getSearchField().getValue());
106 done();
107 });
108 };
109
110 if (window.historyQueryInfo) {
111 verifyFunction(window.historyQueryInfo);
112 return;
113 }
114
115 registerMessageCallback('queryHistory', this, verifyFunction);
116 });
117 });
118 }
44 return { 119 return {
45 registerTests: registerTests 120 registerTests: registerTests
46 }; 121 };
47 }); 122 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_history/history_list_test.js ('k') | chrome/test/data/webui/md_history/history_synced_tabs_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698