Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / forms / calendar-picker / calendar-picker-mouse-operations.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../../forms/resources/common.js"></script>
6 <script src="../../forms/resources/picker-common.js"></script>
7 <script src="resources/calendar-picker-common.js"></script>
8 </head>
9 <body>
10 <input type=date id=date value="2000-01-02">
11 <p id="description"></p>
12 <div id="console"></div>
13 <script>
14 description("Tests if calendar picker mouse opearations work as expected.");
15
16 debug('Check that page popup doesn\'t exist at first.');
17 shouldBeNull('document.getElementById("mock-page-popup")');
18
19 openPickerWithMock(document.getElementById('date'), test);
20
21 function test() {
22     shouldBeEqualToString('currentMonth()', '2000-01');
23     shouldBeEqualToString('selectedValue()', '2000-01-02');
24     shouldBeEqualToString('selectedDayCells()', '2000-01-02');
25     shouldBeEqualToString('highlightedValue()', '2000-01-02');
26     shouldBeEqualToString('highlightedDayCells()', '2000-01-02');
27
28     debug('Check that hovering over an entry highlights it.');
29     hoverOverDayCellAt(5, 0);
30     shouldBeEqualToString('currentMonth()', '2000-01');
31     shouldBeEqualToString('selectedValue()', '2000-01-02');
32     shouldBeEqualToString('selectedDayCells()', '2000-01-02');
33     shouldBeEqualToString('highlightedValue()', '1999-12-31');
34     shouldBeEqualToString('highlightedDayCells()', '1999-12-31');
35
36     hoverOverDayCellAt(2, 1);
37     shouldBeEqualToString('currentMonth()', '2000-01');
38     shouldBeEqualToString('selectedValue()', '2000-01-02');
39     shouldBeEqualToString('selectedDayCells()', '2000-01-02');
40     shouldBeEqualToString('highlightedValue()', '2000-01-04');
41     shouldBeEqualToString('highlightedDayCells()', '2000-01-04');
42
43     debug('Check that navigating between months maintains highlighted position.');
44     eventSender.keyDown('m');
45     shouldBeEqualToString('currentMonth()', '2000-02');
46     shouldBeEqualToString('selectedValue()', '2000-01-02');
47     shouldBeEqualToString('selectedDayCells()', '');
48     shouldBeEqualToString('highlightedValue()', '2000-02-08');
49     shouldBeEqualToString('highlightedDayCells()', '2000-02-08');
50
51     debug('Check that mouse click sets the value.');
52     removeCommitDelay();
53     clickDayCellAt(6, 0);
54     shouldBeEqualToString('document.getElementById("date").value', '2000-02-05');
55
56     waitUntilClosing(function() {
57         openPickerWithMock(document.getElementById('date'), test2);
58     });
59 }
60
61 function test2() {
62     debug('Check that clicking the month popup button opens the month popup.');
63     shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
64     clickMonthPopupButton();
65     shouldBeTrue('popupWindow.global.picker.monthPopupView.isVisible');
66     shouldBeEqualToString('highlightedMonthButton()', '2000-02');
67     checkYearListViewScrollOffset();
68
69     debug('Check that hovering over a month button highlights it.');
70
71     hoverOverMonthButton(2000, 9);
72     shouldBeEqualToString('highlightedMonthButton()', '2000-10');
73
74     debug('Check that month wheel scrolls the list in the month popup.');
75
76     eventSender.mouseScrollBy(0, 1);
77     shouldBeTrue('checkYearListViewScrollOffset() > 0');
78
79     eventSender.mouseScrollBy(0, -1);
80     shouldBeTrue('checkYearListViewScrollOffset() < 0');
81
82     debug('Check that clicking an year list cell opens it.');
83     eventSender.mouseScrollBy(0, 10);
84     shouldBeTrue('checkYearListViewScrollOffset() > 0');
85     clickYearListCell(1999);
86     shouldBeEqualToString('highlightedMonthButton()', '1999-10');
87
88     debug('Check that clicking the month popup sets the month.');
89
90     clickMonthButton(1999, 5);
91     shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
92     shouldBeEqualToString('currentMonth()', '1999-06');
93
94     finishJSTest();
95 }
96 </script>
97 </body>
98 </html>