- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / history / most_visited.js
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.
4
5 // History api test for Chrome.
6 // browser_tests.exe --gtest_filter=HistoryExtensionApiTest.MostVisited
7
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;
12
13 function getVerificationFunction(expected) {
14   return function(results) {
15     chrome.test.assertEq(expected, results);
16     chrome.test.succeed();
17   }
18 }
19
20 // runHistoryTestFns is defined in ./common.js .
21 runHistoryTestFns([
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]));
27   },
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]));
33   },
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([]));
39   },
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([]));
45   },
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]));
51   },
52   function mostVisitedMaxResults() {
53     chrome.experimental.history.getMostVisited({
54       'filterTime': Date.parse('24 Apr 2012, 13:30:00'),
55       'filterWidth': ONE_HOUR_MILLISECONDS,
56       maxResults: 1,
57     }, getVerificationFunction([PICASA_ENTRY]));
58   },
59   function mostVisitedDayOfTheWeekRightDay() {
60     chrome.experimental.history.getMostVisited({
61       'filterTime': Date.parse('25 Apr 2012, 13:30:00'),
62       'dayOfTheWeek': 2,
63     }, getVerificationFunction([PICASA_ENTRY, GOOGLE_ENTRY]));
64   },
65   function mostVisitedDayOfTheWeekWrongDay() {
66     chrome.experimental.history.getMostVisited({
67       'filterTime': Date.parse('25 Apr 2012, 13:30:00'),
68       'dayOfTheWeek': 1,
69     }, getVerificationFunction([]));
70   }
71 ]);