| Index: tests/html/wheelevent_test.dart
|
| diff --git a/tests/html/wheelevent_test.dart b/tests/html/wheelevent_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a9932b9677bb2f416606907cbd5133907819c48f
|
| --- /dev/null
|
| +++ b/tests/html/wheelevent_test.dart
|
| @@ -0,0 +1,74 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +library wheel_event_test;
|
| +import '../../pkg/unittest/lib/unittest.dart';
|
| +import '../../pkg/unittest/lib/html_config.dart';
|
| +import 'dart:html';
|
| +
|
| +
|
| +main() {
|
| +
|
| + useHtmlConfiguration();
|
| +
|
| + var userAgent = window.navigator.userAgent;
|
| +
|
| + // Lame platform-dependent check to validate that our assumptions about
|
| + // which event is being used is correct.
|
| + var wheelEvent = 'wheel';
|
| + if (userAgent.contains("Opera", 0)) {
|
| + wheelEvent = 'mousewheel';
|
| + } else if (userAgent.contains("MSIE", 0)) {
|
| + wheelEvent = 'mousewheel';
|
| + } else if (userAgent.contains('Firefox')) {
|
| + // FF appears to have recently added support for wheel.
|
| + if (userAgent.contains('Firefox/17')) {
|
| + wheelEvent = 'DOMMouseScroll';
|
| + } else {
|
| + wheelEvent = 'wheel';
|
| + }
|
| + } else if (userAgent.contains('WebKit', 0)) {
|
| + wheelEvent = 'mousewheel';
|
| + }
|
| +
|
| + test('wheelEvent', () {
|
| + var element = new DivElement();
|
| + element.on.mouseWheel.add(expectAsync1((e) {
|
| + expect(e.screenX, 100);
|
| + expect(e.deltaX, 0);
|
| + expect(e.deltaY, 240);
|
| + }));
|
| + var event = new WheelEvent(wheelEvent,
|
| + window,
|
| + 0,
|
| + 240,
|
| + 0,
|
| + 100,
|
| + 200,
|
| + 10,
|
| + 20,
|
| + 0);
|
| + element.$dom_dispatchEvent(event);
|
| + });
|
| +
|
| + test('wheelEvent Stream', () {
|
| + var element = new DivElement();
|
| + element.onMouseWheel.listen(expectAsync1((e) {
|
| + expect(e.screenX, 100);
|
| + expect(e.deltaX, 0);
|
| + expect(e.deltaY, 240);
|
| + }));
|
| + var event = new WheelEvent(wheelEvent,
|
| + window,
|
| + 0,
|
| + 240,
|
| + 0,
|
| + 100,
|
| + 200,
|
| + 10,
|
| + 20,
|
| + 0);
|
| + element.$dom_dispatchEvent(event);
|
| + });
|
| +}
|
|
|