summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/week-picker-mouse-operations.html
blob: 4328b1ddbc449e5ffeec5da1e347b419ae656a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../forms/resources/common.js"></script>
<script src="../../forms/resources/picker-common.js"></script>
<script src="resources/calendar-picker-common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<input type=week id=week value="2000-W01">
<script>
description("Tests if week picker mouse operations work as expected.");

debug('Check that page popup doesn\'t exist at first.');
shouldBeNull('document.getElementById("mock-page-popup")');

openPicker(document.getElementById('week'), test);

function test() {
    shouldBeEqualToString('currentMonth()', '2000-01');
    shouldBeEqualToString('selectedValue()', '2000-W01');
    shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
    shouldBeEqualToString('highlightedValue()', '2000-W01');
    shouldBeEqualToString('highlightedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');

    debug('Check that hovering over an entry highlights it.');
    hoverOverDayCellAt(0, 0);
    shouldBeEqualToString('currentMonth()', '2000-01');
    shouldBeEqualToString('selectedValue()', '2000-W01');
    shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
    shouldBeEqualToString('highlightedValue()', '1999-W51');
    shouldBeEqualToString('highlightedDayCells()', '1999-12-26');

    hoverOverDayCellAt(6, 0);
    shouldBeEqualToString('currentMonth()', '2000-01');
    shouldBeEqualToString('selectedValue()', '2000-W01');
    shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
    shouldBeEqualToString('highlightedValue()', '1999-W52');
    shouldBeEqualToString('highlightedDayCells()', '1999-12-27,1999-12-28,1999-12-29,1999-12-30,1999-12-31,2000-01-01,2000-01-02');

    hoverOverDayCellAt(2, 1);
    shouldBeEqualToString('currentMonth()', '2000-01');
    shouldBeEqualToString('selectedValue()', '2000-W01');
    shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
    shouldBeEqualToString('highlightedValue()', '2000-W01');
    shouldBeEqualToString('highlightedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');

    hoverOverDayCellAt(6, 5);
    shouldBeEqualToString('currentMonth()', '2000-01');
    shouldBeEqualToString('selectedValue()', '2000-W01');
    shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
    shouldBeEqualToString('highlightedValue()', '2000-W05');
    shouldBeEqualToString('highlightedDayCells()', '2000-01-31,2000-02-01,2000-02-02,2000-02-03,2000-02-04,2000-02-05');

    debug('Check that mouse click sets the value.');
    setNoCloseOnCommit();
    clickDayCellAt(6, 0);
    shouldBeEqualToString('currentMonth()', '2000-01');
    shouldBeEqualToString('selectedValue()', '1999-W52');
    shouldBeEqualToString('selectedDayCells()', '1999-12-27,1999-12-28,1999-12-29,1999-12-30,1999-12-31,2000-01-01,2000-01-02');
    shouldBeEqualToString('highlightedValue()', '1999-W52');
    shouldBeEqualToString('highlightedDayCells()', '1999-12-27,1999-12-28,1999-12-29,1999-12-30,1999-12-31,2000-01-01,2000-01-02');
    shouldBeEqualToString('document.getElementById("week").value', '1999-W52');

    debug('Check that clicking the month popup button opens the month popup.');
    shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
    clickMonthPopupButton();
    shouldBeTrue('popupWindow.global.picker.monthPopupView.isVisible');
    shouldBeEqualToString('highlightedMonthButton()', '2000-01');

    debug('Check that hovering over a month button highlights it.');

    hoverOverMonthButton(2000, 9);
    shouldBeEqualToString('highlightedMonthButton()', '2000-10');

    debug('Check that month wheel scrolls the list in the month popup.');

    checkYearListViewScrollOffset();
    eventSender.mouseScrollBy(0, 120);
    shouldBeTrue('checkYearListViewScrollOffset() > 0');

    checkYearListViewScrollOffset();
    eventSender.mouseScrollBy(0, -120);
    shouldBeTrue('checkYearListViewScrollOffset() < 0');

    debug('Check that clicking the month popup sets the month.');

    clickMonthButton(2000, 5);
    shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
    shouldBeEqualToString('currentMonth()', '2000-06');

    debug('Check that clicking the month popup button opens the month popup.');
    shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
    clickMonthPopupButton();
    shouldBeTrue('popupWindow.global.picker.monthPopupView.isVisible');
    shouldBeEqualToString('highlightedMonthButton()', '2000-06');
    checkYearListViewScrollOffset();

    debug('Check that hovering over a month button highlights it.');

    hoverOverMonthButton(2000, 9);
    shouldBeEqualToString('highlightedMonthButton()', '2000-10');

    debug('Check that month wheel scrolls the list in the month popup.');

    eventSender.mouseScrollBy(0, 1);
    shouldBeTrue('checkYearListViewScrollOffset() > 0');

    eventSender.mouseScrollBy(0, -1);
    shouldBeTrue('checkYearListViewScrollOffset() < 0');

    debug('Check that clicking an year list cell opens it.');
    eventSender.mouseScrollBy(0, 10);
    shouldBeTrue('checkYearListViewScrollOffset() > 0');
    clickYearListCell(1999);
    shouldBeEqualToString('highlightedMonthButton()', '1999-10');

    debug('Check that clicking the month popup sets the month.');

    clickMonthButton(1999, 5);
    shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
    shouldBeEqualToString('currentMonth()', '1999-06');

    finishJSTest();
}
</script>
</body>
</html>