1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // History api test for Chrome.
6 // browser_tests.exe --gtest_filter=HistoryExtensionApiTest.MostVisited
8 var GOOGLE_ENTRY = {'url' : GOOGLE_URL, 'title' : 'Google'};
9 var PICASA_ENTRY = {'url' : PICASA_URL, 'title' : 'Picasa'};
10 var HALF_HOUR_MILLISECONDS = 30 * 60 * 1000;
11 var ONE_HOUR_MILLISECONDS = 60 * 60 * 1000;
13 function getVerificationFunction(expected) {
14 return function(results) {
15 chrome.test.assertEq(expected, results);
16 chrome.test.succeed();
20 // runHistoryTestFns is defined in ./common.js .
22 function mostVisitedTimeRange1() {
23 chrome.experimental.history.getMostVisited({
24 'filterTime': Date.parse('24 Apr 2012, 13:00:00'),
25 'filterWidth': HALF_HOUR_MILLISECONDS,
26 }, getVerificationFunction([GOOGLE_ENTRY]));
28 function mostVisitedTimeRange2() {
29 chrome.experimental.history.getMostVisited({
30 'filterTime': Date.parse('24 Apr 2012, 14:00:00'),
31 'filterWidth': HALF_HOUR_MILLISECONDS,
32 }, getVerificationFunction([PICASA_ENTRY]));
34 function mostVisitedTimeRange3() {
35 chrome.experimental.history.getMostVisited({
36 'filterTime': Date.parse('24 Apr 2012, 12:00:00'),
37 'filterWidth': HALF_HOUR_MILLISECONDS,
38 }, getVerificationFunction([]));
40 function mostVisitedTimeRange4() {
41 chrome.experimental.history.getMostVisited({
42 'filterTime': Date.parse('24 Apr 2012, 15:00:00'),
43 'filterWidth': HALF_HOUR_MILLISECONDS,
44 }, getVerificationFunction([]));
46 function mostVisitedTimeRange5() {
47 chrome.experimental.history.getMostVisited({
48 'filterTime': Date.parse('24 Apr 2012, 13:30:00'),
49 'filterWidth': ONE_HOUR_MILLISECONDS,
50 }, getVerificationFunction([PICASA_ENTRY, GOOGLE_ENTRY]));
52 function mostVisitedMaxResults() {
53 chrome.experimental.history.getMostVisited({
54 'filterTime': Date.parse('24 Apr 2012, 13:30:00'),
55 'filterWidth': ONE_HOUR_MILLISECONDS,
57 }, getVerificationFunction([PICASA_ENTRY]));
59 function mostVisitedDayOfTheWeekRightDay() {
60 chrome.experimental.history.getMostVisited({
61 'filterTime': Date.parse('25 Apr 2012, 13:30:00'),
63 }, getVerificationFunction([PICASA_ENTRY, GOOGLE_ENTRY]));
65 function mostVisitedDayOfTheWeekWrongDay() {
66 chrome.experimental.history.getMostVisited({
67 'filterTime': Date.parse('25 Apr 2012, 13:30:00'),
69 }, getVerificationFunction([]));