| Index: chrome/test/data/webui/md_history/test_util.js
|
| diff --git a/chrome/test/data/webui/md_history/test_util.js b/chrome/test/data/webui/md_history/test_util.js
|
| index acb77f4d03142d9242589f033837ae2174594dd1..d0a3fc433140dc1161ffcea40af71e00f5ffab85 100644
|
| --- a/chrome/test/data/webui/md_history/test_util.js
|
| +++ b/chrome/test/data/webui/md_history/test_util.js
|
| @@ -10,3 +10,48 @@ function flush(callback) {
|
| Polymer.dom.flush();
|
| window.setTimeout(callback, 0);
|
| }
|
| +
|
| +/**
|
| + * Create a fake history result with the given timestamp.
|
| + * @param {number|string} timestamp Timestamp of the entry, as a number in ms or
|
| + * a string which can be parsed by Date.parse().
|
| + * @param {string} urlStr The URL to set on this entry.
|
| + * @return {!HistoryEntry} An object representing a history entry.
|
| + */
|
| +function createHistoryEntry(timestamp, urlStr) {
|
| + if (typeof timestamp === 'string')
|
| + timestamp += ' UTC';
|
| +
|
| + var d = new Date(timestamp);
|
| + var url = new URL(urlStr);
|
| + var domain = url.host;
|
| + return {
|
| + allTimestamps: [timestamp],
|
| + // Formatting the relative day is too hard, will instead display
|
| + // YYYY-MM-DD.
|
| + dateRelativeDay: d.toISOString().split('T')[0],
|
| + dateTimeOfDay: d.getUTCHours() + ':' + d.getUTCMinutes(),
|
| + domain: domain,
|
| + starred: false,
|
| + time: d.getTime(),
|
| + title: urlStr,
|
| + url: urlStr
|
| + };
|
| +}
|
| +
|
| +/**
|
| + * Create a fake history search result with the given timestamp. Replaces fields
|
| + * from createHistoryEntry to look like a search result.
|
| + * @param {number|string} timestamp Timestamp of the entry, as a number in ms or
|
| + * a string which can be parsed by Date.parse().
|
| + * @param {string} urlStr The URL to set on this entry.
|
| + * @return {!HistoryEntry} An object representing a history entry.
|
| + */
|
| +function createSearchEntry(timestamp, urlStr) {
|
| + var entry = createHistoryEntry(timestamp, urlStr);
|
| + entry.dateShort = entry.dateRelativeDay;
|
| + entry.dateTimeOfDay = '';
|
| + entry.dateRelativeDay = '';
|
| +
|
| + return entry;
|
| +}
|
|
|