| Index: chrome/test/data/webui/md_history/history_toolbar_test.js
|
| diff --git a/chrome/test/data/webui/md_history/history_toolbar_test.js b/chrome/test/data/webui/md_history/history_toolbar_test.js
|
| index ecd9a77230a395c3a4bea54ea22301c096efae0f..a6f1020d2ad7738bc189825e2f3c55eb985a168b 100644
|
| --- a/chrome/test/data/webui/md_history/history_toolbar_test.js
|
| +++ b/chrome/test/data/webui/md_history/history_toolbar_test.js
|
| @@ -2,112 +2,105 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -cr.define('md_history.history_toolbar_test', function() {
|
| - function registerTests() {
|
| - suite('history-toolbar', function() {
|
| - var app;
|
| - var element;
|
| - var toolbar;
|
| - var TEST_HISTORY_RESULTS;
|
| -
|
| - suiteSetup(function() {
|
| - TEST_HISTORY_RESULTS =
|
| - [createHistoryEntry('2016-03-15', 'https://google.com')];
|
| - });
|
| -
|
| - setup(function() {
|
| - app = replaceApp();
|
| - element = app.$['history'].$['infinite-list'];
|
| - toolbar = app.$['toolbar'];
|
| - return PolymerTest.flushTasks();
|
| - });
|
| -
|
| - test('selecting checkbox causes toolbar to change', function() {
|
| - element.addNewResults(TEST_HISTORY_RESULTS);
|
| -
|
| - return PolymerTest.flushTasks().then(function() {
|
| - var item = element.$$('history-item');
|
| - MockInteractions.tap(item.$.checkbox);
|
| -
|
| - // Ensure that when an item is selected that the count held by the
|
| - // toolbar increases.
|
| - assertEquals(1, toolbar.count);
|
| - // Ensure that the toolbar boolean states that at least one item is
|
| - // selected.
|
| - assertTrue(toolbar.itemsSelected_);
|
| -
|
| - MockInteractions.tap(item.$.checkbox);
|
| -
|
| - // Ensure that when an item is deselected the count held by the
|
| - // toolbar decreases.
|
| - assertEquals(0, toolbar.count);
|
| - // Ensure that the toolbar boolean states that no items are selected.
|
| - assertFalse(toolbar.itemsSelected_);
|
| - });
|
| - });
|
| -
|
| - test('search term gathered correctly from toolbar', function(done) {
|
| - app.queryState_.queryingDisabled = false;
|
| - registerMessageCallback('queryHistory', this, function (info) {
|
| - assertEquals('Test', info[0]);
|
| - app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
|
| - done();
|
| - });
|
| -
|
| - toolbar.$$('cr-toolbar').fire('search-changed', 'Test');
|
| - });
|
| -
|
| - test('spinner is active on search' , function(done) {
|
| - app.queryState_.queryingDisabled = false;
|
| - registerMessageCallback('queryHistory', this, function (info) {
|
| - PolymerTest.flushTasks().then(function() {
|
| - assertTrue(toolbar.spinnerActive);
|
| - app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
|
| - assertFalse(toolbar.spinnerActive);
|
| - done();
|
| - });
|
| - });
|
| -
|
| - toolbar.$$('cr-toolbar').fire('search-changed', 'Test2');
|
| - });
|
| +suite('history-toolbar', function() {
|
| + var app;
|
| + var element;
|
| + var toolbar;
|
| + var TEST_HISTORY_RESULTS;
|
| +
|
| + suiteSetup(function() {
|
| + TEST_HISTORY_RESULTS =
|
| + [createHistoryEntry('2016-03-15', 'https://google.com')];
|
| + });
|
| +
|
| + setup(function() {
|
| + app = replaceApp();
|
| + element = app.$['history'].$['infinite-list'];
|
| + toolbar = app.$['toolbar'];
|
| + return PolymerTest.flushTasks();
|
| + });
|
| +
|
| + test('selecting checkbox causes toolbar to change', function() {
|
| + element.addNewResults(TEST_HISTORY_RESULTS);
|
| +
|
| + return PolymerTest.flushTasks().then(function() {
|
| + var item = element.$$('history-item');
|
| + MockInteractions.tap(item.$.checkbox);
|
| +
|
| + // Ensure that when an item is selected that the count held by the
|
| + // toolbar increases.
|
| + assertEquals(1, toolbar.count);
|
| + // Ensure that the toolbar boolean states that at least one item is
|
| + // selected.
|
| + assertTrue(toolbar.itemsSelected_);
|
| +
|
| + MockInteractions.tap(item.$.checkbox);
|
| +
|
| + // Ensure that when an item is deselected the count held by the
|
| + // toolbar decreases.
|
| + assertEquals(0, toolbar.count);
|
| + // Ensure that the toolbar boolean states that no items are selected.
|
| + assertFalse(toolbar.itemsSelected_);
|
| + });
|
| + });
|
| +
|
| + test('search term gathered correctly from toolbar', function(done) {
|
| + app.queryState_.queryingDisabled = false;
|
| + registerMessageCallback('queryHistory', this, function(info) {
|
| + assertEquals('Test', info[0]);
|
| + app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
|
| + done();
|
| + });
|
|
|
| - test('grouped history navigation buttons', function() {
|
| - var info = createHistoryInfo();
|
| - info.finished = false;
|
| - app.historyResult(info, []);
|
| - app.grouped_ = true;
|
| - return PolymerTest.flushTasks().then(function() {
|
| - app.set('queryState_.range', HistoryRange.MONTH);
|
| - groupedList = app.$.history.$$('#grouped-list');
|
| - assertTrue(!!groupedList);
|
| - var today = toolbar.$$('#today-button');
|
| - var next = toolbar.$$('#next-button');
|
| - var prev = toolbar.$$('#prev-button');
|
| -
|
| - assertEquals(0, toolbar.groupedOffset);
|
| - assertTrue(today.disabled);
|
| - assertTrue(next.disabled);
|
| - assertFalse(prev.disabled);
|
| -
|
| - MockInteractions.tap(prev);
|
| - assertEquals(1, toolbar.groupedOffset);
|
| - assertFalse(today.disabled);
|
| - assertFalse(next.disabled);
|
| - assertFalse(prev.disabled);
|
| -
|
| - app.historyResult(createHistoryInfo(), []);
|
| - assertFalse(today.disabled);
|
| - assertFalse(next.disabled);
|
| - assertTrue(prev.disabled);
|
| - });
|
| + toolbar.$$('cr-toolbar').fire('search-changed', 'Test');
|
| + });
|
| +
|
| + test('spinner is active on search' , function(done) {
|
| + app.queryState_.queryingDisabled = false;
|
| + registerMessageCallback('queryHistory', this, function(info) {
|
| + PolymerTest.flushTasks().then(function() {
|
| + assertTrue(toolbar.spinnerActive);
|
| + app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
|
| + assertFalse(toolbar.spinnerActive);
|
| + done();
|
| });
|
| + });
|
|
|
| - teardown(function() {
|
| - registerMessageCallback('queryHistory', this, function() {});
|
| - });
|
| + toolbar.$$('cr-toolbar').fire('search-changed', 'Test2');
|
| + });
|
| +
|
| + test('grouped history navigation buttons', function() {
|
| + var info = createHistoryInfo();
|
| + info.finished = false;
|
| + app.historyResult(info, []);
|
| + app.grouped_ = true;
|
| + return PolymerTest.flushTasks().then(function() {
|
| + app.set('queryState_.range', HistoryRange.MONTH);
|
| + groupedList = app.$.history.$$('#grouped-list');
|
| + assertTrue(!!groupedList);
|
| + var today = toolbar.$$('#today-button');
|
| + var next = toolbar.$$('#next-button');
|
| + var prev = toolbar.$$('#prev-button');
|
| +
|
| + assertEquals(0, toolbar.groupedOffset);
|
| + assertTrue(today.disabled);
|
| + assertTrue(next.disabled);
|
| + assertFalse(prev.disabled);
|
| +
|
| + MockInteractions.tap(prev);
|
| + assertEquals(1, toolbar.groupedOffset);
|
| + assertFalse(today.disabled);
|
| + assertFalse(next.disabled);
|
| + assertFalse(prev.disabled);
|
| +
|
| + app.historyResult(createHistoryInfo(), []);
|
| + assertFalse(today.disabled);
|
| + assertFalse(next.disabled);
|
| + assertTrue(prev.disabled);
|
| });
|
| - }
|
| - return {
|
| - registerTests: registerTests
|
| - };
|
| + });
|
| +
|
| + teardown(function() {
|
| + registerMessageCallback('queryHistory', this, function() {});
|
| + });
|
| });
|
|
|