| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:html'; | 6 import 'dart:html'; |
| 7 | 7 |
| 8 import 'package:expect/minitest.dart'; | 8 import 'package:expect/minitest.dart'; |
| 9 | 9 |
| 10 class Mock { | 10 class Mock { |
| 11 noSuchMethod(Invocation i) => document; | 11 noSuchMethod(Invocation i) => document; |
| 12 } | 12 } |
| 13 | 13 |
| 14 @proxy | 14 @proxy |
| 15 class MockBodyElement extends Mock implements BodyElement { | 15 class MockBodyElement extends Mock implements BodyElement { |
| 16 Node append(Node e) => e; | 16 Node append(Node e) => e; |
| 17 } | 17 } |
| 18 | 18 |
| 19 class _EventListeners { |
| 20 Stream<Event> get onBlur => new Stream.fromIterable([]); |
| 21 } |
| 22 |
| 19 @proxy | 23 @proxy |
| 20 class MockHtmlDocument extends Mock implements HtmlDocument { | 24 class MockHtmlDocument extends Mock |
| 25 with _EventListeners |
| 26 implements HtmlDocument { |
| 21 BodyElement get body => new MockBodyElement(); | 27 BodyElement get body => new MockBodyElement(); |
| 22 } | 28 } |
| 23 | 29 |
| 24 @proxy | 30 @proxy |
| 25 class MockWindow extends Mock implements Window { | 31 class MockWindow extends Mock with _EventListeners implements Window { |
| 26 Stream<Event> get onBeforeUnload => new Stream.fromIterable([]); | 32 Stream<Event> get onBeforeUnload => new Stream.fromIterable([]); |
| 27 | 33 |
| 28 String name = "MOCK_NAME"; | 34 String name = "MOCK_NAME"; |
| 29 } | 35 } |
| 30 | 36 |
| 31 @proxy | 37 @proxy |
| 32 class MockLocation extends Mock implements Location { | 38 class MockLocation extends Mock implements Location { |
| 33 String href = "MOCK_HREF"; | 39 String href = "MOCK_HREF"; |
| 34 } | 40 } |
| 35 | 41 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 loc1.href = "RESET"; | 64 loc1.href = "RESET"; |
| 59 expect(loc2.href, equals("RESET")); | 65 expect(loc2.href, equals("RESET")); |
| 60 loc2.href = "RESET2"; | 66 loc2.href = "RESET2"; |
| 61 expect(loc3.href, equals("RESET2")); | 67 expect(loc3.href, equals("RESET2")); |
| 62 }); | 68 }); |
| 63 | 69 |
| 64 test('method', () { | 70 test('method', () { |
| 65 HtmlDocument doc = new MockHtmlDocument(); | 71 HtmlDocument doc = new MockHtmlDocument(); |
| 66 expect(doc.body.append(null), equals(null)); | 72 expect(doc.body.append(null), equals(null)); |
| 67 }); | 73 }); |
| 74 |
| 75 test('mixin', () { |
| 76 Window win = new MockWindow(); |
| 77 expect(win.onBlur is Stream, isTrue, reason: 'onBlur should be a stream'); |
| 78 HtmlDocument doc = new MockHtmlDocument(); |
| 79 expect(doc.onBlur is Stream, isTrue, reason: 'onBlur should be a stream'); |
| 80 }); |
| 68 } | 81 } |
| OLD | NEW |