| 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; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 assertEquals(searchTerm, toolbar.searchTerm); | 73 assertEquals(searchTerm, toolbar.searchTerm); |
| 74 assertEquals( | 74 assertEquals( |
| 75 'chrome://history/syncedTabs?q=' + searchTerm, | 75 'chrome://history/syncedTabs?q=' + searchTerm, |
| 76 window.location.href); | 76 window.location.href); |
| 77 | 77 |
| 78 MockInteractions.tap(menu.children[0]); | 78 MockInteractions.tap(menu.children[0]); |
| 79 assertEquals('history', app.selectedPage_); | 79 assertEquals('history', app.selectedPage_); |
| 80 assertEquals(searchTerm, toolbar.searchTerm); | 80 assertEquals(searchTerm, toolbar.searchTerm); |
| 81 assertEquals('chrome://history/?q=' + searchTerm, window.location.href); | 81 assertEquals('chrome://history/?q=' + searchTerm, window.location.href); |
| 82 }); | 82 }); |
| 83 | |
| 84 test('changing route changes grouped range and offset', function() { | |
| 85 app.grouped_ = true; | |
| 86 navigateTo('/history/week?offset=1'); | |
| 87 assertEquals(HistoryRange.WEEK, app.queryState_.range); | |
| 88 assertEquals(1, app.queryState_.groupedOffset); | |
| 89 | |
| 90 navigateTo('/history/month'); | |
| 91 assertEquals(HistoryRange.MONTH, app.queryState_.range); | |
| 92 assertEquals(0, app.queryState_.groupedOffset); | |
| 93 | |
| 94 navigateTo('/'); | |
| 95 assertEquals(HistoryRange.ALL_TIME, app.queryState_.range); | |
| 96 }); | |
| 97 | |
| 98 test('route updates from grouped range and offset', function() { | |
| 99 app.grouped_ = true; | |
| 100 | |
| 101 app.fire('change-query', {range: HistoryRange.WEEK}); | |
| 102 assertEquals('chrome://history/history/week', window.location.href); | |
| 103 | |
| 104 app.fire('change-query', {range: HistoryRange.MONTH, offset: 5}); | |
| 105 assertEquals( | |
| 106 'chrome://history/history/month?offset=5', window.location.href); | |
| 107 | |
| 108 app.fire('change-query', {range: HistoryRange.ALL_TIME}); | |
| 109 assertEquals('chrome://history/', window.location.href); | |
| 110 }); | |
| 111 }); | 83 }); |
| 112 } | 84 } |
| 113 return { | 85 return { |
| 114 registerTests: registerTests | 86 registerTests: registerTests |
| 115 }; | 87 }; |
| 116 }); | 88 }); |
| 117 | 89 |
| 118 cr.define('md_history.history_routing_test_with_query_param', function() { | 90 cr.define('md_history.history_routing_test_with_query_param', function() { |
| 119 function registerTests() { | 91 function registerTests() { |
| 120 suite('routing-with-query-param', function() { | 92 suite('routing-with-query-param', function() { |
| 121 var app; | 93 var app; |
| 122 var toolbar; | 94 var toolbar; |
| 123 var expectedQuery; | 95 var expectedQuery; |
| 124 | 96 |
| 125 suiteSetup(function() { | 97 suiteSetup(function() { |
| 126 app = $('history-app'); | 98 app = $('history-app'); |
| 127 toolbar = app.$['toolbar']; | 99 toolbar = app.$['toolbar']; |
| 128 expectedQuery = 'query'; | 100 expectedQuery = 'query'; |
| 129 }); | 101 }); |
| 130 | 102 |
| 131 test('search initiated on load', function(done) { | 103 test('search initiated on load', function(done) { |
| 132 var verifyFunction = function(info) { | 104 var verifyFunction = function(info) { |
| 133 assertEquals(expectedQuery, info[0]); | 105 assertEquals(expectedQuery, info[0]); |
| 134 assertEquals(5, info[1]); | |
| 135 assertEquals(HistoryRange.WEEK, info[2]); | |
| 136 PolymerTest.flushTasks().then(function() { | 106 PolymerTest.flushTasks().then(function() { |
| 137 assertEquals( | 107 assertEquals( |
| 138 expectedQuery, | 108 expectedQuery, |
| 139 toolbar.$['main-toolbar'].getSearchField().getValue()); | 109 toolbar.$['main-toolbar'].getSearchField().getValue()); |
| 140 done(); | 110 done(); |
| 141 }); | 111 }); |
| 142 }; | 112 }; |
| 143 | 113 |
| 144 if (window.historyQueryInfo) { | 114 if (window.historyQueryInfo) { |
| 145 verifyFunction(window.historyQueryInfo); | 115 verifyFunction(window.historyQueryInfo); |
| 146 return; | 116 return; |
| 147 } | 117 } |
| 148 | 118 |
| 149 registerMessageCallback('queryHistory', this, verifyFunction); | 119 registerMessageCallback('queryHistory', this, verifyFunction); |
| 150 }); | 120 }); |
| 151 }); | 121 }); |
| 152 } | 122 } |
| 153 return { | 123 return { |
| 154 registerTests: registerTests | 124 registerTests: registerTests |
| 155 }; | 125 }; |
| 156 }); | 126 }); |
| OLD | NEW |