Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Unified Diff: tests/html/event_subscription_specification_test.dart

Issue 2022263002: Make Dom events run through zone tasks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Mark as experimental Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/event_zone_task_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/event_subscription_specification_test.dart
diff --git a/tests/html/event_subscription_specification_test.dart b/tests/html/event_subscription_specification_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..406ed37b32b1e0cb665fcf477ddd2e3184e06237
--- /dev/null
+++ b/tests/html/event_subscription_specification_test.dart
@@ -0,0 +1,121 @@
+// Copyright (c) 2016, 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 EventTaskZoneTest;
+
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'dart:async';
+import 'dart:html';
+
+// Tests event-subscription specifications.
+
+main() {
+ useHtmlConfiguration();
+
+ var defaultTarget = new Element.div();
+ var defaultOnData = (x) => null;
+
+ EventSubscriptionSpecification createSpec({useCapture, isOneShot}) {
+ return new EventSubscriptionSpecification(
+ name: "name",
+ target: defaultTarget,
+ useCapture: useCapture,
+ isOneShot: isOneShot,
+ onData: defaultOnData,
+ eventType: "eventType");
+ }
+
+ for (var useCapture in [true, false]) {
+ for (var isOneShot in [true, false]) {
+ var spec = createSpec(useCapture: useCapture, isOneShot: isOneShot);
+
+ test(
+ "EventSubscriptionSpecification - constructor "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replaced = spec.replace(eventType: 'replace-eventType');
+ expect(replaced.name, "name");
+ expect(replaced.target, defaultTarget);
+ expect(replaced.useCapture, useCapture);
+ expect(replaced.isOneShot, isOneShot);
+ expect(replaced.onData, equals(defaultOnData));
+ expect(replaced.eventType, "replace-eventType");
+ });
+
+ test(
+ "replace name "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replaced = spec.replace(name: 'replace-name');
+ expect(replaced.name, "replace-name");
+ expect(replaced.target, defaultTarget);
+ expect(replaced.useCapture, useCapture);
+ expect(replaced.isOneShot, isOneShot);
+ expect(replaced.onData, equals(defaultOnData));
+ expect(replaced.eventType, "eventType");
+ });
+
+ test(
+ "replace target "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replacementTarget = new Element.a();
+ var replaced = spec.replace(target: replacementTarget);
+ expect(replaced.name, "name");
+ expect(replaced.target, replacementTarget);
+ expect(replaced.useCapture, useCapture);
+ expect(replaced.isOneShot, isOneShot);
+ expect(replaced.onData, equals(defaultOnData));
+ expect(replaced.eventType, "eventType");
+ });
+
+ test(
+ "replace useCapture "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replaced = spec.replace(useCapture: !useCapture);
+ expect(replaced.name, "name");
+ expect(replaced.target, defaultTarget);
+ expect(replaced.useCapture, !useCapture);
+ expect(replaced.isOneShot, isOneShot);
+ expect(replaced.onData, equals(defaultOnData));
+ expect(replaced.eventType, "eventType");
+ });
+
+ test(
+ "replace isOneShot "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replaced = spec.replace(isOneShot: !isOneShot);
+ expect(replaced.name, "name");
+ expect(replaced.target, defaultTarget);
+ expect(replaced.useCapture, useCapture);
+ expect(replaced.isOneShot, !isOneShot);
+ expect(replaced.onData, equals(defaultOnData));
+ expect(replaced.eventType, "eventType");
+ });
+
+ test(
+ "replace onData "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replacementOnData = (x) {};
+ var replaced = spec.replace(onData: replacementOnData);
+ expect(replaced.name, "name");
+ expect(replaced.target, defaultTarget);
+ expect(replaced.useCapture, useCapture);
+ expect(replaced.isOneShot, isOneShot);
+ expect(replaced.onData, equals(replacementOnData));
+ expect(replaced.eventType, "eventType");
+ });
+
+ test(
+ "replace eventType "
+ "useCapture: $useCapture isOneShot: $isOneShot", () {
+ var replaced = spec.replace(eventType: 'replace-eventType');
+ expect(replaced.name, "name");
+ expect(replaced.target, defaultTarget);
+ expect(replaced.useCapture, useCapture);
+ expect(replaced.isOneShot, isOneShot);
+ expect(replaced.onData, equals(defaultOnData));
+ expect(replaced.eventType, "replace-eventType");
+ });
+ }
+ }
+}
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/event_zone_task_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698