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

Unified Diff: chrome/test/data/webui/md_history/history_grouped_list_test.js

Issue 2207323002: [MD History] Factor out a common HistoryListBehavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.cc ('k') | chrome/test/data/webui/md_history/history_item_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/md_history/history_grouped_list_test.js
diff --git a/chrome/test/data/webui/md_history/history_grouped_list_test.js b/chrome/test/data/webui/md_history/history_grouped_list_test.js
index 1b990afafa0f8e05f7f86ee11b2af55edaee26c1..931f42729b826111127f01a410078569427f691f 100644
--- a/chrome/test/data/webui/md_history/history_grouped_list_test.js
+++ b/chrome/test/data/webui/md_history/history_grouped_list_test.js
@@ -9,14 +9,17 @@ cr.define('md_history.history_grouped_list_test', function() {
var toolbar;
var groupedList;
var sidebar;
+ var listContainer;
var SIMPLE_RESULTS;
var PER_DAY_RESULTS;
var PER_MONTH_RESULTS;
+
suiteSetup(function() {
app = $('history-app');
app.grouped_ = true;
+ listContainer = app.$['history'];
toolbar = app.$['toolbar'];
sidebar = app.$['content-side-bar'];
@@ -135,20 +138,121 @@ cr.define('md_history.history_grouped_list_test', function() {
test('items rendered when expanded', function() {
app.set('queryState_.range', HistoryRange.WEEK);
app.historyResult(createHistoryInfo(), SIMPLE_RESULTS);
- var getItems = function() {
- return Polymer.dom(groupedList.root)
- .querySelectorAll('history-item');
- };
return flush().then(function() {
- assertEquals(0, getItems().length);
+ assertEquals(
+ 0, polymerSelectAll(groupedList, 'history-item').length);
MockInteractions.tap(groupedList.$$('.domain-heading'));
return flush();
}).then(function() {
- assertEquals(2, getItems().length);
+ assertEquals(
+ 2, polymerSelectAll(groupedList, 'history-item').length);
});
});
+ test('items deletion in week view', function(done) {
+ var results = [
+ createHistoryEntry('2016-03-13', 'https://en.wikipedia.org/a'),
+ createHistoryEntry('2016-03-13', 'https://en.wikipedia.org/b'),
+ createHistoryEntry('2016-03-13', 'https://en.wikipedia.org/c'),
+ createHistoryEntry('2016-03-13', 'https://en.wikipedia.org/d'),
+ createHistoryEntry('2016-03-13', 'https://www.youtube.com/a'),
+ createHistoryEntry('2016-03-13', 'https://www.youtube.com/b'),
+ createHistoryEntry('2016-03-11', 'https://en.wikipedia.org'),
+ createHistoryEntry('2016-03-10', 'https://www.youtube.com')
+ ];
+ app.set('queryState_.range', HistoryRange.WEEK);
+ app.historyResult(createHistoryInfo(), results);
+
+ waitForEvent(groupedList, 'dom-change', function() {
+ return polymerSelectAll(
+ groupedList, '.dropdown-indicator').length == 4;
+ }).then(function() {
+ polymerSelectAll(groupedList, '.dropdown-indicator').
+ forEach(MockInteractions.tap);
+
+ return flush();
+ }).then(function() {
+ var items = polymerSelectAll(groupedList, 'history-item');
+
+ MockInteractions.tap(items[0].$.checkbox);
+ MockInteractions.tap(items[2].$.checkbox);
+ MockInteractions.tap(items[4].$.checkbox);
+ MockInteractions.tap(items[5].$.checkbox);
+ MockInteractions.tap(items[6].$.checkbox);
+ MockInteractions.tap(items[7].$.checkbox);
+
+ // Select and deselect item 1.
+ MockInteractions.tap(items[1].$.checkbox);
+ MockInteractions.tap(items[1].$.checkbox);
+
+ registerMessageCallback('removeVisits', this, function() {
+ flush().then(function() {
+ deleteComplete();
+ return waitForEvent(groupedList, 'dom-change', function() {
+ return polymerSelectAll(
+ groupedList, '.dropdown-indicator').length == 1;
+ });
+ }).then(function() {
+ items = polymerSelectAll(groupedList, 'history-item');
+ assertEquals(2, items.length);
+ assertEquals('https://en.wikipedia.org/b', items[0].item.title);
+ assertEquals('https://en.wikipedia.org/d', items[1].item.title);
+ assertEquals(
+ 1, polymerSelectAll(groupedList, '.domain-heading')
+ .length);
+
+ assertEquals(
+ 1, polymerSelectAll(groupedList,
+ '.group-container').length);
+
+ assertFalse(listContainer.$.dialog.open);
+ done();
+ });
+ });
+
+ MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
+
+ // Confirmation dialog should appear.
+ assertTrue(listContainer.$.dialog.open);
+
+ MockInteractions.tap(listContainer.$$('.action-button'));
+ });
+ });
+
+ test('build removal tree', function() {
+ var paths = [
+ 'a.0.b.1',
+ 'a.0.b.3',
+ 'a.2.b.3',
+ ];
+
+ var expected = {
+ currentPath: 'a',
+ leaf: false,
+ indexes: [0, 2],
+ children: [
+ {
+ currentPath: 'a.0.b',
+ leaf: true,
+ indexes: [1, 3],
+ children: [],
+ },
+ null,
+ {
+ currentPath: 'a.2.b',
+ leaf: true,
+ indexes: [3],
+ children: [],
+ },
+ ],
+ };
+
+ assertEquals(
+ JSON.stringify(expected),
+ JSON.stringify(groupedList.buildRemovalTree_(paths)));
+ });
+
teardown(function() {
app.set('queryState_.results', []);
app.set('queryState_.searchedTerm', '');
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.cc ('k') | chrome/test/data/webui/md_history/history_item_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698