| OLD | NEW |
| 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 var toolbar; |
| 11 | 11 |
| 12 function navigateTo(route) { | 12 function navigateTo(route) { |
| 13 window.history.replaceState({}, '', route); | 13 window.history.replaceState({}, '', route); |
| 14 window.dispatchEvent(new CustomEvent('location-changed')); | 14 window.dispatchEvent(new CustomEvent('location-changed')); |
| 15 } | 15 } |
| 16 | 16 |
| 17 setup(function() { | 17 setup(function() { |
| 18 assertEquals('chrome://history/', window.location.href); | 18 assertEquals('chrome://history/', window.location.href); |
| 19 app = replaceApp(); | 19 app = replaceApp(); |
| 20 sidebar = app.$['content-side-bar'] | 20 sidebar = app.$['content-side-bar'] |
| 21 toolbar = app.$['toolbar']; | 21 toolbar = app.$['toolbar']; |
| 22 }); | 22 }); |
| 23 | 23 |
| 24 test('changing route changes active view', function() { | 24 test('changing route changes active view', function() { |
| 25 assertEquals('history', app.$.content.selected); | 25 assertEquals('history', app.$.content.selected); |
| 26 navigateTo('/syncedTabs'); | 26 navigateTo('/syncedTabs'); |
| 27 return flush().then(function() { | 27 return PolymerTest.flushTasks().then(function() { |
| 28 assertEquals('syncedTabs', app.$.content.selected); | 28 assertEquals('syncedTabs', app.$.content.selected); |
| 29 assertEquals('chrome://history/syncedTabs', window.location.href); | 29 assertEquals('chrome://history/syncedTabs', window.location.href); |
| 30 }); | 30 }); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 test('route updates from sidebar', function() { | 33 test('route updates from sidebar', function() { |
| 34 var menu = sidebar.$.menu; | 34 var menu = sidebar.$.menu; |
| 35 assertEquals('history', app.selectedPage_); | 35 assertEquals('history', app.selectedPage_); |
| 36 assertEquals('chrome://history/', window.location.href); | 36 assertEquals('chrome://history/', window.location.href); |
| 37 | 37 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 suiteSetup(function() { | 99 suiteSetup(function() { |
| 100 app = $('history-app'); | 100 app = $('history-app'); |
| 101 toolbar = app.$['toolbar']; | 101 toolbar = app.$['toolbar']; |
| 102 expectedQuery = 'query'; | 102 expectedQuery = 'query'; |
| 103 }); | 103 }); |
| 104 | 104 |
| 105 test('search initiated on load', function(done) { | 105 test('search initiated on load', function(done) { |
| 106 var verifyFunction = function(info) { | 106 var verifyFunction = function(info) { |
| 107 assertEquals(expectedQuery, info[0]); | 107 assertEquals(expectedQuery, info[0]); |
| 108 flush().then(function() { | 108 PolymerTest.flushTasks().then(function() { |
| 109 assertEquals( | 109 assertEquals( |
| 110 expectedQuery, | 110 expectedQuery, |
| 111 toolbar.$['main-toolbar'].getSearchField().getValue()); | 111 toolbar.$['main-toolbar'].getSearchField().getValue()); |
| 112 done(); | 112 done(); |
| 113 }); | 113 }); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 if (window.historyQueryInfo) { | 116 if (window.historyQueryInfo) { |
| 117 verifyFunction(window.historyQueryInfo); | 117 verifyFunction(window.historyQueryInfo); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 | 120 |
| 121 registerMessageCallback('queryHistory', this, verifyFunction); | 121 registerMessageCallback('queryHistory', this, verifyFunction); |
| 122 }); | 122 }); |
| 123 }); | 123 }); |
| 124 } | 124 } |
| 125 return { | 125 return { |
| 126 registerTests: registerTests | 126 registerTests: registerTests |
| 127 }; | 127 }; |
| 128 }); | 128 }); |
| OLD | NEW |