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>
10 <p id=
"description"></p>
11 <div id=
"console"></div>
12 <input type=week id=week
value=
"2000-W01">
14 description("Tests if week picker mouse operations work as expected.");
16 debug('Check that page popup doesn\'t exist at first.');
17 shouldBeNull('document.getElementById("mock-page-popup")');
19 openPicker(document
.getElementById('week'), test
);
22 shouldBeEqualToString('currentMonth()', '2000-01');
23 shouldBeEqualToString('selectedValue()', '2000-W01');
24 shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
25 shouldBeEqualToString('highlightedValue()', '2000-W01');
26 shouldBeEqualToString('highlightedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
28 debug('Check that hovering over an entry highlights it.');
29 hoverOverDayCellAt(0, 0);
30 shouldBeEqualToString('currentMonth()', '2000-01');
31 shouldBeEqualToString('selectedValue()', '2000-W01');
32 shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
33 shouldBeEqualToString('highlightedValue()', '1999-W51');
34 shouldBeEqualToString('highlightedDayCells()', '1999-12-26');
36 hoverOverDayCellAt(6, 0);
37 shouldBeEqualToString('currentMonth()', '2000-01');
38 shouldBeEqualToString('selectedValue()', '2000-W01');
39 shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
40 shouldBeEqualToString('highlightedValue()', '1999-W52');
41 shouldBeEqualToString('highlightedDayCells()', '1999-12-27,1999-12-28,1999-12-29,1999-12-30,1999-12-31,2000-01-01,2000-01-02');
43 hoverOverDayCellAt(2, 1);
44 shouldBeEqualToString('currentMonth()', '2000-01');
45 shouldBeEqualToString('selectedValue()', '2000-W01');
46 shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
47 shouldBeEqualToString('highlightedValue()', '2000-W01');
48 shouldBeEqualToString('highlightedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
50 hoverOverDayCellAt(6, 5);
51 shouldBeEqualToString('currentMonth()', '2000-01');
52 shouldBeEqualToString('selectedValue()', '2000-W01');
53 shouldBeEqualToString('selectedDayCells()', '2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09');
54 shouldBeEqualToString('highlightedValue()', '2000-W05');
55 shouldBeEqualToString('highlightedDayCells()', '2000-01-31,2000-02-01,2000-02-02,2000-02-03,2000-02-04,2000-02-05');
57 debug('Check that mouse click sets the value.');
60 shouldBeEqualToString('currentMonth()', '2000-01');
61 shouldBeEqualToString('selectedValue()', '1999-W52');
62 shouldBeEqualToString('selectedDayCells()', '1999-12-27,1999-12-28,1999-12-29,1999-12-30,1999-12-31,2000-01-01,2000-01-02');
63 shouldBeEqualToString('highlightedValue()', '1999-W52');
64 shouldBeEqualToString('highlightedDayCells()', '1999-12-27,1999-12-28,1999-12-29,1999-12-30,1999-12-31,2000-01-01,2000-01-02');
65 shouldBeEqualToString('document.getElementById("week").value', '1999-W52');
67 debug('Check that clicking the month popup button opens the month popup.');
68 shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
69 clickMonthPopupButton();
70 shouldBeTrue('popupWindow.global.picker.monthPopupView.isVisible');
71 shouldBeEqualToString('highlightedMonthButton()', '2000-01');
73 debug('Check that hovering over a month button highlights it.');
75 hoverOverMonthButton(2000, 9);
76 shouldBeEqualToString('highlightedMonthButton()', '2000-10');
78 debug('Check that month wheel scrolls the list in the month popup.');
80 checkYearListViewScrollOffset();
81 eventSender
.mouseScrollBy(0, 120);
82 shouldBeTrue('checkYearListViewScrollOffset() > 0');
84 checkYearListViewScrollOffset();
85 eventSender
.mouseScrollBy(0, -120);
86 shouldBeTrue('checkYearListViewScrollOffset() < 0');
88 debug('Check that clicking the month popup sets the month.');
90 clickMonthButton(2000, 5);
91 shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
92 shouldBeEqualToString('currentMonth()', '2000-06');
94 debug('Check that clicking the month popup button opens the month popup.');
95 shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
96 clickMonthPopupButton();
97 shouldBeTrue('popupWindow.global.picker.monthPopupView.isVisible');
98 shouldBeEqualToString('highlightedMonthButton()', '2000-06');
99 checkYearListViewScrollOffset();
101 debug('Check that hovering over a month button highlights it.');
103 hoverOverMonthButton(2000, 9);
104 shouldBeEqualToString('highlightedMonthButton()', '2000-10');
106 debug('Check that month wheel scrolls the list in the month popup.');
108 eventSender
.mouseScrollBy(0, 1);
109 shouldBeTrue('checkYearListViewScrollOffset() > 0');
111 eventSender
.mouseScrollBy(0, -1);
112 shouldBeTrue('checkYearListViewScrollOffset() < 0');
114 debug('Check that clicking an year list cell opens it.');
115 eventSender
.mouseScrollBy(0, 10);
116 shouldBeTrue('checkYearListViewScrollOffset() > 0');
117 clickYearListCell(1999);
118 shouldBeEqualToString('highlightedMonthButton()', '1999-10');
120 debug('Check that clicking the month popup sets the month.');
122 clickMonthButton(1999, 5);
123 shouldBeFalse('popupWindow.global.picker.monthPopupView.isVisible');
124 shouldBeEqualToString('currentMonth()', '1999-06');