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

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

Issue 2627263002: MD History: Remove unnecessary namespacing from tests (part 2) (Closed)
Patch Set: Created 3 years, 11 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_toolbar_test', function() { 5 suite('history-toolbar', function() {
6 function registerTests() { 6 var app;
7 suite('history-toolbar', function() { 7 var element;
8 var app; 8 var toolbar;
9 var element; 9 var TEST_HISTORY_RESULTS;
10 var toolbar;
11 var TEST_HISTORY_RESULTS;
12 10
13 suiteSetup(function() { 11 suiteSetup(function() {
14 TEST_HISTORY_RESULTS = 12 TEST_HISTORY_RESULTS =
15 [createHistoryEntry('2016-03-15', 'https://google.com')]; 13 [createHistoryEntry('2016-03-15', 'https://google.com')];
16 }); 14 });
17 15
18 setup(function() { 16 setup(function() {
19 app = replaceApp(); 17 app = replaceApp();
20 element = app.$['history'].$['infinite-list']; 18 element = app.$['history'].$['infinite-list'];
21 toolbar = app.$['toolbar']; 19 toolbar = app.$['toolbar'];
22 return PolymerTest.flushTasks(); 20 return PolymerTest.flushTasks();
23 }); 21 });
24 22
25 test('selecting checkbox causes toolbar to change', function() { 23 test('selecting checkbox causes toolbar to change', function() {
26 element.addNewResults(TEST_HISTORY_RESULTS); 24 element.addNewResults(TEST_HISTORY_RESULTS);
27 25
28 return PolymerTest.flushTasks().then(function() { 26 return PolymerTest.flushTasks().then(function() {
29 var item = element.$$('history-item'); 27 var item = element.$$('history-item');
30 MockInteractions.tap(item.$.checkbox); 28 MockInteractions.tap(item.$.checkbox);
31 29
32 // Ensure that when an item is selected that the count held by the 30 // Ensure that when an item is selected that the count held by the
33 // toolbar increases. 31 // toolbar increases.
34 assertEquals(1, toolbar.count); 32 assertEquals(1, toolbar.count);
35 // Ensure that the toolbar boolean states that at least one item is 33 // Ensure that the toolbar boolean states that at least one item is
36 // selected. 34 // selected.
37 assertTrue(toolbar.itemsSelected_); 35 assertTrue(toolbar.itemsSelected_);
38 36
39 MockInteractions.tap(item.$.checkbox); 37 MockInteractions.tap(item.$.checkbox);
40 38
41 // Ensure that when an item is deselected the count held by the 39 // Ensure that when an item is deselected the count held by the
42 // toolbar decreases. 40 // toolbar decreases.
43 assertEquals(0, toolbar.count); 41 assertEquals(0, toolbar.count);
44 // Ensure that the toolbar boolean states that no items are selected. 42 // Ensure that the toolbar boolean states that no items are selected.
45 assertFalse(toolbar.itemsSelected_); 43 assertFalse(toolbar.itemsSelected_);
46 }); 44 });
47 }); 45 });
48 46
49 test('search term gathered correctly from toolbar', function(done) { 47 test('search term gathered correctly from toolbar', function(done) {
50 app.queryState_.queryingDisabled = false; 48 app.queryState_.queryingDisabled = false;
51 registerMessageCallback('queryHistory', this, function (info) { 49 registerMessageCallback('queryHistory', this, function(info) {
52 assertEquals('Test', info[0]); 50 assertEquals('Test', info[0]);
53 app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS); 51 app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
54 done(); 52 done();
55 }); 53 });
56 54
57 toolbar.$$('cr-toolbar').fire('search-changed', 'Test'); 55 toolbar.$$('cr-toolbar').fire('search-changed', 'Test');
58 }); 56 });
59 57
60 test('spinner is active on search' , function(done) { 58 test('spinner is active on search' , function(done) {
61 app.queryState_.queryingDisabled = false; 59 app.queryState_.queryingDisabled = false;
62 registerMessageCallback('queryHistory', this, function (info) { 60 registerMessageCallback('queryHistory', this, function(info) {
63 PolymerTest.flushTasks().then(function() { 61 PolymerTest.flushTasks().then(function() {
64 assertTrue(toolbar.spinnerActive); 62 assertTrue(toolbar.spinnerActive);
65 app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS); 63 app.historyResult(createHistoryInfo(), TEST_HISTORY_RESULTS);
66 assertFalse(toolbar.spinnerActive); 64 assertFalse(toolbar.spinnerActive);
67 done(); 65 done();
68 });
69 });
70
71 toolbar.$$('cr-toolbar').fire('search-changed', 'Test2');
72 });
73
74 test('grouped history navigation buttons', function() {
75 var info = createHistoryInfo();
76 info.finished = false;
77 app.historyResult(info, []);
78 app.grouped_ = true;
79 return PolymerTest.flushTasks().then(function() {
80 app.set('queryState_.range', HistoryRange.MONTH);
81 groupedList = app.$.history.$$('#grouped-list');
82 assertTrue(!!groupedList);
83 var today = toolbar.$$('#today-button');
84 var next = toolbar.$$('#next-button');
85 var prev = toolbar.$$('#prev-button');
86
87 assertEquals(0, toolbar.groupedOffset);
88 assertTrue(today.disabled);
89 assertTrue(next.disabled);
90 assertFalse(prev.disabled);
91
92 MockInteractions.tap(prev);
93 assertEquals(1, toolbar.groupedOffset);
94 assertFalse(today.disabled);
95 assertFalse(next.disabled);
96 assertFalse(prev.disabled);
97
98 app.historyResult(createHistoryInfo(), []);
99 assertFalse(today.disabled);
100 assertFalse(next.disabled);
101 assertTrue(prev.disabled);
102 });
103 });
104
105 teardown(function() {
106 registerMessageCallback('queryHistory', this, function() {});
107 }); 66 });
108 }); 67 });
109 } 68
110 return { 69 toolbar.$$('cr-toolbar').fire('search-changed', 'Test2');
111 registerTests: registerTests 70 });
112 }; 71
72 test('grouped history navigation buttons', function() {
73 var info = createHistoryInfo();
74 info.finished = false;
75 app.historyResult(info, []);
76 app.grouped_ = true;
77 return PolymerTest.flushTasks().then(function() {
78 app.set('queryState_.range', HistoryRange.MONTH);
79 groupedList = app.$.history.$$('#grouped-list');
80 assertTrue(!!groupedList);
81 var today = toolbar.$$('#today-button');
82 var next = toolbar.$$('#next-button');
83 var prev = toolbar.$$('#prev-button');
84
85 assertEquals(0, toolbar.groupedOffset);
86 assertTrue(today.disabled);
87 assertTrue(next.disabled);
88 assertFalse(prev.disabled);
89
90 MockInteractions.tap(prev);
91 assertEquals(1, toolbar.groupedOffset);
92 assertFalse(today.disabled);
93 assertFalse(next.disabled);
94 assertFalse(prev.disabled);
95
96 app.historyResult(createHistoryInfo(), []);
97 assertFalse(today.disabled);
98 assertFalse(next.disabled);
99 assertTrue(prev.disabled);
100 });
101 });
102
103 teardown(function() {
104 registerMessageCallback('queryHistory', this, function() {});
105 });
113 }); 106 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698