OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import "/sky/framework/shell.dart" as shell; | 5 import "/sky/framework/embedder.dart"; |
6 import "dart:async"; | 6 import "dart:async"; |
7 import "dart:sky"; | 7 import "dart:sky"; |
8 import "dart:sky.internals" as internals; | 8 import "dart:sky.internals" as internals; |
9 import "package:mojo/services/input_events/public/interfaces/input_event_constan
ts.mojom.dart" as constants; | 9 import "package:mojo/services/input_events/public/interfaces/input_event_constan
ts.mojom.dart" as constants; |
10 import "package:mojo/services/input_events/public/interfaces/input_events.mojom.
dart" as events; | 10 import "package:mojo/services/input_events/public/interfaces/input_events.mojom.
dart" as events; |
11 import "package:mojo/services/input_events/public/interfaces/input_key_codes.moj
om.dart" as codes; | 11 import "package:mojo/services/input_events/public/interfaces/input_key_codes.moj
om.dart" as codes; |
12 import "package:sky/services/testing/test_harness.mojom.dart" as harness; | 12 import "package:sky/services/testing/test_harness.mojom.dart" as harness; |
13 | 13 |
14 bool _isDone = false; | 14 bool _isDone = false; |
15 int _keyPressesRemaining = 0; | 15 int _keyPressesRemaining = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 void handleKeyPress_(Event event) { | 56 void handleKeyPress_(Event event) { |
57 --_keyPressesRemaining; | 57 --_keyPressesRemaining; |
58 _checkComplete(); | 58 _checkComplete(); |
59 } | 59 } |
60 | 60 |
61 harness.TestHarnessProxy _init() { | 61 harness.TestHarnessProxy _init() { |
62 document.addEventListener('keypress', handleKeyPress_); | 62 document.addEventListener('keypress', handleKeyPress_); |
63 | 63 |
64 var harnessProxy = new harness.TestHarnessProxy.unbound(); | 64 var harnessProxy = new harness.TestHarnessProxy.unbound(); |
65 shell.connectToService("mojo:sky_tester", harnessProxy); | 65 embedder.connectToService("mojo:sky_tester", harnessProxy); |
66 return harnessProxy; | 66 return harnessProxy; |
67 } | 67 } |
68 | 68 |
69 final harness.TestHarnessProxy _harness = _init(); | 69 final harness.TestHarnessProxy _harness = _init(); |
70 | 70 |
71 // |0| should be EventFlags_NONE once its a compile-time constant. | 71 // |0| should be EventFlags_NONE once its a compile-time constant. |
72 void keyDown(int keyCode, [int eventFlags = 0]) { | 72 void keyDown(int keyCode, [int eventFlags = 0]) { |
73 if (!_chars.contains(keyCode)) { | 73 if (!_chars.contains(keyCode)) { |
74 _harness.dispatchInputEvent( | 74 _harness.dispatchInputEvent( |
75 new events.Event() | 75 new events.Event() |
(...skipping 24 matching lines...) Expand all Loading... |
100 ..unmodifiedText = keyCode)); | 100 ..unmodifiedText = keyCode)); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 void done() { | 104 void done() { |
105 if (_isDone) | 105 if (_isDone) |
106 throw "Already done."; | 106 throw "Already done."; |
107 _isDone = true; | 107 _isDone = true; |
108 _checkComplete(); | 108 _checkComplete(); |
109 } | 109 } |
OLD | NEW |