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

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

Issue 1586373002: MD History: Delete button in the toolbar allows deletion of multiple history-items. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_to_be_uploaded
Patch Set: Address reviewer comments. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_history/history_card_manager_test.js
diff --git a/chrome/test/data/webui/md_history/history_card_manager_test.js b/chrome/test/data/webui/md_history/history_card_manager_test.js
index 007c7252e01b5f568981b4da17552b1276a78524..936029ee80587a2e6ba3ce3a55619ace93f74ad9 100644
--- a/chrome/test/data/webui/md_history/history_card_manager_test.js
+++ b/chrome/test/data/webui/md_history/history_card_manager_test.js
@@ -7,19 +7,23 @@ cr.define('md_history.history_card_manager_test', function() {
var TEST_HISTORY_RESULTS = [
{
"dateRelativeDay": "Today - Wednesday, December 9, 2015",
- "url": "https://www.google.com"
+ "url": "https://www.google.com",
+ "allTimestamps": "1",
},
{
"dateRelativeDay": "Yesterday - Tuesday, December 8, 2015",
- "url": "https://en.wikipedia.com"
+ "url": "https://en.wikipedia.com",
+ "allTimestamps": "2"
},
{
"dateRelativeDay": "Monday, December 7, 2015",
- "url": "https://www.example.com"
+ "url": "https://www.example.com",
+ "allTimestamps": "3"
},
{
"dateRelativeDay": "Monday, December 7, 2015",
- "url": "https://www.google.com"
+ "url": "https://www.google.com",
+ "allTimestamps": "4"
}
];
@@ -45,9 +49,11 @@ cr.define('md_history.history_card_manager_test', function() {
function registerTests() {
suite('history-card-manager', function() {
var element;
+ var toolbar;
suiteSetup(function() {
element = $('history-card-manager');
+ toolbar = $('toolbar');
});
test('splitting items by day', function() {
@@ -69,7 +75,6 @@ cr.define('md_history.history_card_manager_test', function() {
test('cancelling selection of multiple items', function() {
element.addNewResults(TEST_HISTORY_RESULTS);
- var toolbar = $('toolbar');
flush(function() {
var cards = Polymer.dom(element.root)
@@ -126,12 +131,73 @@ cr.define('md_history.history_card_manager_test', function() {
element.historyDataByDay_[4].historyItems[0].url);
});
+ test('removeVisits for multiple items', function(done) {
+ element.addNewResults(TEST_HISTORY_RESULTS);
+ var items;
+
+ // Ensure that the correct identifying data is being used for removal.
+ registerMessageCallback('removeVisits', this, function (toBeRemoved) {
+ assertEquals(toBeRemoved[0].url,
+ element.historyDataByDay_[2].historyItems[0].url);
+ assertEquals(toBeRemoved[1].url,
+ element.historyDataByDay_[2].historyItems[1].url);
+ assertEquals(toBeRemoved[0].timestamps,
+ element.historyDataByDay_[2].historyItems[0]
+ .allTimestamps);
+ assertEquals(toBeRemoved[1].timestamps,
+ element.historyDataByDay_[2].historyItems[1]
+ .allTimestamps);
+ // Reset state of history-items for next test.
+ MockInteractions.tap(items[0].$['checkbox']);
+ MockInteractions.tap(items[1].$['checkbox']);
tsergeant 2016/01/25 01:43:15 You can make a teardown() function which resets th
hsampson 2016/01/25 04:15:42 Done.
+ done();
+ });
+
+ flush(function() {
+ var cards = Polymer.dom(element.root)
+ .querySelectorAll('history-card');
+ items = Polymer.dom(cards[2].root)
+ .querySelectorAll('history-item');
+
+ MockInteractions.tap(items[0].$['checkbox']);
+ MockInteractions.tap(items[1].$['checkbox']);
+
+ toolbar.deleteSelection();
+ });
+ });
+
+ test('deleting multiple items from view', function(done) {
+ element.addNewResults(TEST_HISTORY_RESULTS);
+
+ flush(function() {
+ var cards = Polymer.dom(element.root)
+ .querySelectorAll('history-card');
+ var items = Polymer.dom(cards[2].root)
+ .querySelectorAll('history-item');
+
+ MockInteractions.tap(items[0].$['checkbox']);
+ MockInteractions.tap(items[1].$['checkbox']);
+
+ element.removeDeletedHistory(2);
+
+ flush(function() {
+ assertEquals(element.historyDataByDay_.length, 2);
+ assertEquals(element.historyDataByDay_[0].date,
+ "Today - Wednesday, December 9, 2015");
+ assertEquals(element.historyDataByDay_[1].date,
+ "Yesterday - Tuesday, December 8, 2015");
+ done();
+ });
+ });
+ });
+
teardown(function() {
element.historyDataByDay_ = [];
+ toolbar.count = 0;
});
});
}
return {
registerTests: registerTests
};
-});
+});

Powered by Google App Engine
This is Rietveld 408576698