Chromium Code Reviews| Index: chrome/test/data/webui/md_history/history_routing_test.js |
| diff --git a/chrome/test/data/webui/md_history/history_routing_test.js b/chrome/test/data/webui/md_history/history_routing_test.js |
| index e8aa984451d5bdb2515d84a25b6b72e2c673e86f..5260aa37d4916d0e4b0f147c10eaba532860bd4e 100644 |
| --- a/chrome/test/data/webui/md_history/history_routing_test.js |
| +++ b/chrome/test/data/webui/md_history/history_routing_test.js |
| @@ -7,10 +7,12 @@ cr.define('md_history.history_routing_test', function() { |
| suite('routing-test', function() { |
| var app; |
| var list; |
| + var toolbar; |
| suiteSetup(function() { |
| app = $('history-app'); |
| sidebar = app.$['side-bar'] |
| + toolbar = app.$['toolbar']; |
| }); |
| test('changing route changes active view', function() { |
| @@ -36,8 +38,82 @@ cr.define('md_history.history_routing_test', function() { |
| assertEquals('chrome://history/', window.location.href); |
| }); |
| + test('route updates from search', function() { |
| + var searchTerm = 'McCree'; |
| + assertEquals('', app.routeData_.page); |
| + toolbar.setSearchTerm(searchTerm); |
| + assertEquals(searchTerm, app.queryParams_.q); |
| + }); |
| + |
| + test('search updates from route', function() { |
| + var searchTerm = 'Mei'; |
| + assertEquals('history', app.$.content.selected); |
| + app.set('queryParams_.q', searchTerm); |
| + assertEquals(searchTerm, toolbar.searchTerm); |
| + }); |
| + |
| + test('search preserved across menu items', function() { |
| + var searchTerm = 'Soldier 76'; |
| + var menu = sidebar.$.menu; |
| + assertEquals('', app.routeData_.page); |
| + assertEquals('history', app.$.content.selected); |
| + app.set('queryParams_.q', searchTerm); |
| + |
| + MockInteractions.tap(menu.children[1]); |
| + assertEquals('syncedTabs', app.routeData_.page); |
| + assertEquals(searchTerm, app.queryParams_.q); |
| + assertEquals(searchTerm, toolbar.searchTerm); |
| + |
| + MockInteractions.tap(menu.children[0]); |
| + assertEquals('', app.routeData_.page); |
| + assertEquals(searchTerm, app.queryParams_.q); |
| + assertEquals(searchTerm, toolbar.searchTerm); |
| + }); |
| + |
| teardown(function() { |
| app.set('routeData_.page', ''); |
| + app.set('queryParams_.q', null); |
| + }); |
| + }); |
| + } |
| + return { |
| + registerTests: registerTests |
| + }; |
| +}); |
| + |
| +cr.define('md_history.history_routing_test_with_query_param', function() { |
| + function registerTests() { |
| + suite('routing-with-query-param', function() { |
| + var app; |
| + var list; |
| + var toolbar; |
| + var expectedQuery; |
| + |
| + suiteSetup(function() { |
| + app = $('history-app'); |
| + sidebar = app.$['side-bar'] |
| + toolbar = app.$['toolbar']; |
| + expectedQuery = 'query'; |
| + }); |
| + |
| + test('search initiated on load', function(done) { |
| + var verifyFunction = function(info) { |
| + console.log(info[0]); |
|
tsergeant
2016/07/19 03:32:20
Delete this log
calamity
2016/07/19 04:35:33
Done.
|
| + assertEquals(expectedQuery, info[0]); |
| + flush().then(function() { |
| + assertEquals( |
| + expectedQuery, |
| + toolbar.$['main-toolbar'].getSearchField().getValue()); |
| + done(); |
| + }); |
| + }; |
| + |
| + if (window.historyQueryInfo) { |
| + verifyFunction(window.historyQueryInfo); |
| + return; |
| + } |
| + |
| + registerMessageCallback('historyQueried', this, verifyFunction); |
| }); |
| }); |
| } |